blob: 1a7703a496556b14f41324d49dbb68bebf59d2ef [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 Avdoninbab282b2006-08-22 13:31:58 +0200227 ALC883_ACER,
Tobin Davis2880a8672007-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:
1617 spec->init_amp = ALC_INIT_DEFAULT;
1618 break;
1619 }
1620
1621 /* is laptop or Desktop and enable the function "Mute internal speaker
1622 * when the external headphone out jack is plugged"
1623 */
1624 if (!(ass & 0x8000))
1625 return 1;
1626 /*
1627 * 10~8 : Jack location
1628 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1629 * 14~13: Resvered
1630 * 15 : 1 --> enable the function "Mute internal speaker
1631 * when the external headphone out jack is plugged"
1632 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001633 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001634 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001635 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1636 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001637 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001638 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001639 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001640 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001641 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001642 else if (tmp == 3)
1643 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001644 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001645 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001646 for (i = 0; i < spec->autocfg.line_outs; i++)
1647 if (spec->autocfg.line_out_pins[i] == nid)
1648 return 1;
1649 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001650 }
1651
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001652 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001653 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001654 return 1;
1655}
Kailang Yangea1fb292008-08-26 12:58:38 +02001656
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001657static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001658 hda_nid_t porta, hda_nid_t porte,
1659 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001660{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001661 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001662 struct alc_spec *spec = codec->spec;
1663 snd_printd("realtek: "
1664 "Enable default setup for auto mode as fallback\n");
1665 spec->init_amp = ALC_INIT_DEFAULT;
1666 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001667 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001668 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001669}
1670
Takashi Iwai41e41f12005-06-08 14:48:49 +02001671/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001672 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001673 */
1674
1675struct alc_pincfg {
1676 hda_nid_t nid;
1677 u32 val;
1678};
1679
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001680struct alc_fixup {
David Henningsson90622912010-10-14 14:50:18 +02001681 unsigned int sku;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001682 const struct alc_pincfg *pins;
1683 const struct hda_verb *verbs;
1684};
1685
1686static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001687 const struct snd_pci_quirk *quirk,
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001688 const struct alc_fixup *fix,
1689 int pre_init)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001690{
1691 const struct alc_pincfg *cfg;
David Henningsson90622912010-10-14 14:50:18 +02001692 struct alc_spec *spec;
Takashi Iwaif95474e2007-07-10 00:47:43 +02001693
1694 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1695 if (!quirk)
1696 return;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001697 fix += quirk->value;
1698 cfg = fix->pins;
David Henningsson90622912010-10-14 14:50:18 +02001699 if (pre_init && fix->sku) {
1700#ifdef CONFIG_SND_DEBUG_VERBOSE
1701 snd_printdd(KERN_INFO "hda_codec: %s: Apply sku override for %s\n",
1702 codec->chip_name, quirk->name);
1703#endif
1704 spec = codec->spec;
1705 spec->cdefine.sku_cfg = fix->sku;
1706 spec->cdefine.fixup = 1;
1707 }
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001708 if (pre_init && cfg) {
1709#ifdef CONFIG_SND_DEBUG_VERBOSE
1710 snd_printdd(KERN_INFO "hda_codec: %s: Apply pincfg for %s\n",
1711 codec->chip_name, quirk->name);
1712#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001713 for (; cfg->nid; cfg++)
1714 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1715 }
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001716 if (!pre_init && fix->verbs) {
1717#ifdef CONFIG_SND_DEBUG_VERBOSE
1718 snd_printdd(KERN_INFO "hda_codec: %s: Apply fix-verbs for %s\n",
1719 codec->chip_name, quirk->name);
1720#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001721 add_verb(codec->spec, fix->verbs);
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001722 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001723}
1724
Kailang Yang274693f2009-12-03 10:07:50 +01001725static int alc_read_coef_idx(struct hda_codec *codec,
1726 unsigned int coef_idx)
1727{
1728 unsigned int val;
1729 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1730 coef_idx);
1731 val = snd_hda_codec_read(codec, 0x20, 0,
1732 AC_VERB_GET_PROC_COEF, 0);
1733 return val;
1734}
1735
Kailang Yang977ddd62010-09-15 10:02:29 +02001736static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1737 unsigned int coef_val)
1738{
1739 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1740 coef_idx);
1741 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
1742 coef_val);
1743}
1744
Takashi Iwai757899a2010-07-30 10:48:14 +02001745/* set right pin controls for digital I/O */
1746static void alc_auto_init_digital(struct hda_codec *codec)
1747{
1748 struct alc_spec *spec = codec->spec;
1749 int i;
1750 hda_nid_t pin;
1751
1752 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1753 pin = spec->autocfg.dig_out_pins[i];
1754 if (pin) {
1755 snd_hda_codec_write(codec, pin, 0,
1756 AC_VERB_SET_PIN_WIDGET_CONTROL,
1757 PIN_OUT);
1758 }
1759 }
1760 pin = spec->autocfg.dig_in_pin;
1761 if (pin)
1762 snd_hda_codec_write(codec, pin, 0,
1763 AC_VERB_SET_PIN_WIDGET_CONTROL,
1764 PIN_IN);
1765}
1766
1767/* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1768static void alc_auto_parse_digital(struct hda_codec *codec)
1769{
1770 struct alc_spec *spec = codec->spec;
1771 int i, err;
1772 hda_nid_t dig_nid;
1773
1774 /* support multiple SPDIFs; the secondary is set up as a slave */
1775 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1776 err = snd_hda_get_connections(codec,
1777 spec->autocfg.dig_out_pins[i],
1778 &dig_nid, 1);
1779 if (err < 0)
1780 continue;
1781 if (!i) {
1782 spec->multiout.dig_out_nid = dig_nid;
1783 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1784 } else {
1785 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1786 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1787 break;
1788 spec->slave_dig_outs[i - 1] = dig_nid;
1789 }
1790 }
1791
1792 if (spec->autocfg.dig_in_pin) {
Takashi Iwai01fdf182010-09-24 09:09:42 +02001793 dig_nid = codec->start_nid;
1794 for (i = 0; i < codec->num_nodes; i++, dig_nid++) {
1795 unsigned int wcaps = get_wcaps(codec, dig_nid);
1796 if (get_wcaps_type(wcaps) != AC_WID_AUD_IN)
1797 continue;
1798 if (!(wcaps & AC_WCAP_DIGITAL))
1799 continue;
1800 if (!(wcaps & AC_WCAP_CONN_LIST))
1801 continue;
1802 err = get_connection_index(codec, dig_nid,
1803 spec->autocfg.dig_in_pin);
1804 if (err >= 0) {
1805 spec->dig_in_nid = dig_nid;
1806 break;
1807 }
1808 }
Takashi Iwai757899a2010-07-30 10:48:14 +02001809 }
1810}
1811
Takashi Iwaif95474e2007-07-10 00:47:43 +02001812/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001813 * ALC888
1814 */
1815
1816/*
1817 * 2ch mode
1818 */
1819static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1820/* Mic-in jack as mic in */
1821 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1822 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1823/* Line-in jack as Line in */
1824 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1825 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1826/* Line-Out as Front */
1827 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1828 { } /* end */
1829};
1830
1831/*
1832 * 4ch mode
1833 */
1834static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1835/* Mic-in jack as mic in */
1836 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1837 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1838/* Line-in jack as Surround */
1839 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1840 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1841/* Line-Out as Front */
1842 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1843 { } /* end */
1844};
1845
1846/*
1847 * 6ch mode
1848 */
1849static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1850/* Mic-in jack as CLFE */
1851 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1852 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1853/* Line-in jack as Surround */
1854 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1855 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1856/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1857 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1858 { } /* end */
1859};
1860
1861/*
1862 * 8ch mode
1863 */
1864static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1865/* Mic-in jack as CLFE */
1866 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1867 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1868/* Line-in jack as Surround */
1869 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1870 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1871/* Line-Out as Side */
1872 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1873 { } /* end */
1874};
1875
1876static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1877 { 2, alc888_4ST_ch2_intel_init },
1878 { 4, alc888_4ST_ch4_intel_init },
1879 { 6, alc888_4ST_ch6_intel_init },
1880 { 8, alc888_4ST_ch8_intel_init },
1881};
1882
1883/*
1884 * ALC888 Fujitsu Siemens Amillo xa3530
1885 */
1886
1887static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1888/* Front Mic: set to PIN_IN (empty by default) */
1889 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1890/* Connect Internal HP to Front */
1891 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1892 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1893 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1894/* Connect Bass HP to Front */
1895 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1896 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1897 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1898/* Connect Line-Out side jack (SPDIF) to Side */
1899 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1900 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1901 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1902/* Connect Mic jack to CLFE */
1903 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1904 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1905 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1906/* Connect Line-in jack to Surround */
1907 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1908 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1909 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1910/* Connect HP out jack to Front */
1911 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1912 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1913 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1914/* Enable unsolicited event for HP jack and Line-out jack */
1915 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1916 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1917 {}
1918};
1919
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001920static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001921{
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001922 alc_automute_speaker(codec, 0);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001923}
1924
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001925static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1926 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001927{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001928 if (codec->vendor_id == 0x10ec0880)
1929 res >>= 28;
1930 else
1931 res >>= 26;
1932 if (res == ALC880_HP_EVENT)
1933 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001934}
1935
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001936static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001937{
1938 struct alc_spec *spec = codec->spec;
1939
1940 spec->autocfg.hp_pins[0] = 0x15;
1941 spec->autocfg.speaker_pins[0] = 0x14;
1942 spec->autocfg.speaker_pins[1] = 0x16;
1943 spec->autocfg.speaker_pins[2] = 0x17;
1944 spec->autocfg.speaker_pins[3] = 0x19;
1945 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001946}
1947
1948static void alc889_intel_init_hook(struct hda_codec *codec)
1949{
1950 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001951 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001952}
1953
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001954static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001955{
1956 struct alc_spec *spec = codec->spec;
1957
1958 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1959 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1960 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1961 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001962}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001963
1964/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001965 * ALC888 Acer Aspire 4930G model
1966 */
1967
1968static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1969/* Front Mic: set to PIN_IN (empty by default) */
1970 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1971/* Unselect Front Mic by default in input mixer 3 */
1972 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001973/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001974 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1975/* Connect Internal HP to front */
1976 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1977 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1978 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1979/* Connect HP out to front */
1980 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1981 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1982 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1983 { }
1984};
1985
Hector Martin3b315d72009-06-02 10:54:19 +02001986/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001987 * ALC888 Acer Aspire 6530G model
1988 */
1989
1990static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
Tony Vroond1284182010-04-05 16:30:43 +01001991/* Route to built-in subwoofer as well as speakers */
1992 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1993 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1994 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1995 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001996/* Bias voltage on for external mic port */
1997 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001998/* Front Mic: set to PIN_IN (empty by default) */
1999 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2000/* Unselect Front Mic by default in input mixer 3 */
2001 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002002/* Enable unsolicited event for HP jack */
2003 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2004/* Enable speaker output */
2005 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2006 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tony Vroond1284182010-04-05 16:30:43 +01002007 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002008/* Enable headphone output */
2009 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2010 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2011 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Tony Vroond1284182010-04-05 16:30:43 +01002012 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002013 { }
2014};
2015
2016/*
Hector Martin018df412009-06-04 00:13:40 +02002017 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02002018 */
2019
Hector Martin018df412009-06-04 00:13:40 +02002020static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02002021/* Front Mic: set to PIN_IN (empty by default) */
2022 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2023/* Unselect Front Mic by default in input mixer 3 */
2024 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2025/* Enable unsolicited event for HP jack */
2026 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2027/* Connect Internal Front to Front */
2028 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2029 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2030 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2031/* Connect Internal Rear to Rear */
2032 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2033 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2034 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
2035/* Connect Internal CLFE to CLFE */
2036 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2037 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2038 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
2039/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02002040 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02002041 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2042 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2043/* Enable all DACs */
2044/* DAC DISABLE/MUTE 1? */
2045/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
2046 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
2047 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
2048/* DAC DISABLE/MUTE 2? */
2049/* some bit here disables the other DACs. Init=0x4900 */
2050 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
2051 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02002052/* DMIC fix
2053 * This laptop has a stereo digital microphone. The mics are only 1cm apart
2054 * which makes the stereo useless. However, either the mic or the ALC889
2055 * makes the signal become a difference/sum signal instead of standard
2056 * stereo, which is annoying. So instead we flip this bit which makes the
2057 * codec replicate the sum signal to both channels, turning it into a
2058 * normal mono mic.
2059 */
2060/* DMIC_CONTROL? Init value = 0x0001 */
2061 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
2062 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02002063 { }
2064};
2065
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002066static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002067 /* Front mic only available on one ADC */
2068 {
2069 .num_items = 4,
2070 .items = {
2071 { "Mic", 0x0 },
2072 { "Line", 0x2 },
2073 { "CD", 0x4 },
2074 { "Front Mic", 0xb },
2075 },
2076 },
2077 {
2078 .num_items = 3,
2079 .items = {
2080 { "Mic", 0x0 },
2081 { "Line", 0x2 },
2082 { "CD", 0x4 },
2083 },
2084 }
2085};
2086
Tony Vroond2fd4b02009-06-21 00:40:10 +01002087static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
2088 /* Interal mic only available on one ADC */
2089 {
Tony Vroon684a8842009-06-26 09:27:50 +01002090 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002091 .items = {
2092 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002093 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002094 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002095 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002096 { "Int Mic", 0xb },
2097 },
2098 },
2099 {
Tony Vroon684a8842009-06-26 09:27:50 +01002100 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002101 .items = {
2102 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002103 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002104 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002105 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002106 },
2107 }
2108};
2109
Hector Martin018df412009-06-04 00:13:40 +02002110static struct hda_input_mux alc889_capture_sources[3] = {
2111 /* Digital mic only available on first "ADC" */
2112 {
2113 .num_items = 5,
2114 .items = {
2115 { "Mic", 0x0 },
2116 { "Line", 0x2 },
2117 { "CD", 0x4 },
2118 { "Front Mic", 0xb },
2119 { "Input Mix", 0xa },
2120 },
2121 },
2122 {
2123 .num_items = 4,
2124 .items = {
2125 { "Mic", 0x0 },
2126 { "Line", 0x2 },
2127 { "CD", 0x4 },
2128 { "Input Mix", 0xa },
2129 },
2130 },
2131 {
2132 .num_items = 4,
2133 .items = {
2134 { "Mic", 0x0 },
2135 { "Line", 0x2 },
2136 { "CD", 0x4 },
2137 { "Input Mix", 0xa },
2138 },
2139 }
2140};
2141
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002142static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002143 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2144 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2145 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2146 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2147 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2148 HDA_OUTPUT),
2149 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2150 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2151 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2152 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2153 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2154 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2155 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2156 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2157 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2158 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2159 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
2160 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002161 { } /* end */
2162};
2163
Hector Martin556eea92009-12-20 22:51:23 +01002164static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
2165 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2166 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2167 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2168 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2169 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2170 HDA_OUTPUT),
2171 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2172 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2173 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2174 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2175 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2176 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2177 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
2178 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2179 { } /* end */
2180};
2181
2182
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002183static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002184{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002185 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002186
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002187 spec->autocfg.hp_pins[0] = 0x15;
2188 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01002189 spec->autocfg.speaker_pins[1] = 0x16;
2190 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002191}
2192
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002193static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02002194{
2195 struct alc_spec *spec = codec->spec;
2196
2197 spec->autocfg.hp_pins[0] = 0x15;
2198 spec->autocfg.speaker_pins[0] = 0x14;
2199 spec->autocfg.speaker_pins[1] = 0x16;
2200 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02002201}
2202
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002203static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02002204{
2205 struct alc_spec *spec = codec->spec;
2206
2207 spec->autocfg.hp_pins[0] = 0x15;
2208 spec->autocfg.speaker_pins[0] = 0x14;
2209 spec->autocfg.speaker_pins[1] = 0x16;
2210 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02002211}
2212
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002213/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002214 * ALC880 3-stack model
2215 *
2216 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002217 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2218 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07002219 */
2220
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002221static hda_nid_t alc880_dac_nids[4] = {
2222 /* front, rear, clfe, rear_surr */
2223 0x02, 0x05, 0x04, 0x03
2224};
2225
2226static hda_nid_t alc880_adc_nids[3] = {
2227 /* ADC0-2 */
2228 0x07, 0x08, 0x09,
2229};
2230
2231/* The datasheet says the node 0x07 is connected from inputs,
2232 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01002233 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07002234 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002235static hda_nid_t alc880_adc_nids_alt[2] = {
2236 /* ADC1-2 */
2237 0x08, 0x09,
2238};
2239
2240#define ALC880_DIGOUT_NID 0x06
2241#define ALC880_DIGIN_NID 0x0a
2242
2243static struct hda_input_mux alc880_capture_source = {
2244 .num_items = 4,
2245 .items = {
2246 { "Mic", 0x0 },
2247 { "Front Mic", 0x3 },
2248 { "Line", 0x2 },
2249 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002250 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002251};
2252
2253/* channel source setting (2/6 channel selection for 3-stack) */
2254/* 2ch mode */
2255static struct hda_verb alc880_threestack_ch2_init[] = {
2256 /* set line-in to input, mute it */
2257 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2258 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2259 /* set mic-in to input vref 80%, mute it */
2260 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2261 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002262 { } /* end */
2263};
2264
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002265/* 6ch mode */
2266static struct hda_verb alc880_threestack_ch6_init[] = {
2267 /* set line-in to output, unmute it */
2268 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2269 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2270 /* set mic-in to output, unmute it */
2271 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2272 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2273 { } /* end */
2274};
2275
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002276static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002277 { 2, alc880_threestack_ch2_init },
2278 { 6, alc880_threestack_ch6_init },
2279};
2280
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002281static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002282 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002283 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002284 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002285 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002286 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2287 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002288 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2289 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002290 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2291 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2292 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2293 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2294 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2295 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2296 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2297 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002298 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002299 {
2300 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2301 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002302 .info = alc_ch_mode_info,
2303 .get = alc_ch_mode_get,
2304 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002305 },
2306 { } /* end */
2307};
2308
2309/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002310static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2311 struct snd_ctl_elem_info *uinfo)
2312{
2313 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2314 struct alc_spec *spec = codec->spec;
2315 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002316
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002317 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002318 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2319 HDA_INPUT);
2320 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002321 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002322 return err;
2323}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002324
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002325static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2326 unsigned int size, unsigned int __user *tlv)
2327{
2328 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2329 struct alc_spec *spec = codec->spec;
2330 int err;
2331
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002332 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002333 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2334 HDA_INPUT);
2335 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002336 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002337 return err;
2338}
2339
2340typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2341 struct snd_ctl_elem_value *ucontrol);
2342
2343static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2344 struct snd_ctl_elem_value *ucontrol,
2345 getput_call_t func)
2346{
2347 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2348 struct alc_spec *spec = codec->spec;
2349 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2350 int err;
2351
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002352 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002353 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2354 3, 0, HDA_INPUT);
2355 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002356 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002357 return err;
2358}
2359
2360static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2361 struct snd_ctl_elem_value *ucontrol)
2362{
2363 return alc_cap_getput_caller(kcontrol, ucontrol,
2364 snd_hda_mixer_amp_volume_get);
2365}
2366
2367static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2368 struct snd_ctl_elem_value *ucontrol)
2369{
2370 return alc_cap_getput_caller(kcontrol, ucontrol,
2371 snd_hda_mixer_amp_volume_put);
2372}
2373
2374/* capture mixer elements */
2375#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2376
2377static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2378 struct snd_ctl_elem_value *ucontrol)
2379{
2380 return alc_cap_getput_caller(kcontrol, ucontrol,
2381 snd_hda_mixer_amp_switch_get);
2382}
2383
2384static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2385 struct snd_ctl_elem_value *ucontrol)
2386{
2387 return alc_cap_getput_caller(kcontrol, ucontrol,
2388 snd_hda_mixer_amp_switch_put);
2389}
2390
Takashi Iwaia23b6882009-03-23 15:21:36 +01002391#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002392 { \
2393 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2394 .name = "Capture Switch", \
2395 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2396 .count = num, \
2397 .info = alc_cap_sw_info, \
2398 .get = alc_cap_sw_get, \
2399 .put = alc_cap_sw_put, \
2400 }, \
2401 { \
2402 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2403 .name = "Capture Volume", \
2404 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2405 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2406 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2407 .count = num, \
2408 .info = alc_cap_vol_info, \
2409 .get = alc_cap_vol_get, \
2410 .put = alc_cap_vol_put, \
2411 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002412 }
2413
2414#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002415 { \
2416 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2417 /* .name = "Capture Source", */ \
2418 .name = "Input Source", \
2419 .count = num, \
2420 .info = alc_mux_enum_info, \
2421 .get = alc_mux_enum_get, \
2422 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002423 }
2424
2425#define DEFINE_CAPMIX(num) \
2426static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2427 _DEFINE_CAPMIX(num), \
2428 _DEFINE_CAPSRC(num), \
2429 { } /* end */ \
2430}
2431
2432#define DEFINE_CAPMIX_NOSRC(num) \
2433static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2434 _DEFINE_CAPMIX(num), \
2435 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002436}
2437
2438/* up to three ADCs */
2439DEFINE_CAPMIX(1);
2440DEFINE_CAPMIX(2);
2441DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002442DEFINE_CAPMIX_NOSRC(1);
2443DEFINE_CAPMIX_NOSRC(2);
2444DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002445
2446/*
2447 * ALC880 5-stack model
2448 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002449 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2450 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002451 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2452 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2453 */
2454
2455/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002456static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002457 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002458 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002459 { } /* end */
2460};
2461
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002462/* channel source setting (6/8 channel selection for 5-stack) */
2463/* 6ch mode */
2464static struct hda_verb alc880_fivestack_ch6_init[] = {
2465 /* set line-in to input, mute it */
2466 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2467 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002468 { } /* end */
2469};
2470
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002471/* 8ch mode */
2472static struct hda_verb alc880_fivestack_ch8_init[] = {
2473 /* set line-in to output, unmute it */
2474 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2475 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2476 { } /* end */
2477};
2478
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002479static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002480 { 6, alc880_fivestack_ch6_init },
2481 { 8, alc880_fivestack_ch8_init },
2482};
2483
2484
2485/*
2486 * ALC880 6-stack model
2487 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002488 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2489 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002490 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2491 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2492 */
2493
2494static hda_nid_t alc880_6st_dac_nids[4] = {
2495 /* front, rear, clfe, rear_surr */
2496 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002497};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002498
2499static struct hda_input_mux alc880_6stack_capture_source = {
2500 .num_items = 4,
2501 .items = {
2502 { "Mic", 0x0 },
2503 { "Front Mic", 0x1 },
2504 { "Line", 0x2 },
2505 { "CD", 0x4 },
2506 },
2507};
2508
2509/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002510static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002511 { 8, NULL },
2512};
2513
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002514static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002515 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002516 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002517 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002518 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002519 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2520 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002521 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2522 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002523 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002524 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002525 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2526 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2527 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2528 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2529 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2530 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2531 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2532 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002533 {
2534 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2535 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002536 .info = alc_ch_mode_info,
2537 .get = alc_ch_mode_get,
2538 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002539 },
2540 { } /* end */
2541};
2542
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002543
2544/*
2545 * ALC880 W810 model
2546 *
2547 * W810 has rear IO for:
2548 * Front (DAC 02)
2549 * Surround (DAC 03)
2550 * Center/LFE (DAC 04)
2551 * Digital out (06)
2552 *
2553 * The system also has a pair of internal speakers, and a headphone jack.
2554 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002555 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002556 * There is a variable resistor to control the speaker or headphone
2557 * volume. This is a hardware-only device without a software API.
2558 *
2559 * Plugging headphones in will disable the internal speakers. This is
2560 * implemented in hardware, not via the driver using jack sense. In
2561 * a similar fashion, plugging into the rear socket marked "front" will
2562 * disable both the speakers and headphones.
2563 *
2564 * For input, there's a microphone jack, and an "audio in" jack.
2565 * These may not do anything useful with this driver yet, because I
2566 * haven't setup any initialization verbs for these yet...
2567 */
2568
2569static hda_nid_t alc880_w810_dac_nids[3] = {
2570 /* front, rear/surround, clfe */
2571 0x02, 0x03, 0x04
2572};
2573
2574/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002575static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002576 { 6, NULL }
2577};
2578
2579/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002580static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002581 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002582 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002583 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002584 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002585 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2586 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002587 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2588 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002589 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2590 { } /* end */
2591};
2592
2593
2594/*
2595 * Z710V model
2596 *
2597 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002598 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2599 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002600 */
2601
2602static hda_nid_t alc880_z71v_dac_nids[1] = {
2603 0x02
2604};
2605#define ALC880_Z71V_HP_DAC 0x03
2606
2607/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002608static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002609 { 2, NULL }
2610};
2611
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002612static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002613 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002614 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002615 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002616 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002617 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2618 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2619 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2620 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2621 { } /* end */
2622};
2623
2624
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002625/*
2626 * ALC880 F1734 model
2627 *
2628 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2629 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2630 */
2631
2632static hda_nid_t alc880_f1734_dac_nids[1] = {
2633 0x03
2634};
2635#define ALC880_F1734_HP_DAC 0x02
2636
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002637static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002638 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002639 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002640 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2641 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002642 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2643 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002644 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2645 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002646 { } /* end */
2647};
2648
Takashi Iwai937b4162008-02-11 14:52:36 +01002649static struct hda_input_mux alc880_f1734_capture_source = {
2650 .num_items = 2,
2651 .items = {
2652 { "Mic", 0x1 },
2653 { "CD", 0x4 },
2654 },
2655};
2656
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002657
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002658/*
2659 * ALC880 ASUS model
2660 *
2661 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2662 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2663 * Mic = 0x18, Line = 0x1a
2664 */
2665
2666#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2667#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2668
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002669static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002670 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002671 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002672 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002673 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002674 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2675 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002676 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2677 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002678 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2679 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2680 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2681 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2682 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2683 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002684 {
2685 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2686 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002687 .info = alc_ch_mode_info,
2688 .get = alc_ch_mode_get,
2689 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002690 },
2691 { } /* end */
2692};
2693
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002694/*
2695 * ALC880 ASUS W1V model
2696 *
2697 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2698 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2699 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2700 */
2701
2702/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002703static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002704 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2705 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002706 { } /* end */
2707};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002708
Kailang Yangdf694da2005-12-05 19:42:22 +01002709/* TCL S700 */
2710static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2711 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2712 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2713 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2714 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2715 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2716 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2717 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2718 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2719 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002720 { } /* end */
2721};
2722
Kailang Yangccc656c2006-10-17 12:32:26 +02002723/* Uniwill */
2724static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002725 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2726 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2727 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2728 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002729 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2730 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2731 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2732 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2733 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2734 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2735 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2736 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2737 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2738 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2739 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2740 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002741 {
2742 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2743 .name = "Channel Mode",
2744 .info = alc_ch_mode_info,
2745 .get = alc_ch_mode_get,
2746 .put = alc_ch_mode_put,
2747 },
2748 { } /* end */
2749};
2750
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002751static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2752 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2753 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2754 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2755 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2756 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2757 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2758 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2759 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2760 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2761 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2762 { } /* end */
2763};
2764
Kailang Yangccc656c2006-10-17 12:32:26 +02002765static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002766 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2767 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2768 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2769 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002770 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2771 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2772 { } /* end */
2773};
2774
Linus Torvalds1da177e2005-04-16 15:20:36 -07002775/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002776 * virtual master controls
2777 */
2778
2779/*
2780 * slave controls for virtual master
2781 */
2782static const char *alc_slave_vols[] = {
2783 "Front Playback Volume",
2784 "Surround Playback Volume",
2785 "Center Playback Volume",
2786 "LFE Playback Volume",
2787 "Side Playback Volume",
2788 "Headphone Playback Volume",
2789 "Speaker Playback Volume",
2790 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002791 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002792 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002793 NULL,
2794};
2795
2796static const char *alc_slave_sws[] = {
2797 "Front Playback Switch",
2798 "Surround Playback Switch",
2799 "Center Playback Switch",
2800 "LFE Playback Switch",
2801 "Side Playback Switch",
2802 "Headphone Playback Switch",
2803 "Speaker Playback Switch",
2804 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002805 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002806 "Line-Out Playback Switch",
2807 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002808 NULL,
2809};
2810
2811/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002812 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002813 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002814
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002815#define NID_MAPPING (-1)
2816
2817#define SUBDEV_SPEAKER_ (0 << 6)
2818#define SUBDEV_HP_ (1 << 6)
2819#define SUBDEV_LINE_ (2 << 6)
2820#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2821#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2822#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2823
Takashi Iwai603c4012008-07-30 15:01:44 +02002824static void alc_free_kctls(struct hda_codec *codec);
2825
Takashi Iwai67d634c2009-11-16 15:35:59 +01002826#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002827/* additional beep mixers; the actual parameters are overwritten at build */
2828static struct snd_kcontrol_new alc_beep_mixer[] = {
2829 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002830 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002831 { } /* end */
2832};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002833#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002834
Linus Torvalds1da177e2005-04-16 15:20:36 -07002835static int alc_build_controls(struct hda_codec *codec)
2836{
2837 struct alc_spec *spec = codec->spec;
Takashi Iwai2f44f842010-06-22 11:12:32 +02002838 struct snd_kcontrol *kctl = NULL;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002839 struct snd_kcontrol_new *knew;
2840 int i, j, err;
2841 unsigned int u;
2842 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002843
2844 for (i = 0; i < spec->num_mixers; i++) {
2845 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2846 if (err < 0)
2847 return err;
2848 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002849 if (spec->cap_mixer) {
2850 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2851 if (err < 0)
2852 return err;
2853 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002854 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002855 err = snd_hda_create_spdif_out_ctls(codec,
2856 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002857 if (err < 0)
2858 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002859 if (!spec->no_analog) {
2860 err = snd_hda_create_spdif_share_sw(codec,
2861 &spec->multiout);
2862 if (err < 0)
2863 return err;
2864 spec->multiout.share_spdif = 1;
2865 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002866 }
2867 if (spec->dig_in_nid) {
2868 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2869 if (err < 0)
2870 return err;
2871 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002872
Takashi Iwai67d634c2009-11-16 15:35:59 +01002873#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002874 /* create beep controls if needed */
2875 if (spec->beep_amp) {
2876 struct snd_kcontrol_new *knew;
2877 for (knew = alc_beep_mixer; knew->name; knew++) {
2878 struct snd_kcontrol *kctl;
2879 kctl = snd_ctl_new1(knew, codec);
2880 if (!kctl)
2881 return -ENOMEM;
2882 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002883 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002884 if (err < 0)
2885 return err;
2886 }
2887 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002888#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002889
Takashi Iwai2134ea42008-01-10 16:53:55 +01002890 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002891 if (!spec->no_analog &&
2892 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002893 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002894 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002895 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002896 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002897 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002898 if (err < 0)
2899 return err;
2900 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002901 if (!spec->no_analog &&
2902 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002903 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2904 NULL, alc_slave_sws);
2905 if (err < 0)
2906 return err;
2907 }
2908
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002909 /* assign Capture Source enums to NID */
Takashi Iwaifbe618f2010-06-11 11:24:58 +02002910 if (spec->capsrc_nids || spec->adc_nids) {
2911 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2912 if (!kctl)
2913 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2914 for (i = 0; kctl && i < kctl->count; i++) {
2915 hda_nid_t *nids = spec->capsrc_nids;
2916 if (!nids)
2917 nids = spec->adc_nids;
2918 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
2919 if (err < 0)
2920 return err;
2921 }
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002922 }
2923 if (spec->cap_mixer) {
2924 const char *kname = kctl ? kctl->id.name : NULL;
2925 for (knew = spec->cap_mixer; knew->name; knew++) {
2926 if (kname && strcmp(knew->name, kname) == 0)
2927 continue;
2928 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2929 for (i = 0; kctl && i < kctl->count; i++) {
2930 err = snd_hda_add_nid(codec, kctl, i,
2931 spec->adc_nids[i]);
2932 if (err < 0)
2933 return err;
2934 }
2935 }
2936 }
2937
2938 /* other nid->control mapping */
2939 for (i = 0; i < spec->num_mixers; i++) {
2940 for (knew = spec->mixers[i]; knew->name; knew++) {
2941 if (knew->iface != NID_MAPPING)
2942 continue;
2943 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2944 if (kctl == NULL)
2945 continue;
2946 u = knew->subdevice;
2947 for (j = 0; j < 4; j++, u >>= 8) {
2948 nid = u & 0x3f;
2949 if (nid == 0)
2950 continue;
2951 switch (u & 0xc0) {
2952 case SUBDEV_SPEAKER_:
2953 nid = spec->autocfg.speaker_pins[nid];
2954 break;
2955 case SUBDEV_LINE_:
2956 nid = spec->autocfg.line_out_pins[nid];
2957 break;
2958 case SUBDEV_HP_:
2959 nid = spec->autocfg.hp_pins[nid];
2960 break;
2961 default:
2962 continue;
2963 }
2964 err = snd_hda_add_nid(codec, kctl, 0, nid);
2965 if (err < 0)
2966 return err;
2967 }
2968 u = knew->private_value;
2969 for (j = 0; j < 4; j++, u >>= 8) {
2970 nid = u & 0xff;
2971 if (nid == 0)
2972 continue;
2973 err = snd_hda_add_nid(codec, kctl, 0, nid);
2974 if (err < 0)
2975 return err;
2976 }
2977 }
2978 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01002979
2980 alc_free_kctls(codec); /* no longer needed */
2981
Linus Torvalds1da177e2005-04-16 15:20:36 -07002982 return 0;
2983}
2984
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002985
Linus Torvalds1da177e2005-04-16 15:20:36 -07002986/*
2987 * initialize the codec volumes, etc
2988 */
2989
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002990/*
2991 * generic initialization of ADC, input mixers and output mixers
2992 */
2993static struct hda_verb alc880_volume_init_verbs[] = {
2994 /*
2995 * Unmute ADC0-2 and set the default input to mic-in
2996 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002997 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002998 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002999 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003000 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003001 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003002 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003003
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003004 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3005 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003006 * Note: PASD motherboards uses the Line In 2 as the input for front
3007 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003008 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003009 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003010 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3011 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3012 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3013 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3014 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3015 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3016 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003017
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003018 /*
3019 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003020 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003021 /* set vol=0 to output mixers */
3022 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3023 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3024 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3025 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3026 /* set up input amps for analog loopback */
3027 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003028 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3029 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003030 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3031 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003032 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3033 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003034 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3035 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003036
3037 { }
3038};
3039
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003040/*
3041 * 3-stack pin configuration:
3042 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
3043 */
3044static struct hda_verb alc880_pin_3stack_init_verbs[] = {
3045 /*
3046 * preset connection lists of input pins
3047 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3048 */
3049 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3050 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3051 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3052
3053 /*
3054 * Set pin mode and muting
3055 */
3056 /* set front pin widgets 0x14 for output */
3057 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3058 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3059 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3060 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3061 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3062 /* Mic2 (as headphone out) for HP output */
3063 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3064 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3065 /* Line In pin widget for input */
3066 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3067 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3068 /* Line2 (as front mic) pin widget for input and vref at 80% */
3069 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3070 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3071 /* CD pin widget for input */
3072 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3073
3074 { }
3075};
3076
3077/*
3078 * 5-stack pin configuration:
3079 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
3080 * line-in/side = 0x1a, f-mic = 0x1b
3081 */
3082static struct hda_verb alc880_pin_5stack_init_verbs[] = {
3083 /*
3084 * preset connection lists of input pins
3085 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3086 */
3087 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3088 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
3089
3090 /*
3091 * Set pin mode and muting
3092 */
3093 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02003094 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3095 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3096 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3097 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003098 /* unmute pins for output (no gain on this amp) */
3099 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3100 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3101 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3102 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3103
Linus Torvalds1da177e2005-04-16 15:20:36 -07003104 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003105 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003106 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3107 /* Mic2 (as headphone out) for HP output */
3108 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003109 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003110 /* Line In pin widget for input */
3111 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3112 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3113 /* Line2 (as front mic) pin widget for input and vref at 80% */
3114 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3115 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3116 /* CD pin widget for input */
3117 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003118
3119 { }
3120};
3121
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003122/*
3123 * W810 pin configuration:
3124 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
3125 */
3126static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003127 /* hphone/speaker input selector: front DAC */
3128 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
3129
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003130 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3131 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3132 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3133 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3134 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3135 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3136
3137 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003138 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003139
Linus Torvalds1da177e2005-04-16 15:20:36 -07003140 { }
3141};
3142
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003143/*
3144 * Z71V pin configuration:
3145 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
3146 */
3147static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003148 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003149 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02003150 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003151 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003152
Takashi Iwai16ded522005-06-10 19:58:24 +02003153 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003154 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003155 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003156 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003157
3158 { }
3159};
3160
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003161/*
3162 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003163 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
3164 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003165 */
3166static struct hda_verb alc880_pin_6stack_init_verbs[] = {
3167 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3168
Takashi Iwai16ded522005-06-10 19:58:24 +02003169 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003170 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003171 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003172 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003173 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003174 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003175 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003176 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3177
Takashi Iwai16ded522005-06-10 19:58:24 +02003178 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003179 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003180 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003181 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003182 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003183 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003184 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02003185 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003186 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003187
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003188 { }
3189};
Takashi Iwai16ded522005-06-10 19:58:24 +02003190
Kailang Yangccc656c2006-10-17 12:32:26 +02003191/*
3192 * Uniwill pin configuration:
3193 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3194 * line = 0x1a
3195 */
3196static struct hda_verb alc880_uniwill_init_verbs[] = {
3197 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3198
3199 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3200 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3201 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3202 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3203 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3204 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3205 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3206 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3207 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3208 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3209 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3210 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3211 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3212 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3213
3214 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3215 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3216 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3217 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3218 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3219 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3220 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3221 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3222 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3223
3224 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3225 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3226
3227 { }
3228};
3229
3230/*
3231* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02003232* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02003233 */
3234static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3235 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3236
3237 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3238 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3239 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3240 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3241 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3242 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3243 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3244 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3245 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3246 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3247 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3248 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3249
3250 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3251 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3252 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3253 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3254 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3255 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3256
3257 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3258 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3259
3260 { }
3261};
3262
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003263static struct hda_verb alc880_beep_init_verbs[] = {
3264 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3265 { }
3266};
3267
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003268/* auto-toggle front mic */
3269static void alc880_uniwill_mic_automute(struct hda_codec *codec)
3270{
3271 unsigned int present;
3272 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02003273
Wu Fengguang864f92b2009-11-18 12:38:02 +08003274 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003275 bits = present ? HDA_AMP_MUTE : 0;
3276 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003277}
3278
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003279static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003280{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003281 struct alc_spec *spec = codec->spec;
3282
3283 spec->autocfg.hp_pins[0] = 0x14;
3284 spec->autocfg.speaker_pins[0] = 0x15;
3285 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003286}
3287
3288static void alc880_uniwill_init_hook(struct hda_codec *codec)
3289{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003290 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003291 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02003292}
3293
3294static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3295 unsigned int res)
3296{
3297 /* Looks like the unsol event is incompatible with the standard
3298 * definition. 4bit tag is placed at 28 bit!
3299 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003300 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003301 case ALC880_MIC_EVENT:
3302 alc880_uniwill_mic_automute(codec);
3303 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003304 default:
3305 alc_automute_amp_unsol_event(codec, res);
3306 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003307 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003308}
3309
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003310static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003311{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003312 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003313
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003314 spec->autocfg.hp_pins[0] = 0x14;
3315 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02003316}
3317
3318static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3319{
3320 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003321
Kailang Yangccc656c2006-10-17 12:32:26 +02003322 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003323 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3324 present &= HDA_AMP_VOLMASK;
3325 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3326 HDA_AMP_VOLMASK, present);
3327 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3328 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003329}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003330
Kailang Yangccc656c2006-10-17 12:32:26 +02003331static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3332 unsigned int res)
3333{
3334 /* Looks like the unsol event is incompatible with the standard
3335 * definition. 4bit tag is placed at 28 bit!
3336 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003337 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003338 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003339 else
3340 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003341}
3342
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003343/*
3344 * F1734 pin configuration:
3345 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3346 */
3347static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003348 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003349 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3350 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3351 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3352 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3353
3354 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3355 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3356 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3357 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3358
3359 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3360 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003361 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003362 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3363 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3364 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3365 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3366 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3367 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003368
Takashi Iwai937b4162008-02-11 14:52:36 +01003369 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3370 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3371
Takashi Iwai16ded522005-06-10 19:58:24 +02003372 { }
3373};
3374
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003375/*
3376 * ASUS pin configuration:
3377 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3378 */
3379static struct hda_verb alc880_pin_asus_init_verbs[] = {
3380 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3381 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3382 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3383 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3384
3385 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3386 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3387 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3388 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3389 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3390 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3391 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3392 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3393
3394 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3395 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3396 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3397 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3398 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3399 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3400 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3401 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3402 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003403
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003404 { }
3405};
3406
3407/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003408#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3409#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003410#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003411
Kailang Yangdf694da2005-12-05 19:42:22 +01003412/* Clevo m520g init */
3413static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3414 /* headphone output */
3415 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3416 /* line-out */
3417 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3418 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3419 /* Line-in */
3420 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3421 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3422 /* CD */
3423 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3424 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3425 /* Mic1 (rear panel) */
3426 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3427 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3428 /* Mic2 (front panel) */
3429 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3430 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3431 /* headphone */
3432 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3433 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3434 /* change to EAPD mode */
3435 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3436 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3437
3438 { }
3439};
3440
3441static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003442 /* change to EAPD mode */
3443 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3444 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3445
Kailang Yangdf694da2005-12-05 19:42:22 +01003446 /* Headphone output */
3447 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3448 /* Front output*/
3449 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3450 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3451
3452 /* Line In pin widget for input */
3453 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3454 /* CD pin widget for input */
3455 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3456 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3457 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3458
3459 /* change to EAPD mode */
3460 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3461 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3462
3463 { }
3464};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003465
3466/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003467 * LG m1 express dual
3468 *
3469 * Pin assignment:
3470 * Rear Line-In/Out (blue): 0x14
3471 * Build-in Mic-In: 0x15
3472 * Speaker-out: 0x17
3473 * HP-Out (green): 0x1b
3474 * Mic-In/Out (red): 0x19
3475 * SPDIF-Out: 0x1e
3476 */
3477
3478/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3479static hda_nid_t alc880_lg_dac_nids[3] = {
3480 0x05, 0x02, 0x03
3481};
3482
3483/* seems analog CD is not working */
3484static struct hda_input_mux alc880_lg_capture_source = {
3485 .num_items = 3,
3486 .items = {
3487 { "Mic", 0x1 },
3488 { "Line", 0x5 },
3489 { "Internal Mic", 0x6 },
3490 },
3491};
3492
3493/* 2,4,6 channel modes */
3494static struct hda_verb alc880_lg_ch2_init[] = {
3495 /* set line-in and mic-in to input */
3496 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3497 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3498 { }
3499};
3500
3501static struct hda_verb alc880_lg_ch4_init[] = {
3502 /* set line-in to out and mic-in to input */
3503 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3504 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3505 { }
3506};
3507
3508static struct hda_verb alc880_lg_ch6_init[] = {
3509 /* set line-in and mic-in to output */
3510 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3511 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3512 { }
3513};
3514
3515static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3516 { 2, alc880_lg_ch2_init },
3517 { 4, alc880_lg_ch4_init },
3518 { 6, alc880_lg_ch6_init },
3519};
3520
3521static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003522 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3523 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003524 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3525 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3526 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3527 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3528 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3529 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3530 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3531 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3532 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3533 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3534 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3535 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3536 {
3537 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3538 .name = "Channel Mode",
3539 .info = alc_ch_mode_info,
3540 .get = alc_ch_mode_get,
3541 .put = alc_ch_mode_put,
3542 },
3543 { } /* end */
3544};
3545
3546static struct hda_verb alc880_lg_init_verbs[] = {
3547 /* set capture source to mic-in */
3548 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3549 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3550 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3551 /* mute all amp mixer inputs */
3552 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003553 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3554 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003555 /* line-in to input */
3556 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3557 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3558 /* built-in mic */
3559 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3560 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3561 /* speaker-out */
3562 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3563 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3564 /* mic-in to input */
3565 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3566 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3567 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3568 /* HP-out */
3569 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3570 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3571 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3572 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003573 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003574 { }
3575};
3576
3577/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003578static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003579{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003580 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003581
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003582 spec->autocfg.hp_pins[0] = 0x1b;
3583 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003584}
3585
3586/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003587 * LG LW20
3588 *
3589 * Pin assignment:
3590 * Speaker-out: 0x14
3591 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003592 * Built-in Mic-In: 0x19
3593 * Line-In: 0x1b
3594 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003595 * SPDIF-Out: 0x1e
3596 */
3597
Takashi Iwaid6815182006-03-23 16:06:23 +01003598static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003599 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003600 .items = {
3601 { "Mic", 0x0 },
3602 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003603 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003604 },
3605};
3606
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003607#define alc880_lg_lw_modes alc880_threestack_modes
3608
Takashi Iwaid6815182006-03-23 16:06:23 +01003609static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003610 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3611 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3612 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3613 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3614 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3615 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3616 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3617 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3618 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3619 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003620 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3621 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3622 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3623 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003624 {
3625 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3626 .name = "Channel Mode",
3627 .info = alc_ch_mode_info,
3628 .get = alc_ch_mode_get,
3629 .put = alc_ch_mode_put,
3630 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003631 { } /* end */
3632};
3633
3634static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003635 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3636 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3637 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3638
Takashi Iwaid6815182006-03-23 16:06:23 +01003639 /* set capture source to mic-in */
3640 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3641 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3642 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003643 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003644 /* speaker-out */
3645 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3646 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3647 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003648 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3649 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3650 /* mic-in to input */
3651 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3652 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3653 /* built-in mic */
3654 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3655 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3656 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003657 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003658 { }
3659};
3660
3661/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003662static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003663{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003664 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003665
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003666 spec->autocfg.hp_pins[0] = 0x1b;
3667 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003668}
3669
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003670static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3671 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3672 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3673 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3674 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3675 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3676 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3677 { } /* end */
3678};
3679
3680static struct hda_input_mux alc880_medion_rim_capture_source = {
3681 .num_items = 2,
3682 .items = {
3683 { "Mic", 0x0 },
3684 { "Internal Mic", 0x1 },
3685 },
3686};
3687
3688static struct hda_verb alc880_medion_rim_init_verbs[] = {
3689 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3690
3691 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3692 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3693
3694 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3695 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3696 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3697 /* Mic2 (as headphone out) for HP output */
3698 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3699 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3700 /* Internal Speaker */
3701 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3702 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3703
3704 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3705 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3706
3707 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3708 { }
3709};
3710
3711/* toggle speaker-output according to the hp-jack state */
3712static void alc880_medion_rim_automute(struct hda_codec *codec)
3713{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003714 struct alc_spec *spec = codec->spec;
3715 alc_automute_amp(codec);
3716 /* toggle EAPD */
3717 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003718 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3719 else
3720 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3721}
3722
3723static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3724 unsigned int res)
3725{
3726 /* Looks like the unsol event is incompatible with the standard
3727 * definition. 4bit tag is placed at 28 bit!
3728 */
3729 if ((res >> 28) == ALC880_HP_EVENT)
3730 alc880_medion_rim_automute(codec);
3731}
3732
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003733static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003734{
3735 struct alc_spec *spec = codec->spec;
3736
3737 spec->autocfg.hp_pins[0] = 0x14;
3738 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003739}
3740
Takashi Iwaicb53c622007-08-10 17:21:45 +02003741#ifdef CONFIG_SND_HDA_POWER_SAVE
3742static struct hda_amp_list alc880_loopbacks[] = {
3743 { 0x0b, HDA_INPUT, 0 },
3744 { 0x0b, HDA_INPUT, 1 },
3745 { 0x0b, HDA_INPUT, 2 },
3746 { 0x0b, HDA_INPUT, 3 },
3747 { 0x0b, HDA_INPUT, 4 },
3748 { } /* end */
3749};
3750
3751static struct hda_amp_list alc880_lg_loopbacks[] = {
3752 { 0x0b, HDA_INPUT, 1 },
3753 { 0x0b, HDA_INPUT, 6 },
3754 { 0x0b, HDA_INPUT, 7 },
3755 { } /* end */
3756};
3757#endif
3758
Takashi Iwaid6815182006-03-23 16:06:23 +01003759/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003760 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003761 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003762
Linus Torvalds1da177e2005-04-16 15:20:36 -07003763static int alc_init(struct hda_codec *codec)
3764{
3765 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003766 unsigned int i;
3767
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003768 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003769 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003770
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003771 for (i = 0; i < spec->num_init_verbs; i++)
3772 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003773
3774 if (spec->init_hook)
3775 spec->init_hook(codec);
3776
Takashi Iwai9e5341b2010-09-21 09:57:06 +02003777 hda_call_check_power_status(codec, 0x01);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003778 return 0;
3779}
3780
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003781static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3782{
3783 struct alc_spec *spec = codec->spec;
3784
3785 if (spec->unsol_event)
3786 spec->unsol_event(codec, res);
3787}
3788
Takashi Iwaicb53c622007-08-10 17:21:45 +02003789#ifdef CONFIG_SND_HDA_POWER_SAVE
3790static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3791{
3792 struct alc_spec *spec = codec->spec;
3793 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3794}
3795#endif
3796
Linus Torvalds1da177e2005-04-16 15:20:36 -07003797/*
3798 * Analog playback callbacks
3799 */
3800static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3801 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003802 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003803{
3804 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003805 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3806 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003807}
3808
3809static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3810 struct hda_codec *codec,
3811 unsigned int stream_tag,
3812 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003813 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003814{
3815 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003816 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3817 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003818}
3819
3820static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3821 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003822 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003823{
3824 struct alc_spec *spec = codec->spec;
3825 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3826}
3827
3828/*
3829 * Digital out
3830 */
3831static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3832 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003833 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003834{
3835 struct alc_spec *spec = codec->spec;
3836 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3837}
3838
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003839static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3840 struct hda_codec *codec,
3841 unsigned int stream_tag,
3842 unsigned int format,
3843 struct snd_pcm_substream *substream)
3844{
3845 struct alc_spec *spec = codec->spec;
3846 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3847 stream_tag, format, substream);
3848}
3849
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003850static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3851 struct hda_codec *codec,
3852 struct snd_pcm_substream *substream)
3853{
3854 struct alc_spec *spec = codec->spec;
3855 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3856}
3857
Linus Torvalds1da177e2005-04-16 15:20:36 -07003858static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3859 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003860 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003861{
3862 struct alc_spec *spec = codec->spec;
3863 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3864}
3865
3866/*
3867 * Analog capture
3868 */
Takashi Iwai63300792008-01-24 15:31:36 +01003869static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003870 struct hda_codec *codec,
3871 unsigned int stream_tag,
3872 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003873 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003874{
3875 struct alc_spec *spec = codec->spec;
3876
Takashi Iwai63300792008-01-24 15:31:36 +01003877 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003878 stream_tag, 0, format);
3879 return 0;
3880}
3881
Takashi Iwai63300792008-01-24 15:31:36 +01003882static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003883 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003884 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003885{
3886 struct alc_spec *spec = codec->spec;
3887
Takashi Iwai888afa12008-03-18 09:57:50 +01003888 snd_hda_codec_cleanup_stream(codec,
3889 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003890 return 0;
3891}
3892
Takashi Iwai840b64c2010-07-13 22:49:01 +02003893/* analog capture with dynamic dual-adc changes */
3894static int dualmic_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3895 struct hda_codec *codec,
3896 unsigned int stream_tag,
3897 unsigned int format,
3898 struct snd_pcm_substream *substream)
3899{
3900 struct alc_spec *spec = codec->spec;
3901 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
3902 spec->cur_adc_stream_tag = stream_tag;
3903 spec->cur_adc_format = format;
3904 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
3905 return 0;
3906}
3907
3908static int dualmic_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3909 struct hda_codec *codec,
3910 struct snd_pcm_substream *substream)
3911{
3912 struct alc_spec *spec = codec->spec;
3913 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
3914 spec->cur_adc = 0;
3915 return 0;
3916}
3917
3918static struct hda_pcm_stream dualmic_pcm_analog_capture = {
3919 .substreams = 1,
3920 .channels_min = 2,
3921 .channels_max = 2,
3922 .nid = 0, /* fill later */
3923 .ops = {
3924 .prepare = dualmic_capture_pcm_prepare,
3925 .cleanup = dualmic_capture_pcm_cleanup
3926 },
3927};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003928
3929/*
3930 */
3931static struct hda_pcm_stream alc880_pcm_analog_playback = {
3932 .substreams = 1,
3933 .channels_min = 2,
3934 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003935 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003936 .ops = {
3937 .open = alc880_playback_pcm_open,
3938 .prepare = alc880_playback_pcm_prepare,
3939 .cleanup = alc880_playback_pcm_cleanup
3940 },
3941};
3942
3943static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003944 .substreams = 1,
3945 .channels_min = 2,
3946 .channels_max = 2,
3947 /* NID is set in alc_build_pcms */
3948};
3949
3950static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3951 .substreams = 1,
3952 .channels_min = 2,
3953 .channels_max = 2,
3954 /* NID is set in alc_build_pcms */
3955};
3956
3957static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3958 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003959 .channels_min = 2,
3960 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003961 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003962 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003963 .prepare = alc880_alt_capture_pcm_prepare,
3964 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003965 },
3966};
3967
3968static struct hda_pcm_stream alc880_pcm_digital_playback = {
3969 .substreams = 1,
3970 .channels_min = 2,
3971 .channels_max = 2,
3972 /* NID is set in alc_build_pcms */
3973 .ops = {
3974 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003975 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003976 .prepare = alc880_dig_playback_pcm_prepare,
3977 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003978 },
3979};
3980
3981static struct hda_pcm_stream alc880_pcm_digital_capture = {
3982 .substreams = 1,
3983 .channels_min = 2,
3984 .channels_max = 2,
3985 /* NID is set in alc_build_pcms */
3986};
3987
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003988/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003989static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003990 .substreams = 0,
3991 .channels_min = 0,
3992 .channels_max = 0,
3993};
3994
Linus Torvalds1da177e2005-04-16 15:20:36 -07003995static int alc_build_pcms(struct hda_codec *codec)
3996{
3997 struct alc_spec *spec = codec->spec;
3998 struct hda_pcm *info = spec->pcm_rec;
3999 int i;
4000
4001 codec->num_pcms = 1;
4002 codec->pcm_info = info;
4003
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004004 if (spec->no_analog)
4005 goto skip_analog;
4006
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004007 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
4008 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004009 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01004010
Takashi Iwai4a471b72005-12-07 13:56:29 +01004011 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004012 if (snd_BUG_ON(!spec->multiout.dac_nids))
4013 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004014 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
4015 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
4016 }
4017 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004018 if (snd_BUG_ON(!spec->adc_nids))
4019 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004020 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
4021 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
4022 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004023
Takashi Iwai4a471b72005-12-07 13:56:29 +01004024 if (spec->channel_mode) {
4025 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
4026 for (i = 0; i < spec->num_channel_mode; i++) {
4027 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
4028 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
4029 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004030 }
4031 }
4032
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004033 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02004034 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004035 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004036 snprintf(spec->stream_name_digital,
4037 sizeof(spec->stream_name_digital),
4038 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02004039 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08004040 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004041 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004042 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01004043 if (spec->dig_out_type)
4044 info->pcm_type = spec->dig_out_type;
4045 else
4046 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004047 if (spec->multiout.dig_out_nid &&
4048 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004049 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
4050 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
4051 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004052 if (spec->dig_in_nid &&
4053 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004054 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
4055 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
4056 }
Takashi Iwai963f8032008-08-11 10:04:40 +02004057 /* FIXME: do we need this for all Realtek codec models? */
4058 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004059 }
4060
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004061 if (spec->no_analog)
4062 return 0;
4063
Takashi Iwaie08a0072006-09-07 17:52:14 +02004064 /* If the use of more than one ADC is requested for the current
4065 * model, configure a second analog capture-only PCM.
4066 */
4067 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01004068 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
4069 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02004070 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004071 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004072 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01004073 if (spec->alt_dac_nid) {
4074 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4075 *spec->stream_analog_alt_playback;
4076 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
4077 spec->alt_dac_nid;
4078 } else {
4079 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4080 alc_pcm_null_stream;
4081 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
4082 }
4083 if (spec->num_adc_nids > 1) {
4084 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4085 *spec->stream_analog_alt_capture;
4086 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
4087 spec->adc_nids[1];
4088 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
4089 spec->num_adc_nids - 1;
4090 } else {
4091 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4092 alc_pcm_null_stream;
4093 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004094 }
4095 }
4096
Linus Torvalds1da177e2005-04-16 15:20:36 -07004097 return 0;
4098}
4099
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004100static inline void alc_shutup(struct hda_codec *codec)
4101{
4102 snd_hda_shutup_pins(codec);
4103}
4104
Takashi Iwai603c4012008-07-30 15:01:44 +02004105static void alc_free_kctls(struct hda_codec *codec)
4106{
4107 struct alc_spec *spec = codec->spec;
4108
4109 if (spec->kctls.list) {
4110 struct snd_kcontrol_new *kctl = spec->kctls.list;
4111 int i;
4112 for (i = 0; i < spec->kctls.used; i++)
4113 kfree(kctl[i].name);
4114 }
4115 snd_array_free(&spec->kctls);
4116}
4117
Linus Torvalds1da177e2005-04-16 15:20:36 -07004118static void alc_free(struct hda_codec *codec)
4119{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004120 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004121
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004122 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004123 return;
4124
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004125 alc_shutup(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02004126 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004127 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004128 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004129}
4130
Hector Martinf5de24b2009-12-20 22:51:31 +01004131#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05004132static void alc_power_eapd(struct hda_codec *codec)
4133{
4134 /* We currently only handle front, HP */
4135 switch (codec->vendor_id) {
4136 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004137 set_eapd(codec, 0x0f, 0);
4138 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004139 break;
4140 case 0x10ec0262:
4141 case 0x10ec0267:
4142 case 0x10ec0268:
4143 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004144 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05004145 case 0x10ec0272:
4146 case 0x10ec0660:
4147 case 0x10ec0662:
4148 case 0x10ec0663:
4149 case 0x10ec0862:
4150 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004151 set_eapd(codec, 0x14, 0);
4152 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004153 break;
4154 }
4155}
4156
Hector Martinf5de24b2009-12-20 22:51:31 +01004157static int alc_suspend(struct hda_codec *codec, pm_message_t state)
4158{
4159 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004160 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004161 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05004162 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004163 return 0;
4164}
4165#endif
4166
Takashi Iwaie044c392008-10-27 16:56:24 +01004167#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01004168static int alc_resume(struct hda_codec *codec)
4169{
Takashi Iwaie044c392008-10-27 16:56:24 +01004170 codec->patch_ops.init(codec);
4171 snd_hda_codec_resume_amp(codec);
4172 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +02004173 hda_call_check_power_status(codec, 0x01);
Takashi Iwaie044c392008-10-27 16:56:24 +01004174 return 0;
4175}
Takashi Iwaie044c392008-10-27 16:56:24 +01004176#endif
4177
Linus Torvalds1da177e2005-04-16 15:20:36 -07004178/*
4179 */
4180static struct hda_codec_ops alc_patch_ops = {
4181 .build_controls = alc_build_controls,
4182 .build_pcms = alc_build_pcms,
4183 .init = alc_init,
4184 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004185 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01004186#ifdef SND_HDA_NEEDS_RESUME
4187 .resume = alc_resume,
4188#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02004189#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01004190 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004191 .check_power_status = alc_check_power_status,
4192#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05004193 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004194};
4195
Kailang Yangc027ddc2010-03-19 11:33:06 +01004196/* replace the codec chip_name with the given string */
4197static int alc_codec_rename(struct hda_codec *codec, const char *name)
4198{
4199 kfree(codec->chip_name);
4200 codec->chip_name = kstrdup(name, GFP_KERNEL);
4201 if (!codec->chip_name) {
4202 alc_free(codec);
4203 return -ENOMEM;
4204 }
4205 return 0;
4206}
4207
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004208/*
4209 * Test configuration for debugging
4210 *
4211 * Almost all inputs/outputs are enabled. I/O pins can be configured via
4212 * enum controls.
4213 */
4214#ifdef CONFIG_SND_DEBUG
4215static hda_nid_t alc880_test_dac_nids[4] = {
4216 0x02, 0x03, 0x04, 0x05
4217};
4218
4219static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004220 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004221 .items = {
4222 { "In-1", 0x0 },
4223 { "In-2", 0x1 },
4224 { "In-3", 0x2 },
4225 { "In-4", 0x3 },
4226 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004227 { "Front", 0x5 },
4228 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004229 },
4230};
4231
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004232static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004233 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004234 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004235 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004236 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004237};
4238
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004239static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
4240 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004241{
4242 static char *texts[] = {
4243 "N/A", "Line Out", "HP Out",
4244 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
4245 };
4246 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4247 uinfo->count = 1;
4248 uinfo->value.enumerated.items = 8;
4249 if (uinfo->value.enumerated.item >= 8)
4250 uinfo->value.enumerated.item = 7;
4251 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4252 return 0;
4253}
4254
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004255static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
4256 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004257{
4258 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4259 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4260 unsigned int pin_ctl, item = 0;
4261
4262 pin_ctl = snd_hda_codec_read(codec, nid, 0,
4263 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4264 if (pin_ctl & AC_PINCTL_OUT_EN) {
4265 if (pin_ctl & AC_PINCTL_HP_EN)
4266 item = 2;
4267 else
4268 item = 1;
4269 } else if (pin_ctl & AC_PINCTL_IN_EN) {
4270 switch (pin_ctl & AC_PINCTL_VREFEN) {
4271 case AC_PINCTL_VREF_HIZ: item = 3; break;
4272 case AC_PINCTL_VREF_50: item = 4; break;
4273 case AC_PINCTL_VREF_GRD: item = 5; break;
4274 case AC_PINCTL_VREF_80: item = 6; break;
4275 case AC_PINCTL_VREF_100: item = 7; break;
4276 }
4277 }
4278 ucontrol->value.enumerated.item[0] = item;
4279 return 0;
4280}
4281
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004282static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
4283 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004284{
4285 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4286 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4287 static unsigned int ctls[] = {
4288 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
4289 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
4290 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
4291 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
4292 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
4293 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
4294 };
4295 unsigned int old_ctl, new_ctl;
4296
4297 old_ctl = snd_hda_codec_read(codec, nid, 0,
4298 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4299 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
4300 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004301 int val;
4302 snd_hda_codec_write_cache(codec, nid, 0,
4303 AC_VERB_SET_PIN_WIDGET_CONTROL,
4304 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02004305 val = ucontrol->value.enumerated.item[0] >= 3 ?
4306 HDA_AMP_MUTE : 0;
4307 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
4308 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004309 return 1;
4310 }
4311 return 0;
4312}
4313
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004314static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
4315 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004316{
4317 static char *texts[] = {
4318 "Front", "Surround", "CLFE", "Side"
4319 };
4320 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4321 uinfo->count = 1;
4322 uinfo->value.enumerated.items = 4;
4323 if (uinfo->value.enumerated.item >= 4)
4324 uinfo->value.enumerated.item = 3;
4325 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4326 return 0;
4327}
4328
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004329static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
4330 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004331{
4332 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4333 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4334 unsigned int sel;
4335
4336 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4337 ucontrol->value.enumerated.item[0] = sel & 3;
4338 return 0;
4339}
4340
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004341static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4342 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004343{
4344 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4345 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4346 unsigned int sel;
4347
4348 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4349 if (ucontrol->value.enumerated.item[0] != sel) {
4350 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004351 snd_hda_codec_write_cache(codec, nid, 0,
4352 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004353 return 1;
4354 }
4355 return 0;
4356}
4357
4358#define PIN_CTL_TEST(xname,nid) { \
4359 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4360 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004361 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004362 .info = alc_test_pin_ctl_info, \
4363 .get = alc_test_pin_ctl_get, \
4364 .put = alc_test_pin_ctl_put, \
4365 .private_value = nid \
4366 }
4367
4368#define PIN_SRC_TEST(xname,nid) { \
4369 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4370 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004371 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004372 .info = alc_test_pin_src_info, \
4373 .get = alc_test_pin_src_get, \
4374 .put = alc_test_pin_src_put, \
4375 .private_value = nid \
4376 }
4377
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004378static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004379 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4380 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4381 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4382 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004383 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4384 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4385 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4386 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004387 PIN_CTL_TEST("Front Pin Mode", 0x14),
4388 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4389 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4390 PIN_CTL_TEST("Side Pin Mode", 0x17),
4391 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4392 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4393 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4394 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4395 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4396 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4397 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4398 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4399 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4400 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4401 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4402 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4403 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4404 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4405 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4406 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4407 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4408 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004409 {
4410 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4411 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004412 .info = alc_ch_mode_info,
4413 .get = alc_ch_mode_get,
4414 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004415 },
4416 { } /* end */
4417};
4418
4419static struct hda_verb alc880_test_init_verbs[] = {
4420 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004421 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4422 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4423 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4424 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4425 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4426 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4427 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4428 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004429 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004430 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4431 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4432 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4433 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004434 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004435 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4436 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4437 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4438 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004439 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004440 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4441 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4442 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4443 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004444 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004445 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4446 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004447 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4448 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4449 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004450 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004451 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4452 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4453 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4454 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004455 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004456 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004457 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004458 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004459 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004460 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004461 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004462 /* Analog input/passthru */
4463 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4464 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4465 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4466 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4467 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004468 { }
4469};
4470#endif
4471
Linus Torvalds1da177e2005-04-16 15:20:36 -07004472/*
4473 */
4474
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004475static const char *alc880_models[ALC880_MODEL_LAST] = {
4476 [ALC880_3ST] = "3stack",
4477 [ALC880_TCL_S700] = "tcl",
4478 [ALC880_3ST_DIG] = "3stack-digout",
4479 [ALC880_CLEVO] = "clevo",
4480 [ALC880_5ST] = "5stack",
4481 [ALC880_5ST_DIG] = "5stack-digout",
4482 [ALC880_W810] = "w810",
4483 [ALC880_Z71V] = "z71v",
4484 [ALC880_6ST] = "6stack",
4485 [ALC880_6ST_DIG] = "6stack-digout",
4486 [ALC880_ASUS] = "asus",
4487 [ALC880_ASUS_W1V] = "asus-w1v",
4488 [ALC880_ASUS_DIG] = "asus-dig",
4489 [ALC880_ASUS_DIG2] = "asus-dig2",
4490 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004491 [ALC880_UNIWILL_P53] = "uniwill-p53",
4492 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004493 [ALC880_F1734] = "F1734",
4494 [ALC880_LG] = "lg",
4495 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004496 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004497#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004498 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004499#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004500 [ALC880_AUTO] = "auto",
4501};
4502
4503static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004504 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004505 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4506 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4507 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4508 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4509 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4510 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4511 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4512 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004513 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4514 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004515 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4516 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4517 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4518 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4519 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4520 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4521 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4522 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4523 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4524 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004525 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004526 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4527 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4528 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004529 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004530 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004531 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4532 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004533 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4534 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004535 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4536 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4537 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4538 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004539 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4540 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004541 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004542 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004543 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004544 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004545 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4546 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004547 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004548 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004549 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004550 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004551 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004552 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Daniel T Chen33535412010-04-22 07:15:26 -04004553 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004554 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004555 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004556 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
4557 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004558 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004559 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4560 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4561 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4562 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004563 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4564 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004565 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004566 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004567 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4568 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004569 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4570 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4571 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004572 /* default Intel */
4573 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004574 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4575 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004576 {}
4577};
4578
Takashi Iwai16ded522005-06-10 19:58:24 +02004579/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004580 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004581 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004582static struct alc_config_preset alc880_presets[] = {
4583 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004584 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004585 .init_verbs = { alc880_volume_init_verbs,
4586 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004587 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004588 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004589 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4590 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004591 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004592 .input_mux = &alc880_capture_source,
4593 },
4594 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004595 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004596 .init_verbs = { alc880_volume_init_verbs,
4597 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004598 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004599 .dac_nids = alc880_dac_nids,
4600 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004601 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4602 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004603 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004604 .input_mux = &alc880_capture_source,
4605 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004606 [ALC880_TCL_S700] = {
4607 .mixers = { alc880_tcl_s700_mixer },
4608 .init_verbs = { alc880_volume_init_verbs,
4609 alc880_pin_tcl_S700_init_verbs,
4610 alc880_gpio2_init_verbs },
4611 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4612 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004613 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4614 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004615 .hp_nid = 0x03,
4616 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4617 .channel_mode = alc880_2_jack_modes,
4618 .input_mux = &alc880_capture_source,
4619 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004620 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004621 .mixers = { alc880_three_stack_mixer,
4622 alc880_five_stack_mixer},
4623 .init_verbs = { alc880_volume_init_verbs,
4624 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004625 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4626 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004627 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4628 .channel_mode = alc880_fivestack_modes,
4629 .input_mux = &alc880_capture_source,
4630 },
4631 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004632 .mixers = { alc880_three_stack_mixer,
4633 alc880_five_stack_mixer },
4634 .init_verbs = { alc880_volume_init_verbs,
4635 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004636 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4637 .dac_nids = alc880_dac_nids,
4638 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004639 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4640 .channel_mode = alc880_fivestack_modes,
4641 .input_mux = &alc880_capture_source,
4642 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004643 [ALC880_6ST] = {
4644 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004645 .init_verbs = { alc880_volume_init_verbs,
4646 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004647 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4648 .dac_nids = alc880_6st_dac_nids,
4649 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4650 .channel_mode = alc880_sixstack_modes,
4651 .input_mux = &alc880_6stack_capture_source,
4652 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004653 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004654 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004655 .init_verbs = { alc880_volume_init_verbs,
4656 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004657 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4658 .dac_nids = alc880_6st_dac_nids,
4659 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004660 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4661 .channel_mode = alc880_sixstack_modes,
4662 .input_mux = &alc880_6stack_capture_source,
4663 },
4664 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004665 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004666 .init_verbs = { alc880_volume_init_verbs,
4667 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004668 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004669 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4670 .dac_nids = alc880_w810_dac_nids,
4671 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004672 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4673 .channel_mode = alc880_w810_modes,
4674 .input_mux = &alc880_capture_source,
4675 },
4676 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004677 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004678 .init_verbs = { alc880_volume_init_verbs,
4679 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004680 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4681 .dac_nids = alc880_z71v_dac_nids,
4682 .dig_out_nid = ALC880_DIGOUT_NID,
4683 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004684 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4685 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004686 .input_mux = &alc880_capture_source,
4687 },
4688 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004689 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004690 .init_verbs = { alc880_volume_init_verbs,
4691 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004692 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4693 .dac_nids = alc880_f1734_dac_nids,
4694 .hp_nid = 0x02,
4695 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4696 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004697 .input_mux = &alc880_f1734_capture_source,
4698 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004699 .setup = alc880_uniwill_p53_setup,
4700 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004701 },
4702 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004703 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004704 .init_verbs = { alc880_volume_init_verbs,
4705 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004706 alc880_gpio1_init_verbs },
4707 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4708 .dac_nids = alc880_asus_dac_nids,
4709 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4710 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004711 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004712 .input_mux = &alc880_capture_source,
4713 },
4714 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004715 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004716 .init_verbs = { alc880_volume_init_verbs,
4717 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004718 alc880_gpio1_init_verbs },
4719 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4720 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004721 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004722 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4723 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004724 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004725 .input_mux = &alc880_capture_source,
4726 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004727 [ALC880_ASUS_DIG2] = {
4728 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004729 .init_verbs = { alc880_volume_init_verbs,
4730 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004731 alc880_gpio2_init_verbs }, /* use GPIO2 */
4732 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4733 .dac_nids = alc880_asus_dac_nids,
4734 .dig_out_nid = ALC880_DIGOUT_NID,
4735 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4736 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004737 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004738 .input_mux = &alc880_capture_source,
4739 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004740 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004741 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004742 .init_verbs = { alc880_volume_init_verbs,
4743 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004744 alc880_gpio1_init_verbs },
4745 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4746 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004747 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004748 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4749 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004750 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004751 .input_mux = &alc880_capture_source,
4752 },
4753 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004754 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004755 .init_verbs = { alc880_volume_init_verbs,
4756 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004757 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4758 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004759 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004760 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4761 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004762 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004763 .input_mux = &alc880_capture_source,
4764 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004765 [ALC880_UNIWILL] = {
4766 .mixers = { alc880_uniwill_mixer },
4767 .init_verbs = { alc880_volume_init_verbs,
4768 alc880_uniwill_init_verbs },
4769 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4770 .dac_nids = alc880_asus_dac_nids,
4771 .dig_out_nid = ALC880_DIGOUT_NID,
4772 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4773 .channel_mode = alc880_threestack_modes,
4774 .need_dac_fix = 1,
4775 .input_mux = &alc880_capture_source,
4776 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004777 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004778 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004779 },
4780 [ALC880_UNIWILL_P53] = {
4781 .mixers = { alc880_uniwill_p53_mixer },
4782 .init_verbs = { alc880_volume_init_verbs,
4783 alc880_uniwill_p53_init_verbs },
4784 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4785 .dac_nids = alc880_asus_dac_nids,
4786 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004787 .channel_mode = alc880_threestack_modes,
4788 .input_mux = &alc880_capture_source,
4789 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004790 .setup = alc880_uniwill_p53_setup,
4791 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004792 },
4793 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004794 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004795 .init_verbs = { alc880_volume_init_verbs,
4796 alc880_uniwill_p53_init_verbs,
4797 alc880_beep_init_verbs },
4798 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4799 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004800 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004801 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4802 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004803 .input_mux = &alc880_capture_source,
4804 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004805 .setup = alc880_uniwill_p53_setup,
4806 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004807 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004808 [ALC880_CLEVO] = {
4809 .mixers = { alc880_three_stack_mixer },
4810 .init_verbs = { alc880_volume_init_verbs,
4811 alc880_pin_clevo_init_verbs },
4812 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4813 .dac_nids = alc880_dac_nids,
4814 .hp_nid = 0x03,
4815 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4816 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004817 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004818 .input_mux = &alc880_capture_source,
4819 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004820 [ALC880_LG] = {
4821 .mixers = { alc880_lg_mixer },
4822 .init_verbs = { alc880_volume_init_verbs,
4823 alc880_lg_init_verbs },
4824 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4825 .dac_nids = alc880_lg_dac_nids,
4826 .dig_out_nid = ALC880_DIGOUT_NID,
4827 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4828 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004829 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004830 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004831 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004832 .setup = alc880_lg_setup,
4833 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004834#ifdef CONFIG_SND_HDA_POWER_SAVE
4835 .loopbacks = alc880_lg_loopbacks,
4836#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004837 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004838 [ALC880_LG_LW] = {
4839 .mixers = { alc880_lg_lw_mixer },
4840 .init_verbs = { alc880_volume_init_verbs,
4841 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004842 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004843 .dac_nids = alc880_dac_nids,
4844 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004845 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4846 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004847 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004848 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004849 .setup = alc880_lg_lw_setup,
4850 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004851 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004852 [ALC880_MEDION_RIM] = {
4853 .mixers = { alc880_medion_rim_mixer },
4854 .init_verbs = { alc880_volume_init_verbs,
4855 alc880_medion_rim_init_verbs,
4856 alc_gpio2_init_verbs },
4857 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4858 .dac_nids = alc880_dac_nids,
4859 .dig_out_nid = ALC880_DIGOUT_NID,
4860 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4861 .channel_mode = alc880_2_jack_modes,
4862 .input_mux = &alc880_medion_rim_capture_source,
4863 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004864 .setup = alc880_medion_rim_setup,
4865 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004866 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004867#ifdef CONFIG_SND_DEBUG
4868 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004869 .mixers = { alc880_test_mixer },
4870 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004871 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4872 .dac_nids = alc880_test_dac_nids,
4873 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004874 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4875 .channel_mode = alc880_test_modes,
4876 .input_mux = &alc880_test_capture_source,
4877 },
4878#endif
4879};
4880
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004881/*
4882 * Automatic parse of I/O pins from the BIOS configuration
4883 */
4884
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004885enum {
4886 ALC_CTL_WIDGET_VOL,
4887 ALC_CTL_WIDGET_MUTE,
4888 ALC_CTL_BIND_MUTE,
4889};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004890static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004891 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4892 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004893 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004894};
4895
4896/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004897static int add_control(struct alc_spec *spec, int type, const char *name,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004898 int cidx, unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004899{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004900 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004901
Takashi Iwai603c4012008-07-30 15:01:44 +02004902 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4903 knew = snd_array_new(&spec->kctls);
4904 if (!knew)
4905 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004906 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004907 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004908 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004909 return -ENOMEM;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004910 knew->index = cidx;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004911 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004912 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004913 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004914 return 0;
4915}
4916
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004917static int add_control_with_pfx(struct alc_spec *spec, int type,
4918 const char *pfx, const char *dir,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004919 const char *sfx, int cidx, unsigned long val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004920{
4921 char name[32];
4922 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004923 return add_control(spec, type, name, cidx, val);
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004924}
4925
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004926#define add_pb_vol_ctrl(spec, type, pfx, val) \
4927 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
4928#define add_pb_sw_ctrl(spec, type, pfx, val) \
4929 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
4930#define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
4931 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
4932#define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
4933 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004934
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004935#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4936#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4937#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4938#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004939#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4940#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4941#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4942#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4943#define ALC880_PIN_CD_NID 0x1c
4944
4945/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004946static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4947 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004948{
4949 hda_nid_t nid;
4950 int assigned[4];
4951 int i, j;
4952
4953 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004954 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004955
4956 /* check the pins hardwired to audio widget */
4957 for (i = 0; i < cfg->line_outs; i++) {
4958 nid = cfg->line_out_pins[i];
4959 if (alc880_is_fixed_pin(nid)) {
4960 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004961 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004962 assigned[idx] = 1;
4963 }
4964 }
4965 /* left pins can be connect to any audio widget */
4966 for (i = 0; i < cfg->line_outs; i++) {
4967 nid = cfg->line_out_pins[i];
4968 if (alc880_is_fixed_pin(nid))
4969 continue;
4970 /* search for an empty channel */
4971 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004972 if (!assigned[j]) {
4973 spec->multiout.dac_nids[i] =
4974 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004975 assigned[j] = 1;
4976 break;
4977 }
4978 }
4979 }
4980 spec->multiout.num_dacs = cfg->line_outs;
4981 return 0;
4982}
4983
4984/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004985static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4986 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004987{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004988 static const char *chname[4] = {
4989 "Front", "Surround", NULL /*CLFE*/, "Side"
4990 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004991 hda_nid_t nid;
4992 int i, err;
4993
4994 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004995 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004996 continue;
4997 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4998 if (i == 2) {
4999 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005000 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5001 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005002 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
5003 HDA_OUTPUT));
5004 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005005 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005006 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5007 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005008 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
5009 HDA_OUTPUT));
5010 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005011 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005012 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5013 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005014 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
5015 HDA_INPUT));
5016 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005017 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005018 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5019 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005020 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
5021 HDA_INPUT));
5022 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005023 return err;
5024 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02005025 const char *pfx;
5026 if (cfg->line_outs == 1 &&
5027 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
5028 pfx = "Speaker";
5029 else
5030 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005031 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005032 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
5033 HDA_OUTPUT));
5034 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005035 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005036 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005037 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
5038 HDA_INPUT));
5039 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005040 return err;
5041 }
5042 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005043 return 0;
5044}
5045
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005046/* add playback controls for speaker and HP outputs */
5047static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
5048 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005049{
5050 hda_nid_t nid;
5051 int err;
5052
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005053 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005054 return 0;
5055
5056 if (alc880_is_fixed_pin(pin)) {
5057 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01005058 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005059 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005060 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005061 else
5062 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005063 /* control HP volume/switch on the output mixer amp */
5064 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005065 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005066 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
5067 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005068 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005069 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005070 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
5071 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005072 return err;
5073 } else if (alc880_is_multi_pin(pin)) {
5074 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005075 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005076 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005077 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
5078 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005079 return err;
5080 }
5081 return 0;
5082}
5083
5084/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005085static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005086 const char *ctlname, int ctlidx,
Kailang Yangdf694da2005-12-05 19:42:22 +01005087 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005088{
Kailang Yangdf694da2005-12-05 19:42:22 +01005089 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005090
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005091 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005092 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5093 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005094 return err;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005095 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005096 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5097 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005098 return err;
5099 return 0;
5100}
5101
Takashi Iwai05f5f472009-08-25 13:10:18 +02005102static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005103{
Takashi Iwai05f5f472009-08-25 13:10:18 +02005104 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
5105 return (pincap & AC_PINCAP_IN) != 0;
5106}
5107
5108/* create playback/capture controls for input pins */
5109static int alc_auto_create_input_ctls(struct hda_codec *codec,
5110 const struct auto_pin_cfg *cfg,
5111 hda_nid_t mixer,
5112 hda_nid_t cap1, hda_nid_t cap2)
5113{
5114 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005115 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005116 int i, err, idx, type, type_idx = 0;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005117
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005118 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02005119 hda_nid_t pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005120 const char *label;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005121
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005122 pin = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005123 if (!alc_is_input_pin(codec, pin))
5124 continue;
5125
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005126 type = cfg->inputs[i].type;
5127 if (i > 0 && type == cfg->inputs[i - 1].type)
5128 type_idx++;
5129 else
5130 type_idx = 0;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005131 label = hda_get_autocfg_input_label(codec, cfg, i);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005132 if (mixer) {
5133 idx = get_connection_index(codec, mixer, pin);
5134 if (idx >= 0) {
5135 err = new_analog_input(spec, pin,
Takashi Iwai10a20af2010-09-09 16:28:02 +02005136 label, type_idx,
5137 idx, mixer);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005138 if (err < 0)
5139 return err;
5140 }
5141 }
5142
5143 if (!cap1)
5144 continue;
5145 idx = get_connection_index(codec, cap1, pin);
5146 if (idx < 0 && cap2)
5147 idx = get_connection_index(codec, cap2, pin);
Takashi Iwai10a20af2010-09-09 16:28:02 +02005148 if (idx >= 0)
5149 snd_hda_add_imux_item(imux, label, idx, NULL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005150 }
5151 return 0;
5152}
5153
Takashi Iwai05f5f472009-08-25 13:10:18 +02005154static int alc880_auto_create_input_ctls(struct hda_codec *codec,
5155 const struct auto_pin_cfg *cfg)
5156{
5157 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
5158}
5159
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005160static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
5161 unsigned int pin_type)
5162{
5163 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5164 pin_type);
5165 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01005166 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5167 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005168}
5169
Kailang Yangdf694da2005-12-05 19:42:22 +01005170static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
5171 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005172 int dac_idx)
5173{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005174 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005175 /* need the manual connection? */
5176 if (alc880_is_multi_pin(nid)) {
5177 struct alc_spec *spec = codec->spec;
5178 int idx = alc880_multi_pin_idx(nid);
5179 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
5180 AC_VERB_SET_CONNECT_SEL,
5181 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
5182 }
5183}
5184
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005185static int get_pin_type(int line_out_type)
5186{
5187 if (line_out_type == AUTO_PIN_HP_OUT)
5188 return PIN_HP;
5189 else
5190 return PIN_OUT;
5191}
5192
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005193static void alc880_auto_init_multi_out(struct hda_codec *codec)
5194{
5195 struct alc_spec *spec = codec->spec;
5196 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02005197
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005198 for (i = 0; i < spec->autocfg.line_outs; i++) {
5199 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005200 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5201 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005202 }
5203}
5204
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005205static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005206{
5207 struct alc_spec *spec = codec->spec;
5208 hda_nid_t pin;
5209
Takashi Iwai82bc9552006-03-21 11:24:42 +01005210 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005211 if (pin) /* connect to front */
5212 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005213 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005214 if (pin) /* connect to front */
5215 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5216}
5217
5218static void alc880_auto_init_analog_input(struct hda_codec *codec)
5219{
5220 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005221 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005222 int i;
5223
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005224 for (i = 0; i < cfg->num_inputs; i++) {
5225 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005226 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02005227 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005228 if (nid != ALC880_PIN_CD_NID &&
5229 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005230 snd_hda_codec_write(codec, nid, 0,
5231 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005232 AMP_OUT_MUTE);
5233 }
5234 }
5235}
5236
Takashi Iwai7f311a42010-04-09 17:32:23 +02005237static void alc880_auto_init_input_src(struct hda_codec *codec)
5238{
5239 struct alc_spec *spec = codec->spec;
5240 int c;
5241
5242 for (c = 0; c < spec->num_adc_nids; c++) {
5243 unsigned int mux_idx;
5244 const struct hda_input_mux *imux;
5245 mux_idx = c >= spec->num_mux_defs ? 0 : c;
5246 imux = &spec->input_mux[mux_idx];
5247 if (!imux->num_items && mux_idx > 0)
5248 imux = &spec->input_mux[0];
5249 if (imux)
5250 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
5251 AC_VERB_SET_CONNECT_SEL,
5252 imux->items[0].index);
5253 }
5254}
5255
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005256/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005257/* return 1 if successful, 0 if the proper config is not found,
5258 * or a negative error code
5259 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005260static int alc880_parse_auto_config(struct hda_codec *codec)
5261{
5262 struct alc_spec *spec = codec->spec;
Takashi Iwai757899a2010-07-30 10:48:14 +02005263 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005264 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005265
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005266 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5267 alc880_ignore);
5268 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005269 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005270 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005271 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01005272
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005273 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
5274 if (err < 0)
5275 return err;
5276 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
5277 if (err < 0)
5278 return err;
5279 err = alc880_auto_create_extra_out(spec,
5280 spec->autocfg.speaker_pins[0],
5281 "Speaker");
5282 if (err < 0)
5283 return err;
5284 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
5285 "Headphone");
5286 if (err < 0)
5287 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005288 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005289 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005290 return err;
5291
5292 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5293
Takashi Iwai757899a2010-07-30 10:48:14 +02005294 alc_auto_parse_digital(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005295
Takashi Iwai603c4012008-07-30 15:01:44 +02005296 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005297 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005298
Takashi Iwaid88897e2008-10-31 15:01:37 +01005299 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005300
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005301 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005302 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005303
Kailang Yang6227cdc2010-02-25 08:36:52 +01005304 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005305
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005306 return 1;
5307}
5308
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005309/* additional initialization for auto-configuration model */
5310static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005311{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005312 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005313 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005314 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005315 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02005316 alc880_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02005317 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005318 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005319 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005320}
5321
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005322/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5323 * one of two digital mic pins, e.g. on ALC272
5324 */
5325static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005326{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005327 struct alc_spec *spec = codec->spec;
5328 int i;
5329
5330 for (i = 0; i < spec->num_adc_nids; i++) {
5331 hda_nid_t cap = spec->capsrc_nids ?
5332 spec->capsrc_nids[i] : spec->adc_nids[i];
5333 int iidx, eidx;
5334
5335 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5336 if (iidx < 0)
5337 continue;
5338 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5339 if (eidx < 0)
5340 continue;
5341 spec->int_mic.mux_idx = iidx;
5342 spec->ext_mic.mux_idx = eidx;
5343 if (spec->capsrc_nids)
5344 spec->capsrc_nids += i;
5345 spec->adc_nids += i;
5346 spec->num_adc_nids = 1;
5347 return;
5348 }
5349 snd_printd(KERN_INFO "hda_codec: %s: "
5350 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5351 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5352 spec->auto_mic = 0; /* disable auto-mic to be sure */
5353}
5354
Takashi Iwai748cce42010-08-04 07:37:39 +02005355/* select or unmute the given capsrc route */
5356static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
5357 int idx)
5358{
5359 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5360 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5361 HDA_AMP_MUTE, 0);
5362 } else {
5363 snd_hda_codec_write_cache(codec, cap, 0,
5364 AC_VERB_SET_CONNECT_SEL, idx);
5365 }
5366}
5367
Takashi Iwai840b64c2010-07-13 22:49:01 +02005368/* set the default connection to that pin */
5369static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
5370{
5371 struct alc_spec *spec = codec->spec;
5372 int i;
5373
5374 for (i = 0; i < spec->num_adc_nids; i++) {
5375 hda_nid_t cap = spec->capsrc_nids ?
5376 spec->capsrc_nids[i] : spec->adc_nids[i];
5377 int idx;
5378
5379 idx = get_connection_index(codec, cap, pin);
5380 if (idx < 0)
5381 continue;
Takashi Iwai748cce42010-08-04 07:37:39 +02005382 select_or_unmute_capsrc(codec, cap, idx);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005383 return i; /* return the found index */
5384 }
5385 return -1; /* not found */
5386}
5387
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005388/* choose the ADC/MUX containing the input pin and initialize the setup */
5389static void fixup_single_adc(struct hda_codec *codec)
5390{
5391 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005392 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005393 int i;
5394
5395 /* search for the input pin; there must be only one */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005396 if (cfg->num_inputs != 1)
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005397 return;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005398 i = init_capsrc_for_pin(codec, cfg->inputs[0].pin);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005399 if (i >= 0) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005400 /* use only this ADC */
5401 if (spec->capsrc_nids)
5402 spec->capsrc_nids += i;
5403 spec->adc_nids += i;
5404 spec->num_adc_nids = 1;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005405 }
5406}
5407
Takashi Iwai840b64c2010-07-13 22:49:01 +02005408/* initialize dual adcs */
5409static void fixup_dual_adc_switch(struct hda_codec *codec)
5410{
5411 struct alc_spec *spec = codec->spec;
5412 init_capsrc_for_pin(codec, spec->ext_mic.pin);
5413 init_capsrc_for_pin(codec, spec->int_mic.pin);
5414}
5415
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005416static void set_capture_mixer(struct hda_codec *codec)
5417{
5418 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005419 static struct snd_kcontrol_new *caps[2][3] = {
5420 { alc_capture_mixer_nosrc1,
5421 alc_capture_mixer_nosrc2,
5422 alc_capture_mixer_nosrc3 },
5423 { alc_capture_mixer1,
5424 alc_capture_mixer2,
5425 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005426 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005427 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005428 int mux = 0;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005429 int num_adcs = spec->num_adc_nids;
5430 if (spec->dual_adc_switch)
5431 fixup_dual_adc_switch(codec);
5432 else if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005433 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005434 else if (spec->input_mux) {
5435 if (spec->input_mux->num_items > 1)
5436 mux = 1;
5437 else if (spec->input_mux->num_items == 1)
5438 fixup_single_adc(codec);
5439 }
Takashi Iwai840b64c2010-07-13 22:49:01 +02005440 if (spec->dual_adc_switch)
5441 num_adcs = 1;
5442 spec->cap_mixer = caps[mux][num_adcs - 1];
Takashi Iwaia23b6882009-03-23 15:21:36 +01005443 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005444}
5445
Takashi Iwai66946352010-03-29 17:21:45 +02005446/* fill adc_nids (and capsrc_nids) containing all active input pins */
5447static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5448 int num_nids)
5449{
5450 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005451 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai66946352010-03-29 17:21:45 +02005452 int n;
5453 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5454
5455 for (n = 0; n < num_nids; n++) {
5456 hda_nid_t adc, cap;
5457 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5458 int nconns, i, j;
5459
5460 adc = nids[n];
5461 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5462 continue;
5463 cap = adc;
5464 nconns = snd_hda_get_connections(codec, cap, conn,
5465 ARRAY_SIZE(conn));
5466 if (nconns == 1) {
5467 cap = conn[0];
5468 nconns = snd_hda_get_connections(codec, cap, conn,
5469 ARRAY_SIZE(conn));
5470 }
5471 if (nconns <= 0)
5472 continue;
5473 if (!fallback_adc) {
5474 fallback_adc = adc;
5475 fallback_cap = cap;
5476 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005477 for (i = 0; i < cfg->num_inputs; i++) {
5478 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai66946352010-03-29 17:21:45 +02005479 for (j = 0; j < nconns; j++) {
5480 if (conn[j] == nid)
5481 break;
5482 }
5483 if (j >= nconns)
5484 break;
5485 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005486 if (i >= cfg->num_inputs) {
Takashi Iwai66946352010-03-29 17:21:45 +02005487 int num_adcs = spec->num_adc_nids;
5488 spec->private_adc_nids[num_adcs] = adc;
5489 spec->private_capsrc_nids[num_adcs] = cap;
5490 spec->num_adc_nids++;
5491 spec->adc_nids = spec->private_adc_nids;
5492 if (adc != cap)
5493 spec->capsrc_nids = spec->private_capsrc_nids;
5494 }
5495 }
5496 if (!spec->num_adc_nids) {
5497 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005498 " using fallback 0x%x\n",
5499 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005500 spec->private_adc_nids[0] = fallback_adc;
5501 spec->adc_nids = spec->private_adc_nids;
5502 if (fallback_adc != fallback_cap) {
5503 spec->private_capsrc_nids[0] = fallback_cap;
5504 spec->capsrc_nids = spec->private_adc_nids;
5505 }
5506 }
5507}
5508
Takashi Iwai67d634c2009-11-16 15:35:59 +01005509#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005510#define set_beep_amp(spec, nid, idx, dir) \
5511 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005512
5513static struct snd_pci_quirk beep_white_list[] = {
5514 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai080dc7b2010-09-08 08:38:41 +02005515 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
Takashi Iwaie096c8e2010-08-03 17:20:35 +02005516 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005517 {}
5518};
5519
5520static inline int has_cdefine_beep(struct hda_codec *codec)
5521{
5522 struct alc_spec *spec = codec->spec;
5523 const struct snd_pci_quirk *q;
5524 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5525 if (q)
5526 return q->value;
5527 return spec->cdefine.enable_pcbeep;
5528}
Takashi Iwai67d634c2009-11-16 15:35:59 +01005529#else
5530#define set_beep_amp(spec, nid, idx, dir) /* NOP */
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005531#define has_cdefine_beep(codec) 0
Takashi Iwai67d634c2009-11-16 15:35:59 +01005532#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005533
5534/*
5535 * OK, here we have finally the patch for ALC880
5536 */
5537
Linus Torvalds1da177e2005-04-16 15:20:36 -07005538static int patch_alc880(struct hda_codec *codec)
5539{
5540 struct alc_spec *spec;
5541 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005542 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005543
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005544 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005545 if (spec == NULL)
5546 return -ENOMEM;
5547
5548 codec->spec = spec;
5549
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005550 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5551 alc880_models,
5552 alc880_cfg_tbl);
5553 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005554 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5555 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005556 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005557 }
5558
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005559 if (board_config == ALC880_AUTO) {
5560 /* automatic parse from the BIOS config */
5561 err = alc880_parse_auto_config(codec);
5562 if (err < 0) {
5563 alc_free(codec);
5564 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005565 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005566 printk(KERN_INFO
5567 "hda_codec: Cannot set up configuration "
5568 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005569 board_config = ALC880_3ST;
5570 }
5571 }
5572
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005573 err = snd_hda_attach_beep_device(codec, 0x1);
5574 if (err < 0) {
5575 alc_free(codec);
5576 return err;
5577 }
5578
Kailang Yangdf694da2005-12-05 19:42:22 +01005579 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005580 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005581
Linus Torvalds1da177e2005-04-16 15:20:36 -07005582 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5583 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005584 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005585
Linus Torvalds1da177e2005-04-16 15:20:36 -07005586 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5587 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5588
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005589 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005590 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005591 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005592 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005593 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005594 if (wcap != AC_WID_AUD_IN) {
5595 spec->adc_nids = alc880_adc_nids_alt;
5596 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005597 } else {
5598 spec->adc_nids = alc880_adc_nids;
5599 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005600 }
5601 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005602 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005603 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005604
Takashi Iwai2134ea42008-01-10 16:53:55 +01005605 spec->vmaster_nid = 0x0c;
5606
Linus Torvalds1da177e2005-04-16 15:20:36 -07005607 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005608 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005609 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005610#ifdef CONFIG_SND_HDA_POWER_SAVE
5611 if (!spec->loopback.amplist)
5612 spec->loopback.amplist = alc880_loopbacks;
5613#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005614
5615 return 0;
5616}
5617
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005618
Linus Torvalds1da177e2005-04-16 15:20:36 -07005619/*
5620 * ALC260 support
5621 */
5622
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005623static hda_nid_t alc260_dac_nids[1] = {
5624 /* front */
5625 0x02,
5626};
5627
5628static hda_nid_t alc260_adc_nids[1] = {
5629 /* ADC0 */
5630 0x04,
5631};
5632
Kailang Yangdf694da2005-12-05 19:42:22 +01005633static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005634 /* ADC1 */
5635 0x05,
5636};
5637
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005638/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5639 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5640 */
5641static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005642 /* ADC0, ADC1 */
5643 0x04, 0x05
5644};
5645
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005646#define ALC260_DIGOUT_NID 0x03
5647#define ALC260_DIGIN_NID 0x06
5648
5649static struct hda_input_mux alc260_capture_source = {
5650 .num_items = 4,
5651 .items = {
5652 { "Mic", 0x0 },
5653 { "Front Mic", 0x1 },
5654 { "Line", 0x2 },
5655 { "CD", 0x4 },
5656 },
5657};
5658
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005659/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005660 * headphone jack and the internal CD lines since these are the only pins at
5661 * which audio can appear. For flexibility, also allow the option of
5662 * recording the mixer output on the second ADC (ADC0 doesn't have a
5663 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005664 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005665static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5666 {
5667 .num_items = 3,
5668 .items = {
5669 { "Mic/Line", 0x0 },
5670 { "CD", 0x4 },
5671 { "Headphone", 0x2 },
5672 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005673 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005674 {
5675 .num_items = 4,
5676 .items = {
5677 { "Mic/Line", 0x0 },
5678 { "CD", 0x4 },
5679 { "Headphone", 0x2 },
5680 { "Mixer", 0x5 },
5681 },
5682 },
5683
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005684};
5685
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005686/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5687 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005688 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005689static struct hda_input_mux alc260_acer_capture_sources[2] = {
5690 {
5691 .num_items = 4,
5692 .items = {
5693 { "Mic", 0x0 },
5694 { "Line", 0x2 },
5695 { "CD", 0x4 },
5696 { "Headphone", 0x5 },
5697 },
5698 },
5699 {
5700 .num_items = 5,
5701 .items = {
5702 { "Mic", 0x0 },
5703 { "Line", 0x2 },
5704 { "CD", 0x4 },
5705 { "Headphone", 0x6 },
5706 { "Mixer", 0x5 },
5707 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005708 },
5709};
Michael Schwingencc959482009-02-22 18:58:45 +01005710
5711/* Maxdata Favorit 100XS */
5712static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5713 {
5714 .num_items = 2,
5715 .items = {
5716 { "Line/Mic", 0x0 },
5717 { "CD", 0x4 },
5718 },
5719 },
5720 {
5721 .num_items = 3,
5722 .items = {
5723 { "Line/Mic", 0x0 },
5724 { "CD", 0x4 },
5725 { "Mixer", 0x5 },
5726 },
5727 },
5728};
5729
Linus Torvalds1da177e2005-04-16 15:20:36 -07005730/*
5731 * This is just place-holder, so there's something for alc_build_pcms to look
5732 * at when it calculates the maximum number of channels. ALC260 has no mixer
5733 * element which allows changing the channel mode, so the verb list is
5734 * never used.
5735 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005736static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005737 { 2, NULL },
5738};
5739
Kailang Yangdf694da2005-12-05 19:42:22 +01005740
5741/* Mixer combinations
5742 *
5743 * basic: base_output + input + pc_beep + capture
5744 * HP: base_output + input + capture_alt
5745 * HP_3013: hp_3013 + input + capture
5746 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005747 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005748 */
5749
5750static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005751 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005752 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005753 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5754 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5755 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5756 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5757 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005758};
Kailang Yangdf694da2005-12-05 19:42:22 +01005759
5760static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005761 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5762 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5763 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5764 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5765 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5766 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5767 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5768 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005769 { } /* end */
5770};
5771
Takashi Iwaibec15c32008-01-28 18:16:30 +01005772/* update HP, line and mono out pins according to the master switch */
5773static void alc260_hp_master_update(struct hda_codec *codec,
5774 hda_nid_t hp, hda_nid_t line,
5775 hda_nid_t mono)
5776{
5777 struct alc_spec *spec = codec->spec;
5778 unsigned int val = spec->master_sw ? PIN_HP : 0;
5779 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005780 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005781 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005782 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005783 val);
5784 /* mono (speaker) depending on the HP jack sense */
5785 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005786 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005787 val);
5788}
5789
5790static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5791 struct snd_ctl_elem_value *ucontrol)
5792{
5793 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5794 struct alc_spec *spec = codec->spec;
5795 *ucontrol->value.integer.value = spec->master_sw;
5796 return 0;
5797}
5798
5799static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5800 struct snd_ctl_elem_value *ucontrol)
5801{
5802 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5803 struct alc_spec *spec = codec->spec;
5804 int val = !!*ucontrol->value.integer.value;
5805 hda_nid_t hp, line, mono;
5806
5807 if (val == spec->master_sw)
5808 return 0;
5809 spec->master_sw = val;
5810 hp = (kcontrol->private_value >> 16) & 0xff;
5811 line = (kcontrol->private_value >> 8) & 0xff;
5812 mono = kcontrol->private_value & 0xff;
5813 alc260_hp_master_update(codec, hp, line, mono);
5814 return 1;
5815}
5816
5817static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5818 {
5819 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5820 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005821 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005822 .info = snd_ctl_boolean_mono_info,
5823 .get = alc260_hp_master_sw_get,
5824 .put = alc260_hp_master_sw_put,
5825 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5826 },
5827 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5828 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5829 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5830 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5831 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5832 HDA_OUTPUT),
5833 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5834 { } /* end */
5835};
5836
5837static struct hda_verb alc260_hp_unsol_verbs[] = {
5838 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5839 {},
5840};
5841
5842static void alc260_hp_automute(struct hda_codec *codec)
5843{
5844 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005845
Wu Fengguang864f92b2009-11-18 12:38:02 +08005846 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005847 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5848}
5849
5850static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5851{
5852 if ((res >> 26) == ALC880_HP_EVENT)
5853 alc260_hp_automute(codec);
5854}
5855
Kailang Yangdf694da2005-12-05 19:42:22 +01005856static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005857 {
5858 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5859 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005860 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005861 .info = snd_ctl_boolean_mono_info,
5862 .get = alc260_hp_master_sw_get,
5863 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005864 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005865 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005866 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5867 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5868 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5869 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5870 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5871 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005872 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5873 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005874 { } /* end */
5875};
5876
Kailang Yang3f878302008-08-26 13:02:23 +02005877static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5878 .ops = &snd_hda_bind_vol,
5879 .values = {
5880 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5881 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5882 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5883 0
5884 },
5885};
5886
5887static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5888 .ops = &snd_hda_bind_sw,
5889 .values = {
5890 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5891 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5892 0
5893 },
5894};
5895
5896static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5897 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5898 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5899 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5900 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5901 { } /* end */
5902};
5903
Takashi Iwaibec15c32008-01-28 18:16:30 +01005904static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5905 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5906 {},
5907};
5908
5909static void alc260_hp_3013_automute(struct hda_codec *codec)
5910{
5911 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005912
Wu Fengguang864f92b2009-11-18 12:38:02 +08005913 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005914 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005915}
5916
5917static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5918 unsigned int res)
5919{
5920 if ((res >> 26) == ALC880_HP_EVENT)
5921 alc260_hp_3013_automute(codec);
5922}
5923
Kailang Yang3f878302008-08-26 13:02:23 +02005924static void alc260_hp_3012_automute(struct hda_codec *codec)
5925{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005926 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005927
Kailang Yang3f878302008-08-26 13:02:23 +02005928 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5929 bits);
5930 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5931 bits);
5932 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5933 bits);
5934}
5935
5936static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5937 unsigned int res)
5938{
5939 if ((res >> 26) == ALC880_HP_EVENT)
5940 alc260_hp_3012_automute(codec);
5941}
5942
5943/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005944 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5945 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005946static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005947 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005948 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005949 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005950 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5951 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5952 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5953 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005954 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005955 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5956 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005957 { } /* end */
5958};
5959
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005960/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5961 * versions of the ALC260 don't act on requests to enable mic bias from NID
5962 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5963 * datasheet doesn't mention this restriction. At this stage it's not clear
5964 * whether this behaviour is intentional or is a hardware bug in chip
5965 * revisions available in early 2006. Therefore for now allow the
5966 * "Headphone Jack Mode" control to span all choices, but if it turns out
5967 * that the lack of mic bias for this NID is intentional we could change the
5968 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5969 *
5970 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5971 * don't appear to make the mic bias available from the "line" jack, even
5972 * though the NID used for this jack (0x14) can supply it. The theory is
5973 * that perhaps Acer have included blocking capacitors between the ALC260
5974 * and the output jack. If this turns out to be the case for all such
5975 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5976 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005977 *
5978 * The C20x Tablet series have a mono internal speaker which is controlled
5979 * via the chip's Mono sum widget and pin complex, so include the necessary
5980 * controls for such models. On models without a "mono speaker" the control
5981 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005982 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005983static struct snd_kcontrol_new alc260_acer_mixer[] = {
5984 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5985 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005986 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005987 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005988 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005989 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005990 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005991 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5992 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5993 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5994 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5995 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5996 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5997 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5998 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005999 { } /* end */
6000};
6001
Michael Schwingencc959482009-02-22 18:58:45 +01006002/* Maxdata Favorit 100XS: one output and one input (0x12) jack
6003 */
6004static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
6005 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6006 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
6007 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
6008 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6009 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6010 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6011 { } /* end */
6012};
6013
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006014/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
6015 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
6016 */
6017static struct snd_kcontrol_new alc260_will_mixer[] = {
6018 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6019 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6020 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6021 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6022 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6023 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6024 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6025 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6026 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6027 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006028 { } /* end */
6029};
6030
6031/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
6032 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
6033 */
6034static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
6035 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6036 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6037 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6038 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6039 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6040 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
6041 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
6042 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6043 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6044 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6045 { } /* end */
6046};
6047
Kailang Yangdf694da2005-12-05 19:42:22 +01006048/*
6049 * initialization verbs
6050 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006051static struct hda_verb alc260_init_verbs[] = {
6052 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006053 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006054 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006055 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006056 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006057 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006058 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006059 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006060 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02006061 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006062 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01006063 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006064 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02006065 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006066 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02006067 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006068 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02006069 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6070 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02006071 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006072 /* set connection select to line in (default select for this ADC) */
6073 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02006074 /* mute capture amp left and right */
6075 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6076 /* set connection select to line in (default select for this ADC) */
6077 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02006078 /* set vol=0 Line-Out mixer amp left and right */
6079 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6080 /* unmute pin widget amp left and right (no gain on this amp) */
6081 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6082 /* set vol=0 HP mixer amp left and right */
6083 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6084 /* unmute pin widget amp left and right (no gain on this amp) */
6085 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6086 /* set vol=0 Mono mixer amp left and right */
6087 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6088 /* unmute pin widget amp left and right (no gain on this amp) */
6089 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6090 /* unmute LINE-2 out pin */
6091 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006092 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6093 * Line In 2 = 0x03
6094 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006095 /* mute analog inputs */
6096 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6097 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6098 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6099 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6100 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006101 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006102 /* mute Front out path */
6103 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6104 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6105 /* mute Headphone out path */
6106 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6107 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6108 /* mute Mono out path */
6109 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6110 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006111 { }
6112};
6113
Takashi Iwai474167d2006-05-17 17:17:43 +02006114#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01006115static struct hda_verb alc260_hp_init_verbs[] = {
6116 /* Headphone and output */
6117 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6118 /* mono output */
6119 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6120 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6121 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6122 /* Mic2 (front panel) pin widget for input and vref at 80% */
6123 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6124 /* Line In pin widget for input */
6125 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6126 /* Line-2 pin widget for output */
6127 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6128 /* CD pin widget for input */
6129 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6130 /* unmute amp left and right */
6131 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6132 /* set connection select to line in (default select for this ADC) */
6133 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6134 /* unmute Line-Out mixer amp left and right (volume = 0) */
6135 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6136 /* mute pin widget amp left and right (no gain on this amp) */
6137 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6138 /* unmute HP mixer amp left and right (volume = 0) */
6139 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6140 /* mute pin widget amp left and right (no gain on this amp) */
6141 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006142 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6143 * Line In 2 = 0x03
6144 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006145 /* mute analog inputs */
6146 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6147 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6148 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6149 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6150 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006151 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6152 /* Unmute Front out path */
6153 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6154 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6155 /* Unmute Headphone out path */
6156 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6157 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6158 /* Unmute Mono out path */
6159 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6160 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6161 { }
6162};
Takashi Iwai474167d2006-05-17 17:17:43 +02006163#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006164
6165static struct hda_verb alc260_hp_3013_init_verbs[] = {
6166 /* Line out and output */
6167 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6168 /* mono output */
6169 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6170 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6171 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6172 /* Mic2 (front panel) pin widget for input and vref at 80% */
6173 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6174 /* Line In pin widget for input */
6175 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6176 /* Headphone pin widget for output */
6177 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6178 /* CD pin widget for input */
6179 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6180 /* unmute amp left and right */
6181 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6182 /* set connection select to line in (default select for this ADC) */
6183 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6184 /* unmute Line-Out mixer amp left and right (volume = 0) */
6185 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6186 /* mute pin widget amp left and right (no gain on this amp) */
6187 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6188 /* unmute HP mixer amp left and right (volume = 0) */
6189 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6190 /* mute pin widget amp left and right (no gain on this amp) */
6191 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006192 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6193 * Line In 2 = 0x03
6194 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006195 /* mute analog inputs */
6196 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6197 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6198 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6199 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6200 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006201 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6202 /* Unmute Front out path */
6203 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6204 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6205 /* Unmute Headphone out path */
6206 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6207 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6208 /* Unmute Mono out path */
6209 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6210 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6211 { }
6212};
6213
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006214/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006215 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
6216 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006217 */
6218static struct hda_verb alc260_fujitsu_init_verbs[] = {
6219 /* Disable all GPIOs */
6220 {0x01, AC_VERB_SET_GPIO_MASK, 0},
6221 /* Internal speaker is connected to headphone pin */
6222 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6223 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
6224 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006225 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
6226 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6227 /* Ensure all other unused pins are disabled and muted. */
6228 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6229 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006230 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006231 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006232 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006233 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6234 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6235 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006236
Jonathan Woithef7ace402006-02-28 11:46:14 +01006237 /* Disable digital (SPDIF) pins */
6238 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6239 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006240
Kailang Yangea1fb292008-08-26 12:58:38 +02006241 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01006242 * when acting as an output.
6243 */
6244 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6245
6246 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01006247 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6248 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6249 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6250 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6251 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6252 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6253 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6254 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6255 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006256
Jonathan Woithef7ace402006-02-28 11:46:14 +01006257 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
6258 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6259 /* Unmute Line1 pin widget output buffer since it starts as an output.
6260 * If the pin mode is changed by the user the pin mode control will
6261 * take care of enabling the pin's input/output buffers as needed.
6262 * Therefore there's no need to enable the input buffer at this
6263 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006264 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006265 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02006266 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006267 * mixer ctrl)
6268 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006269 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006270
Jonathan Woithef7ace402006-02-28 11:46:14 +01006271 /* Mute capture amp left and right */
6272 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006273 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01006274 * in (on mic1 pin)
6275 */
6276 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006277
Jonathan Woithef7ace402006-02-28 11:46:14 +01006278 /* Do the same for the second ADC: mute capture input amp and
6279 * set ADC connection to line in (on mic1 pin)
6280 */
6281 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6282 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006283
Jonathan Woithef7ace402006-02-28 11:46:14 +01006284 /* Mute all inputs to mixer widget (even unconnected ones) */
6285 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6286 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6287 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6288 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6289 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6290 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6291 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6292 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006293
6294 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006295};
6296
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006297/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
6298 * similar laptops (adapted from Fujitsu init verbs).
6299 */
6300static struct hda_verb alc260_acer_init_verbs[] = {
6301 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
6302 * the headphone jack. Turn this on and rely on the standard mute
6303 * methods whenever the user wants to turn these outputs off.
6304 */
6305 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6306 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6307 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6308 /* Internal speaker/Headphone jack is connected to Line-out pin */
6309 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6310 /* Internal microphone/Mic jack is connected to Mic1 pin */
6311 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6312 /* Line In jack is connected to Line1 pin */
6313 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01006314 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
6315 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006316 /* Ensure all other unused pins are disabled and muted. */
6317 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6318 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006319 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6320 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6321 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6322 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6323 /* Disable digital (SPDIF) pins */
6324 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6325 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6326
Kailang Yangea1fb292008-08-26 12:58:38 +02006327 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006328 * bus when acting as outputs.
6329 */
6330 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6331 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6332
6333 /* Start with output sum widgets muted and their output gains at min */
6334 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6335 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6336 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6337 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6338 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6339 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6340 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6341 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6342 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6343
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006344 /* Unmute Line-out pin widget amp left and right
6345 * (no equiv mixer ctrl)
6346 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006347 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01006348 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6349 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006350 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6351 * inputs. If the pin mode is changed by the user the pin mode control
6352 * will take care of enabling the pin's input/output buffers as needed.
6353 * Therefore there's no need to enable the input buffer at this
6354 * stage.
6355 */
6356 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6357 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6358
6359 /* Mute capture amp left and right */
6360 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6361 /* Set ADC connection select to match default mixer setting - mic
6362 * (on mic1 pin)
6363 */
6364 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6365
6366 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006367 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006368 */
6369 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006370 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006371
6372 /* Mute all inputs to mixer widget (even unconnected ones) */
6373 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6374 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6375 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6376 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6377 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6378 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6379 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6380 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6381
6382 { }
6383};
6384
Michael Schwingencc959482009-02-22 18:58:45 +01006385/* Initialisation sequence for Maxdata Favorit 100XS
6386 * (adapted from Acer init verbs).
6387 */
6388static struct hda_verb alc260_favorit100_init_verbs[] = {
6389 /* GPIO 0 enables the output jack.
6390 * Turn this on and rely on the standard mute
6391 * methods whenever the user wants to turn these outputs off.
6392 */
6393 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6394 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6395 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6396 /* Line/Mic input jack is connected to Mic1 pin */
6397 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6398 /* Ensure all other unused pins are disabled and muted. */
6399 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6400 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6401 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6402 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6403 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6404 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6405 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6406 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6407 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6408 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6409 /* Disable digital (SPDIF) pins */
6410 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6411 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6412
6413 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6414 * bus when acting as outputs.
6415 */
6416 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6417 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6418
6419 /* Start with output sum widgets muted and their output gains at min */
6420 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6421 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6422 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6423 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6424 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6425 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6426 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6427 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6428 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6429
6430 /* Unmute Line-out pin widget amp left and right
6431 * (no equiv mixer ctrl)
6432 */
6433 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6434 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6435 * inputs. If the pin mode is changed by the user the pin mode control
6436 * will take care of enabling the pin's input/output buffers as needed.
6437 * Therefore there's no need to enable the input buffer at this
6438 * stage.
6439 */
6440 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6441
6442 /* Mute capture amp left and right */
6443 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6444 /* Set ADC connection select to match default mixer setting - mic
6445 * (on mic1 pin)
6446 */
6447 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6448
6449 /* Do similar with the second ADC: mute capture input amp and
6450 * set ADC connection to mic to match ALSA's default state.
6451 */
6452 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6453 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6454
6455 /* Mute all inputs to mixer widget (even unconnected ones) */
6456 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6457 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6458 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6459 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6460 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6461 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6462 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6463 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6464
6465 { }
6466};
6467
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006468static struct hda_verb alc260_will_verbs[] = {
6469 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6470 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6471 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6472 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6473 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6474 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6475 {}
6476};
6477
6478static struct hda_verb alc260_replacer_672v_verbs[] = {
6479 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6480 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6481 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6482
6483 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6484 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6485 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6486
6487 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6488 {}
6489};
6490
6491/* toggle speaker-output according to the hp-jack state */
6492static void alc260_replacer_672v_automute(struct hda_codec *codec)
6493{
6494 unsigned int present;
6495
6496 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006497 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006498 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006499 snd_hda_codec_write_cache(codec, 0x01, 0,
6500 AC_VERB_SET_GPIO_DATA, 1);
6501 snd_hda_codec_write_cache(codec, 0x0f, 0,
6502 AC_VERB_SET_PIN_WIDGET_CONTROL,
6503 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006504 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006505 snd_hda_codec_write_cache(codec, 0x01, 0,
6506 AC_VERB_SET_GPIO_DATA, 0);
6507 snd_hda_codec_write_cache(codec, 0x0f, 0,
6508 AC_VERB_SET_PIN_WIDGET_CONTROL,
6509 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006510 }
6511}
6512
6513static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6514 unsigned int res)
6515{
6516 if ((res >> 26) == ALC880_HP_EVENT)
6517 alc260_replacer_672v_automute(codec);
6518}
6519
Kailang Yang3f878302008-08-26 13:02:23 +02006520static struct hda_verb alc260_hp_dc7600_verbs[] = {
6521 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6522 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6523 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6524 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6525 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6526 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6527 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6528 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6529 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6530 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6531 {}
6532};
6533
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006534/* Test configuration for debugging, modelled after the ALC880 test
6535 * configuration.
6536 */
6537#ifdef CONFIG_SND_DEBUG
6538static hda_nid_t alc260_test_dac_nids[1] = {
6539 0x02,
6540};
6541static hda_nid_t alc260_test_adc_nids[2] = {
6542 0x04, 0x05,
6543};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006544/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006545 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006546 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006547 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006548static struct hda_input_mux alc260_test_capture_sources[2] = {
6549 {
6550 .num_items = 7,
6551 .items = {
6552 { "MIC1 pin", 0x0 },
6553 { "MIC2 pin", 0x1 },
6554 { "LINE1 pin", 0x2 },
6555 { "LINE2 pin", 0x3 },
6556 { "CD pin", 0x4 },
6557 { "LINE-OUT pin", 0x5 },
6558 { "HP-OUT pin", 0x6 },
6559 },
6560 },
6561 {
6562 .num_items = 8,
6563 .items = {
6564 { "MIC1 pin", 0x0 },
6565 { "MIC2 pin", 0x1 },
6566 { "LINE1 pin", 0x2 },
6567 { "LINE2 pin", 0x3 },
6568 { "CD pin", 0x4 },
6569 { "Mixer", 0x5 },
6570 { "LINE-OUT pin", 0x6 },
6571 { "HP-OUT pin", 0x7 },
6572 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006573 },
6574};
6575static struct snd_kcontrol_new alc260_test_mixer[] = {
6576 /* Output driver widgets */
6577 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6578 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6579 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6580 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6581 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6582 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6583
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006584 /* Modes for retasking pin widgets
6585 * Note: the ALC260 doesn't seem to act on requests to enable mic
6586 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6587 * mention this restriction. At this stage it's not clear whether
6588 * this behaviour is intentional or is a hardware bug in chip
6589 * revisions available at least up until early 2006. Therefore for
6590 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6591 * choices, but if it turns out that the lack of mic bias for these
6592 * NIDs is intentional we could change their modes from
6593 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6594 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006595 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6596 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6597 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6598 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6599 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6600 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6601
6602 /* Loopback mixer controls */
6603 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6604 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6605 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6606 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6607 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6608 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6609 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6610 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6611 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6612 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006613 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6614 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6615 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6616 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006617
6618 /* Controls for GPIO pins, assuming they are configured as outputs */
6619 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6620 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6621 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6622 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6623
Jonathan Woithe92621f12006-02-28 11:47:47 +01006624 /* Switches to allow the digital IO pins to be enabled. The datasheet
6625 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006626 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006627 */
6628 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6629 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6630
Jonathan Woithef8225f62008-01-08 12:16:54 +01006631 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6632 * this output to turn on an external amplifier.
6633 */
6634 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6635 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6636
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006637 { } /* end */
6638};
6639static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006640 /* Enable all GPIOs as outputs with an initial value of 0 */
6641 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6642 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6643 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6644
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006645 /* Enable retasking pins as output, initially without power amp */
6646 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6647 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6648 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6649 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6650 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6651 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6652
Jonathan Woithe92621f12006-02-28 11:47:47 +01006653 /* Disable digital (SPDIF) pins initially, but users can enable
6654 * them via a mixer switch. In the case of SPDIF-out, this initverb
6655 * payload also sets the generation to 0, output to be in "consumer"
6656 * PCM format, copyright asserted, no pre-emphasis and no validity
6657 * control.
6658 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006659 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6660 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6661
Kailang Yangea1fb292008-08-26 12:58:38 +02006662 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006663 * OUT1 sum bus when acting as an output.
6664 */
6665 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6666 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6667 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6668 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6669
6670 /* Start with output sum widgets muted and their output gains at min */
6671 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6672 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6673 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6674 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6675 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6676 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6677 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6678 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6679 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6680
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006681 /* Unmute retasking pin widget output buffers since the default
6682 * state appears to be output. As the pin mode is changed by the
6683 * user the pin mode control will take care of enabling the pin's
6684 * input/output buffers as needed.
6685 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006686 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6687 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6688 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6689 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6690 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6691 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6692 /* Also unmute the mono-out pin widget */
6693 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6694
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006695 /* Mute capture amp left and right */
6696 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006697 /* Set ADC connection select to match default mixer setting (mic1
6698 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006699 */
6700 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6701
6702 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006703 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006704 */
6705 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6706 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6707
6708 /* Mute all inputs to mixer widget (even unconnected ones) */
6709 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6710 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6711 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6712 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6713 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6714 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6715 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6716 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6717
6718 { }
6719};
6720#endif
6721
Takashi Iwai63300792008-01-24 15:31:36 +01006722#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6723#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006724
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006725#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6726#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6727
Kailang Yangdf694da2005-12-05 19:42:22 +01006728/*
6729 * for BIOS auto-configuration
6730 */
6731
6732static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006733 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006734{
6735 hda_nid_t nid_vol;
6736 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006737 int err;
6738
6739 if (nid >= 0x0f && nid < 0x11) {
6740 nid_vol = nid - 0x7;
6741 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6742 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6743 } else if (nid == 0x11) {
6744 nid_vol = nid - 0x7;
6745 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6746 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6747 } else if (nid >= 0x12 && nid <= 0x15) {
6748 nid_vol = 0x08;
6749 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6750 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6751 } else
6752 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006753
Takashi Iwai863b4512008-10-21 17:01:47 +02006754 if (!(*vol_bits & (1 << nid_vol))) {
6755 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006756 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006757 if (err < 0)
6758 return err;
6759 *vol_bits |= (1 << nid_vol);
6760 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006761 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006762 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006763 return err;
6764 return 1;
6765}
6766
6767/* add playback controls from the parsed DAC table */
6768static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6769 const struct auto_pin_cfg *cfg)
6770{
6771 hda_nid_t nid;
6772 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006773 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006774
6775 spec->multiout.num_dacs = 1;
6776 spec->multiout.dac_nids = spec->private_dac_nids;
6777 spec->multiout.dac_nids[0] = 0x02;
6778
6779 nid = cfg->line_out_pins[0];
6780 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006781 const char *pfx;
6782 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6783 pfx = "Master";
6784 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6785 pfx = "Speaker";
6786 else
6787 pfx = "Front";
6788 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006789 if (err < 0)
6790 return err;
6791 }
6792
Takashi Iwai82bc9552006-03-21 11:24:42 +01006793 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006794 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006795 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006796 if (err < 0)
6797 return err;
6798 }
6799
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006800 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006801 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006802 err = alc260_add_playback_controls(spec, nid, "Headphone",
6803 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006804 if (err < 0)
6805 return err;
6806 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006807 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006808}
6809
6810/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006811static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006812 const struct auto_pin_cfg *cfg)
6813{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006814 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006815}
6816
6817static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6818 hda_nid_t nid, int pin_type,
6819 int sel_idx)
6820{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006821 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006822 /* need the manual connection? */
6823 if (nid >= 0x12) {
6824 int idx = nid - 0x12;
6825 snd_hda_codec_write(codec, idx + 0x0b, 0,
6826 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006827 }
6828}
6829
6830static void alc260_auto_init_multi_out(struct hda_codec *codec)
6831{
6832 struct alc_spec *spec = codec->spec;
6833 hda_nid_t nid;
6834
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006835 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006836 if (nid) {
6837 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6838 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6839 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006840
Takashi Iwai82bc9552006-03-21 11:24:42 +01006841 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006842 if (nid)
6843 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6844
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006845 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006846 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006847 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006848}
Kailang Yangdf694da2005-12-05 19:42:22 +01006849
6850#define ALC260_PIN_CD_NID 0x16
6851static void alc260_auto_init_analog_input(struct hda_codec *codec)
6852{
6853 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006854 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +01006855 int i;
6856
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006857 for (i = 0; i < cfg->num_inputs; i++) {
6858 hda_nid_t nid = cfg->inputs[i].pin;
Kailang Yangdf694da2005-12-05 19:42:22 +01006859 if (nid >= 0x12) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02006860 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006861 if (nid != ALC260_PIN_CD_NID &&
6862 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006863 snd_hda_codec_write(codec, nid, 0,
6864 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006865 AMP_OUT_MUTE);
6866 }
6867 }
6868}
6869
Takashi Iwai7f311a42010-04-09 17:32:23 +02006870#define alc260_auto_init_input_src alc880_auto_init_input_src
6871
Kailang Yangdf694da2005-12-05 19:42:22 +01006872/*
6873 * generic initialization of ADC, input mixers and output mixers
6874 */
6875static struct hda_verb alc260_volume_init_verbs[] = {
6876 /*
6877 * Unmute ADC0-1 and set the default input to mic-in
6878 */
6879 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6880 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6881 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6882 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006883
Kailang Yangdf694da2005-12-05 19:42:22 +01006884 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6885 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006886 * Note: PASD motherboards uses the Line In 2 as the input for
6887 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006888 */
6889 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006890 /* mute analog inputs */
6891 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6892 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6893 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6894 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6895 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006896
6897 /*
6898 * Set up output mixers (0x08 - 0x0a)
6899 */
6900 /* set vol=0 to output mixers */
6901 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6902 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6903 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6904 /* set up input amps for analog loopback */
6905 /* Amp Indices: DAC = 0, mixer = 1 */
6906 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6907 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6908 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6909 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6910 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6911 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006912
Kailang Yangdf694da2005-12-05 19:42:22 +01006913 { }
6914};
6915
6916static int alc260_parse_auto_config(struct hda_codec *codec)
6917{
6918 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006919 int err;
6920 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6921
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006922 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6923 alc260_ignore);
6924 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006925 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006926 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6927 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006928 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006929 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006930 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006931 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006932 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006933 return err;
6934
6935 spec->multiout.max_channels = 2;
6936
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006937 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006938 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006939 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006940 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006941
Takashi Iwaid88897e2008-10-31 15:01:37 +01006942 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006943
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006944 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006945 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006946
Kailang Yang6227cdc2010-02-25 08:36:52 +01006947 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006948
Kailang Yangdf694da2005-12-05 19:42:22 +01006949 return 1;
6950}
6951
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006952/* additional initialization for auto-configuration model */
6953static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006954{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006955 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006956 alc260_auto_init_multi_out(codec);
6957 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02006958 alc260_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02006959 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006960 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006961 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006962}
6963
Takashi Iwaicb53c622007-08-10 17:21:45 +02006964#ifdef CONFIG_SND_HDA_POWER_SAVE
6965static struct hda_amp_list alc260_loopbacks[] = {
6966 { 0x07, HDA_INPUT, 0 },
6967 { 0x07, HDA_INPUT, 1 },
6968 { 0x07, HDA_INPUT, 2 },
6969 { 0x07, HDA_INPUT, 3 },
6970 { 0x07, HDA_INPUT, 4 },
6971 { } /* end */
6972};
6973#endif
6974
Kailang Yangdf694da2005-12-05 19:42:22 +01006975/*
Takashi Iwaifc091762010-08-04 23:53:36 +02006976 * Pin config fixes
6977 */
6978enum {
6979 PINFIX_HP_DC5750,
6980};
6981
Takashi Iwaifc091762010-08-04 23:53:36 +02006982static const struct alc_fixup alc260_fixups[] = {
6983 [PINFIX_HP_DC5750] = {
Takashi Iwai73413b12010-08-30 09:39:57 +02006984 .pins = (const struct alc_pincfg[]) {
6985 { 0x11, 0x90130110 }, /* speaker */
6986 { }
6987 }
Takashi Iwaifc091762010-08-04 23:53:36 +02006988 },
6989};
6990
6991static struct snd_pci_quirk alc260_fixup_tbl[] = {
6992 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
6993 {}
6994};
6995
6996/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006997 * ALC260 configurations
6998 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006999static const char *alc260_models[ALC260_MODEL_LAST] = {
7000 [ALC260_BASIC] = "basic",
7001 [ALC260_HP] = "hp",
7002 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02007003 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007004 [ALC260_FUJITSU_S702X] = "fujitsu",
7005 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007006 [ALC260_WILL] = "will",
7007 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01007008 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007009#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007010 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007011#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007012 [ALC260_AUTO] = "auto",
7013};
7014
7015static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01007016 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05007017 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007018 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01007019 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01007020 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01007021 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007022 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02007023 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02007024 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007025 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
7026 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
7027 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
7028 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
7029 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
7030 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
7031 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
7032 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
7033 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007034 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007035 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02007036 {}
7037};
7038
Kailang Yangdf694da2005-12-05 19:42:22 +01007039static struct alc_config_preset alc260_presets[] = {
7040 [ALC260_BASIC] = {
7041 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007042 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007043 .init_verbs = { alc260_init_verbs },
7044 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7045 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007046 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01007047 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007048 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7049 .channel_mode = alc260_modes,
7050 .input_mux = &alc260_capture_source,
7051 },
7052 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01007053 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007054 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007055 .init_verbs = { alc260_init_verbs,
7056 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007057 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7058 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007059 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7060 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007061 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7062 .channel_mode = alc260_modes,
7063 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007064 .unsol_event = alc260_hp_unsol_event,
7065 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007066 },
Kailang Yang3f878302008-08-26 13:02:23 +02007067 [ALC260_HP_DC7600] = {
7068 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007069 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02007070 .init_verbs = { alc260_init_verbs,
7071 alc260_hp_dc7600_verbs },
7072 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7073 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007074 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7075 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02007076 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7077 .channel_mode = alc260_modes,
7078 .input_mux = &alc260_capture_source,
7079 .unsol_event = alc260_hp_3012_unsol_event,
7080 .init_hook = alc260_hp_3012_automute,
7081 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007082 [ALC260_HP_3013] = {
7083 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007084 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007085 .init_verbs = { alc260_hp_3013_init_verbs,
7086 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007087 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7088 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007089 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7090 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007091 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7092 .channel_mode = alc260_modes,
7093 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007094 .unsol_event = alc260_hp_3013_unsol_event,
7095 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007096 },
7097 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007098 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007099 .init_verbs = { alc260_fujitsu_init_verbs },
7100 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7101 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01007102 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7103 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007104 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7105 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007106 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
7107 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01007108 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007109 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007110 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007111 .init_verbs = { alc260_acer_init_verbs },
7112 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7113 .dac_nids = alc260_dac_nids,
7114 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7115 .adc_nids = alc260_dual_adc_nids,
7116 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7117 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007118 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
7119 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007120 },
Michael Schwingencc959482009-02-22 18:58:45 +01007121 [ALC260_FAVORIT100] = {
7122 .mixers = { alc260_favorit100_mixer },
7123 .init_verbs = { alc260_favorit100_init_verbs },
7124 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7125 .dac_nids = alc260_dac_nids,
7126 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7127 .adc_nids = alc260_dual_adc_nids,
7128 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7129 .channel_mode = alc260_modes,
7130 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
7131 .input_mux = alc260_favorit100_capture_sources,
7132 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007133 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007134 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007135 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
7136 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7137 .dac_nids = alc260_dac_nids,
7138 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7139 .adc_nids = alc260_adc_nids,
7140 .dig_out_nid = ALC260_DIGOUT_NID,
7141 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7142 .channel_mode = alc260_modes,
7143 .input_mux = &alc260_capture_source,
7144 },
7145 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007146 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007147 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
7148 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7149 .dac_nids = alc260_dac_nids,
7150 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7151 .adc_nids = alc260_adc_nids,
7152 .dig_out_nid = ALC260_DIGOUT_NID,
7153 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7154 .channel_mode = alc260_modes,
7155 .input_mux = &alc260_capture_source,
7156 .unsol_event = alc260_replacer_672v_unsol_event,
7157 .init_hook = alc260_replacer_672v_automute,
7158 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007159#ifdef CONFIG_SND_DEBUG
7160 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007161 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007162 .init_verbs = { alc260_test_init_verbs },
7163 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
7164 .dac_nids = alc260_test_dac_nids,
7165 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
7166 .adc_nids = alc260_test_adc_nids,
7167 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7168 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007169 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
7170 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007171 },
7172#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01007173};
7174
Linus Torvalds1da177e2005-04-16 15:20:36 -07007175static int patch_alc260(struct hda_codec *codec)
7176{
7177 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007178 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007179
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007180 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007181 if (spec == NULL)
7182 return -ENOMEM;
7183
7184 codec->spec = spec;
7185
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007186 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
7187 alc260_models,
7188 alc260_cfg_tbl);
7189 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02007190 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02007191 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01007192 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02007193 }
7194
Takashi Iwaifc091762010-08-04 23:53:36 +02007195 if (board_config == ALC260_AUTO)
7196 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 1);
7197
Kailang Yangdf694da2005-12-05 19:42:22 +01007198 if (board_config == ALC260_AUTO) {
7199 /* automatic parse from the BIOS config */
7200 err = alc260_parse_auto_config(codec);
7201 if (err < 0) {
7202 alc_free(codec);
7203 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007204 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007205 printk(KERN_INFO
7206 "hda_codec: Cannot set up configuration "
7207 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007208 board_config = ALC260_BASIC;
7209 }
Takashi Iwai16ded522005-06-10 19:58:24 +02007210 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007211
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007212 err = snd_hda_attach_beep_device(codec, 0x1);
7213 if (err < 0) {
7214 alc_free(codec);
7215 return err;
7216 }
7217
Kailang Yangdf694da2005-12-05 19:42:22 +01007218 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02007219 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007220
Linus Torvalds1da177e2005-04-16 15:20:36 -07007221 spec->stream_analog_playback = &alc260_pcm_analog_playback;
7222 spec->stream_analog_capture = &alc260_pcm_analog_capture;
Jonathan Woithe53bacfb2010-08-08 00:17:05 +09307223 spec->stream_analog_alt_capture = &alc260_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007224
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007225 spec->stream_digital_playback = &alc260_pcm_digital_playback;
7226 spec->stream_digital_capture = &alc260_pcm_digital_capture;
7227
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007228 if (!spec->adc_nids && spec->input_mux) {
7229 /* check whether NID 0x04 is valid */
7230 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02007231 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007232 /* get type */
7233 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
7234 spec->adc_nids = alc260_adc_nids_alt;
7235 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
7236 } else {
7237 spec->adc_nids = alc260_adc_nids;
7238 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
7239 }
7240 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02007241 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007242 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007243
Takashi Iwaifc091762010-08-04 23:53:36 +02007244 if (board_config == ALC260_AUTO)
7245 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 0);
7246
Takashi Iwai2134ea42008-01-10 16:53:55 +01007247 spec->vmaster_nid = 0x08;
7248
Linus Torvalds1da177e2005-04-16 15:20:36 -07007249 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007250 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007251 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007252#ifdef CONFIG_SND_HDA_POWER_SAVE
7253 if (!spec->loopback.amplist)
7254 spec->loopback.amplist = alc260_loopbacks;
7255#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07007256
7257 return 0;
7258}
7259
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007260
Linus Torvalds1da177e2005-04-16 15:20:36 -07007261/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007262 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07007263 *
7264 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
7265 * configuration. Each pin widget can choose any input DACs and a mixer.
7266 * Each ADC is connected from a mixer of all inputs. This makes possible
7267 * 6-channel independent captures.
7268 *
7269 * In addition, an independent DAC for the multi-playback (not used in this
7270 * driver yet).
7271 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007272#define ALC882_DIGOUT_NID 0x06
7273#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02007274#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
7275#define ALC883_DIGIN_NID ALC882_DIGIN_NID
7276#define ALC1200_DIGOUT_NID 0x10
7277
Linus Torvalds1da177e2005-04-16 15:20:36 -07007278
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01007279static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007280 { 8, NULL }
7281};
7282
Takashi Iwai4953550a2009-06-30 15:28:30 +02007283/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007284static hda_nid_t alc882_dac_nids[4] = {
7285 /* front, rear, clfe, rear_surr */
7286 0x02, 0x03, 0x04, 0x05
7287};
Takashi Iwai4953550a2009-06-30 15:28:30 +02007288#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007289
Takashi Iwai4953550a2009-06-30 15:28:30 +02007290/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01007291#define alc882_adc_nids alc880_adc_nids
7292#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02007293#define alc883_adc_nids alc882_adc_nids_alt
7294static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
7295static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
7296#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007297
Takashi Iwaie1406342008-02-11 18:32:32 +01007298static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
7299static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007300#define alc883_capsrc_nids alc882_capsrc_nids_alt
7301static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7302#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01007303
Linus Torvalds1da177e2005-04-16 15:20:36 -07007304/* input MUX */
7305/* FIXME: should be a matrix-type input source selection */
7306
7307static struct hda_input_mux alc882_capture_source = {
7308 .num_items = 4,
7309 .items = {
7310 { "Mic", 0x0 },
7311 { "Front Mic", 0x1 },
7312 { "Line", 0x2 },
7313 { "CD", 0x4 },
7314 },
7315};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007316
Takashi Iwai4953550a2009-06-30 15:28:30 +02007317#define alc883_capture_source alc882_capture_source
7318
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007319static struct hda_input_mux alc889_capture_source = {
7320 .num_items = 3,
7321 .items = {
7322 { "Front Mic", 0x0 },
7323 { "Mic", 0x3 },
7324 { "Line", 0x2 },
7325 },
7326};
7327
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007328static struct hda_input_mux mb5_capture_source = {
7329 .num_items = 3,
7330 .items = {
7331 { "Mic", 0x1 },
Alex Murrayb8f171e2010-06-14 12:08:43 +09307332 { "Line", 0x7 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007333 { "CD", 0x4 },
7334 },
7335};
7336
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007337static struct hda_input_mux macmini3_capture_source = {
7338 .num_items = 2,
7339 .items = {
7340 { "Line", 0x2 },
7341 { "CD", 0x4 },
7342 },
7343};
7344
Takashi Iwai4953550a2009-06-30 15:28:30 +02007345static struct hda_input_mux alc883_3stack_6ch_intel = {
7346 .num_items = 4,
7347 .items = {
7348 { "Mic", 0x1 },
7349 { "Front Mic", 0x0 },
7350 { "Line", 0x2 },
7351 { "CD", 0x4 },
7352 },
7353};
7354
7355static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7356 .num_items = 2,
7357 .items = {
7358 { "Mic", 0x1 },
7359 { "Line", 0x2 },
7360 },
7361};
7362
7363static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7364 .num_items = 4,
7365 .items = {
7366 { "Mic", 0x0 },
David Henningsson150b4322010-07-29 14:46:42 +02007367 { "Int Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007368 { "Line", 0x2 },
7369 { "CD", 0x4 },
7370 },
7371};
7372
7373static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7374 .num_items = 2,
7375 .items = {
7376 { "Mic", 0x0 },
7377 { "Int Mic", 0x1 },
7378 },
7379};
7380
7381static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7382 .num_items = 3,
7383 .items = {
7384 { "Mic", 0x0 },
7385 { "Front Mic", 0x1 },
7386 { "Line", 0x4 },
7387 },
7388};
7389
7390static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7391 .num_items = 2,
7392 .items = {
7393 { "Mic", 0x0 },
7394 { "Line", 0x2 },
7395 },
7396};
7397
7398static struct hda_input_mux alc889A_mb31_capture_source = {
7399 .num_items = 2,
7400 .items = {
7401 { "Mic", 0x0 },
7402 /* Front Mic (0x01) unused */
7403 { "Line", 0x2 },
7404 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007405 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007406 },
7407};
7408
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007409static struct hda_input_mux alc889A_imac91_capture_source = {
7410 .num_items = 2,
7411 .items = {
7412 { "Mic", 0x01 },
7413 { "Line", 0x2 }, /* Not sure! */
7414 },
7415};
7416
Takashi Iwai4953550a2009-06-30 15:28:30 +02007417/*
7418 * 2ch mode
7419 */
7420static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7421 { 2, NULL }
7422};
7423
Kailang Yangdf694da2005-12-05 19:42:22 +01007424/*
Kailang Yang272a5272007-05-14 11:00:38 +02007425 * 2ch mode
7426 */
7427static struct hda_verb alc882_3ST_ch2_init[] = {
7428 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7429 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7430 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7431 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7432 { } /* end */
7433};
7434
7435/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007436 * 4ch mode
7437 */
7438static struct hda_verb alc882_3ST_ch4_init[] = {
7439 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7440 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7441 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7442 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7443 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7444 { } /* end */
7445};
7446
7447/*
Kailang Yang272a5272007-05-14 11:00:38 +02007448 * 6ch mode
7449 */
7450static struct hda_verb alc882_3ST_ch6_init[] = {
7451 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7452 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7453 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7454 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7455 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7456 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7457 { } /* end */
7458};
7459
Takashi Iwai4953550a2009-06-30 15:28:30 +02007460static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007461 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007462 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007463 { 6, alc882_3ST_ch6_init },
7464};
7465
Takashi Iwai4953550a2009-06-30 15:28:30 +02007466#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7467
Kailang Yang272a5272007-05-14 11:00:38 +02007468/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307469 * 2ch mode
7470 */
7471static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7472 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7473 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7474 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7475 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7476 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7477 { } /* end */
7478};
7479
7480/*
7481 * 4ch mode
7482 */
7483static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7484 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7485 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7486 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7487 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7488 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7489 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7490 { } /* end */
7491};
7492
7493/*
7494 * 6ch mode
7495 */
7496static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7497 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7498 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7499 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7500 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7501 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7502 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7503 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7504 { } /* end */
7505};
7506
7507static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7508 { 2, alc883_3ST_ch2_clevo_init },
7509 { 4, alc883_3ST_ch4_clevo_init },
7510 { 6, alc883_3ST_ch6_clevo_init },
7511};
7512
7513
7514/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007515 * 6ch mode
7516 */
7517static struct hda_verb alc882_sixstack_ch6_init[] = {
7518 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7519 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7520 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7521 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7522 { } /* end */
7523};
7524
7525/*
7526 * 8ch mode
7527 */
7528static struct hda_verb alc882_sixstack_ch8_init[] = {
7529 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7530 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7531 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7532 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7533 { } /* end */
7534};
7535
7536static struct hda_channel_mode alc882_sixstack_modes[2] = {
7537 { 6, alc882_sixstack_ch6_init },
7538 { 8, alc882_sixstack_ch8_init },
7539};
7540
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007541
7542/* Macbook Air 2,1 */
7543
7544static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7545 { 2, NULL },
7546};
7547
Takashi Iwai87350ad2007-08-16 18:19:38 +02007548/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007549 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007550 */
7551
7552/*
7553 * 2ch mode
7554 */
7555static struct hda_verb alc885_mbp_ch2_init[] = {
7556 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7557 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7558 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7559 { } /* end */
7560};
7561
7562/*
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007563 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007564 */
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007565static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007566 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7567 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7568 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7569 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7570 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7571 { } /* end */
7572};
7573
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007574static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007575 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007576 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007577};
7578
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007579/*
7580 * 2ch
7581 * Speakers/Woofer/HP = Front
7582 * LineIn = Input
7583 */
7584static struct hda_verb alc885_mb5_ch2_init[] = {
7585 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7586 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7587 { } /* end */
7588};
7589
7590/*
7591 * 6ch mode
7592 * Speakers/HP = Front
7593 * Woofer = LFE
7594 * LineIn = Surround
7595 */
7596static struct hda_verb alc885_mb5_ch6_init[] = {
7597 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7598 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7599 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7600 { } /* end */
7601};
7602
7603static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7604 { 2, alc885_mb5_ch2_init },
7605 { 6, alc885_mb5_ch6_init },
7606};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007607
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007608#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007609
7610/*
7611 * 2ch mode
7612 */
7613static struct hda_verb alc883_4ST_ch2_init[] = {
7614 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7615 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7616 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7617 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7618 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7619 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7620 { } /* end */
7621};
7622
7623/*
7624 * 4ch mode
7625 */
7626static struct hda_verb alc883_4ST_ch4_init[] = {
7627 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7628 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7629 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7630 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7631 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7632 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7633 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7634 { } /* end */
7635};
7636
7637/*
7638 * 6ch mode
7639 */
7640static struct hda_verb alc883_4ST_ch6_init[] = {
7641 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7642 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7643 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7644 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7645 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7646 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7647 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7648 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7649 { } /* end */
7650};
7651
7652/*
7653 * 8ch mode
7654 */
7655static struct hda_verb alc883_4ST_ch8_init[] = {
7656 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7657 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7658 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7659 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7660 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7661 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7662 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7663 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7664 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7665 { } /* end */
7666};
7667
7668static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7669 { 2, alc883_4ST_ch2_init },
7670 { 4, alc883_4ST_ch4_init },
7671 { 6, alc883_4ST_ch6_init },
7672 { 8, alc883_4ST_ch8_init },
7673};
7674
7675
7676/*
7677 * 2ch mode
7678 */
7679static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7680 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7681 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7682 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7683 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7684 { } /* end */
7685};
7686
7687/*
7688 * 4ch mode
7689 */
7690static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7691 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7692 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7693 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7694 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7695 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7696 { } /* end */
7697};
7698
7699/*
7700 * 6ch mode
7701 */
7702static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7703 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7704 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7705 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7706 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7707 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7708 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7709 { } /* end */
7710};
7711
7712static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7713 { 2, alc883_3ST_ch2_intel_init },
7714 { 4, alc883_3ST_ch4_intel_init },
7715 { 6, alc883_3ST_ch6_intel_init },
7716};
7717
7718/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007719 * 2ch mode
7720 */
7721static struct hda_verb alc889_ch2_intel_init[] = {
7722 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7723 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7724 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7725 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7726 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7727 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7728 { } /* end */
7729};
7730
7731/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007732 * 6ch mode
7733 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007734static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007735 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7736 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7737 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7738 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7739 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007740 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7741 { } /* end */
7742};
7743
7744/*
7745 * 8ch mode
7746 */
7747static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007748 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7749 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7750 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7751 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7752 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007753 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7754 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007755 { } /* end */
7756};
7757
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007758static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7759 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007760 { 6, alc889_ch6_intel_init },
7761 { 8, alc889_ch8_intel_init },
7762};
7763
7764/*
7765 * 6ch mode
7766 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007767static struct hda_verb alc883_sixstack_ch6_init[] = {
7768 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7769 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7770 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7771 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7772 { } /* end */
7773};
7774
7775/*
7776 * 8ch mode
7777 */
7778static struct hda_verb alc883_sixstack_ch8_init[] = {
7779 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7780 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7781 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7782 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7783 { } /* end */
7784};
7785
7786static struct hda_channel_mode alc883_sixstack_modes[2] = {
7787 { 6, alc883_sixstack_ch6_init },
7788 { 8, alc883_sixstack_ch8_init },
7789};
7790
7791
Linus Torvalds1da177e2005-04-16 15:20:36 -07007792/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7793 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7794 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007795static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007796 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007797 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007798 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007799 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007800 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7801 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007802 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7803 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007804 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007805 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007806 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7807 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7808 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7809 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7810 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7811 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007812 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007813 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7814 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007815 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007816 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007817 { } /* end */
7818};
7819
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007820/* Macbook Air 2,1 same control for HP and internal Speaker */
7821
7822static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7823 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7824 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7825 { }
7826};
7827
7828
Takashi Iwai87350ad2007-08-16 18:19:38 +02007829static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007830 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7831 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7832 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7833 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7834 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007835 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7836 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007837 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7838 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007839 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007840 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7841 { } /* end */
7842};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007843
7844static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007845 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7846 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7847 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7848 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7849 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7850 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307851 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7852 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Alex Murrayb8f171e2010-06-14 12:08:43 +09307853 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7854 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007855 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7856 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7857 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7858 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7859 { } /* end */
7860};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007861
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007862static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7863 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7864 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7865 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7866 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7867 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7868 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7869 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7870 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7871 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7872 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
7873 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7874 { } /* end */
7875};
7876
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007877static struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007878 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7879 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007880 { } /* end */
7881};
7882
7883
Kailang Yangbdd148a2007-05-08 15:19:08 +02007884static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7885 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7886 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7887 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7888 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7889 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7890 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7891 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7892 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7893 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007894 { } /* end */
7895};
7896
Kailang Yang272a5272007-05-14 11:00:38 +02007897static struct snd_kcontrol_new alc882_targa_mixer[] = {
7898 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7899 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7900 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7901 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7902 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7903 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7904 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7905 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7906 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007907 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007908 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7909 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007910 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007911 { } /* end */
7912};
7913
7914/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7915 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7916 */
7917static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7918 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7919 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7920 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7921 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7922 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7923 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7924 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7925 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7926 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7927 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7928 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7929 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007930 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007931 { } /* end */
7932};
7933
Takashi Iwai914759b2007-09-06 14:52:04 +02007934static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7935 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7936 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7937 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7938 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7939 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7940 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7941 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7942 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7943 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7944 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007945 { } /* end */
7946};
7947
Kailang Yangdf694da2005-12-05 19:42:22 +01007948static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7949 {
7950 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7951 .name = "Channel Mode",
7952 .info = alc_ch_mode_info,
7953 .get = alc_ch_mode_get,
7954 .put = alc_ch_mode_put,
7955 },
7956 { } /* end */
7957};
7958
Takashi Iwai4953550a2009-06-30 15:28:30 +02007959static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007960 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007961 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7962 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007963 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007964 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7965 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007966 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007967 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7968 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007969 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007970 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7971 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007972
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007973 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007974 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007975 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007976 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007977 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007978 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007979 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007980 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007981 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007982 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007983 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007984 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007985 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007986 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007987 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007988 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007989 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007990 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007991 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7992 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007993 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007994 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7995 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007996 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007997 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7998 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7999 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8000 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8001 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008002 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008003 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008004
8005 /* FIXME: use matrix-type input source selection */
8006 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008007 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008008 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008009 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008010 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02008011 /* ADC2: mute amp left and right */
8012 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008013 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02008014 /* ADC3: mute amp left and right */
8015 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008016 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008017
8018 { }
8019};
8020
Takashi Iwai4953550a2009-06-30 15:28:30 +02008021static struct hda_verb alc882_adc1_init_verbs[] = {
8022 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8023 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8024 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8025 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8026 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8027 /* ADC1: mute amp left and right */
8028 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8029 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8030 { }
8031};
8032
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008033static struct hda_verb alc882_eapd_verbs[] = {
8034 /* change to EAPD mode */
8035 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008036 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008037 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008038};
8039
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008040static struct hda_verb alc889_eapd_verbs[] = {
8041 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8042 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8043 { }
8044};
8045
Wu Fengguang6732bd02009-07-30 09:19:14 +02008046static struct hda_verb alc_hp15_unsol_verbs[] = {
8047 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8048 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8049 {}
8050};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008051
8052static struct hda_verb alc885_init_verbs[] = {
8053 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01008054 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8055 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008056 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008057 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8058 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008059 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008060 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8061 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008062 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008063 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8064 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008065
8066 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02008067 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008068 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8069 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8070 /* Front Pin: output 0 (0x0c) */
8071 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8072 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8073 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8074 /* Rear Pin: output 1 (0x0d) */
8075 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8076 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8077 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
8078 /* CLFE Pin: output 2 (0x0e) */
8079 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8080 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8081 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8082 /* Side Pin: output 3 (0x0f) */
8083 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8084 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8085 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8086 /* Mic (rear) pin: input vref at 80% */
8087 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8088 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8089 /* Front Mic pin: input vref at 80% */
8090 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8091 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8092 /* Line In pin: input */
8093 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8094 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8095
8096 /* Mixer elements: 0x18, , 0x1a, 0x1b */
8097 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01008098 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008099 /* Input mixer2 */
8100 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008101 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008102 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008103 /* ADC2: mute amp left and right */
8104 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8105 /* ADC3: mute amp left and right */
8106 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8107
8108 { }
8109};
8110
8111static struct hda_verb alc885_init_input_verbs[] = {
8112 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8113 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8114 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8115 { }
8116};
8117
8118
8119/* Unmute Selector 24h and set the default input to front mic */
8120static struct hda_verb alc889_init_input_verbs[] = {
8121 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
8122 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8123 { }
8124};
8125
8126
Takashi Iwai4953550a2009-06-30 15:28:30 +02008127#define alc883_init_verbs alc882_base_init_verbs
8128
Tobin Davis9102cd12006-12-15 10:02:12 +01008129/* Mac Pro test */
8130static struct snd_kcontrol_new alc882_macpro_mixer[] = {
8131 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8132 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8133 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
8134 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8135 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008136 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01008137 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
8138 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008139 */
Tobin Davis9102cd12006-12-15 10:02:12 +01008140 { } /* end */
8141};
8142
8143static struct hda_verb alc882_macpro_init_verbs[] = {
8144 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8145 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8146 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8147 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8148 /* Front Pin: output 0 (0x0c) */
8149 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8150 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8151 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8152 /* Front Mic pin: input vref at 80% */
8153 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8154 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8155 /* Speaker: output */
8156 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8157 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8158 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
8159 /* Headphone output (output 0 - 0x0c) */
8160 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8161 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8162 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8163
8164 /* FIXME: use matrix-type input source selection */
8165 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8166 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8167 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8168 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8169 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8170 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8171 /* Input mixer2 */
8172 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8173 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8174 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8175 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8176 /* Input mixer3 */
8177 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8178 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8179 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8180 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8181 /* ADC1: mute amp left and right */
8182 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8183 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8184 /* ADC2: mute amp left and right */
8185 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8186 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8187 /* ADC3: mute amp left and right */
8188 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8189 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8190
8191 { }
8192};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008193
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008194/* Macbook 5,1 */
8195static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008196 /* DACs */
8197 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8198 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8199 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8200 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008201 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008202 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8203 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8204 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008205 /* Surround mixer */
8206 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8207 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8208 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8209 /* LFE mixer */
8210 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8211 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8212 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8213 /* HP mixer */
8214 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8215 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8216 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8217 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008218 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8219 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008220 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8221 /* LFE Pin (0x0e) */
8222 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8223 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8224 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8225 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008226 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8227 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008228 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10308229 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008230 /* Front Mic pin: input vref at 80% */
8231 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8232 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8233 /* Line In pin */
8234 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8235 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8236
Alex Murrayb8f171e2010-06-14 12:08:43 +09308237 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
8238 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
8239 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008240 { }
8241};
8242
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008243/* Macmini 3,1 */
8244static struct hda_verb alc885_macmini3_init_verbs[] = {
8245 /* DACs */
8246 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8247 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8248 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8249 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8250 /* Front mixer */
8251 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8252 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8253 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8254 /* Surround mixer */
8255 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8256 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8257 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8258 /* LFE mixer */
8259 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8260 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8261 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8262 /* HP mixer */
8263 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8264 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8265 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8266 /* Front Pin (0x0c) */
8267 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8268 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8269 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8270 /* LFE Pin (0x0e) */
8271 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8272 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8273 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8274 /* HP Pin (0x0f) */
8275 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8276 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8277 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
8278 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8279 /* Line In pin */
8280 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8281 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8282
8283 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8284 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8285 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8286 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8287 { }
8288};
8289
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008290
8291static struct hda_verb alc885_mba21_init_verbs[] = {
8292 /*Internal and HP Speaker Mixer*/
8293 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8294 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8295 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8296 /*Internal Speaker Pin (0x0c)*/
8297 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8298 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8299 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8300 /* HP Pin: output 0 (0x0e) */
8301 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
8302 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8303 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8304 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8305 /* Line in (is hp when jack connected)*/
8306 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8307 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8308
8309 { }
8310 };
8311
8312
Takashi Iwai87350ad2007-08-16 18:19:38 +02008313/* Macbook Pro rev3 */
8314static struct hda_verb alc885_mbp3_init_verbs[] = {
8315 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8316 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8317 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8318 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8319 /* Rear mixer */
8320 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8321 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8322 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02008323 /* HP mixer */
8324 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8325 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8326 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008327 /* Front Pin: output 0 (0x0c) */
8328 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8329 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8330 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02008331 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02008332 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02008333 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8334 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008335 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8336 /* Mic (rear) pin: input vref at 80% */
8337 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8338 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8339 /* Front Mic pin: input vref at 80% */
8340 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8341 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8342 /* Line In pin: use output 1 when in LineOut mode */
8343 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8344 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8345 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8346
8347 /* FIXME: use matrix-type input source selection */
8348 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8349 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8350 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8351 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8352 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8353 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8354 /* Input mixer2 */
8355 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8356 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8357 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8358 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8359 /* Input mixer3 */
8360 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8361 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8362 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8363 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8364 /* ADC1: mute amp left and right */
8365 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8366 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8367 /* ADC2: mute amp left and right */
8368 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8369 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8370 /* ADC3: mute amp left and right */
8371 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8372 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8373
8374 { }
8375};
8376
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008377/* iMac 9,1 */
8378static struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008379 /* Internal Speaker Pin (0x0c) */
8380 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8381 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8382 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8383 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8384 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8385 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8386 /* HP Pin: Rear */
8387 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8388 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8389 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8390 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8391 /* Line in Rear */
8392 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8393 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8394 /* Front Mic pin: input vref at 80% */
8395 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8396 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008397 /* Rear mixer */
8398 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8399 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8400 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008401 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8402 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8403 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8404 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8405 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008406 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8407 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8408 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8409 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008410 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008411 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8412 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8413 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8414 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008415 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008416 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8417 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8418 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8419 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008420 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008421 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8422 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008423 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008424 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8425 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008426 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008427 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8428 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008429 { }
8430};
8431
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008432/* iMac 24 mixer. */
8433static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8434 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8435 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8436 { } /* end */
8437};
8438
8439/* iMac 24 init verbs. */
8440static struct hda_verb alc885_imac24_init_verbs[] = {
8441 /* Internal speakers: output 0 (0x0c) */
8442 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8443 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8444 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8445 /* Internal speakers: output 0 (0x0c) */
8446 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8447 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8448 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8449 /* Headphone: output 0 (0x0c) */
8450 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8451 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8452 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8453 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8454 /* Front Mic: input vref at 80% */
8455 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8456 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8457 { }
8458};
8459
8460/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008461static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008462{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008463 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008464
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008465 spec->autocfg.hp_pins[0] = 0x14;
8466 spec->autocfg.speaker_pins[0] = 0x18;
8467 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008468}
8469
Takashi Iwai9d54f082010-02-22 08:34:40 +01008470#define alc885_mb5_setup alc885_imac24_setup
8471#define alc885_macmini3_setup alc885_imac24_setup
8472
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008473/* Macbook Air 2,1 */
8474static void alc885_mba21_setup(struct hda_codec *codec)
8475{
8476 struct alc_spec *spec = codec->spec;
8477
8478 spec->autocfg.hp_pins[0] = 0x14;
8479 spec->autocfg.speaker_pins[0] = 0x18;
8480}
8481
8482
8483
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008484static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008485{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008486 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008487
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008488 spec->autocfg.hp_pins[0] = 0x15;
8489 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008490}
8491
Takashi Iwai9d54f082010-02-22 08:34:40 +01008492static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308493{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008494 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308495
Takashi Iwai9d54f082010-02-22 08:34:40 +01008496 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008497 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008498 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008499}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008500
Kailang Yang272a5272007-05-14 11:00:38 +02008501static struct hda_verb alc882_targa_verbs[] = {
8502 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8503 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8504
8505 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8506 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008507
Kailang Yang272a5272007-05-14 11:00:38 +02008508 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8509 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8510 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8511
8512 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008513 { } /* end */
8514};
8515
8516/* toggle speaker-output according to the hp-jack state */
8517static void alc882_targa_automute(struct hda_codec *codec)
8518{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008519 struct alc_spec *spec = codec->spec;
8520 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008521 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008522 spec->jack_present ? 1 : 3);
8523}
8524
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008525static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008526{
8527 struct alc_spec *spec = codec->spec;
8528
8529 spec->autocfg.hp_pins[0] = 0x14;
8530 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008531}
8532
8533static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8534{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008535 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008536 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008537}
8538
8539static struct hda_verb alc882_asus_a7j_verbs[] = {
8540 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8541 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8542
8543 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8544 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8545 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008546
Kailang Yang272a5272007-05-14 11:00:38 +02008547 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8548 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8549 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8550
8551 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8552 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8553 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8554 { } /* end */
8555};
8556
Takashi Iwai914759b2007-09-06 14:52:04 +02008557static struct hda_verb alc882_asus_a7m_verbs[] = {
8558 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8559 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8560
8561 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8562 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8563 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008564
Takashi Iwai914759b2007-09-06 14:52:04 +02008565 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8566 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8567 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8568
8569 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8570 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8571 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8572 { } /* end */
8573};
8574
Tobin Davis9102cd12006-12-15 10:02:12 +01008575static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8576{
8577 unsigned int gpiostate, gpiomask, gpiodir;
8578
8579 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8580 AC_VERB_GET_GPIO_DATA, 0);
8581
8582 if (!muted)
8583 gpiostate |= (1 << pin);
8584 else
8585 gpiostate &= ~(1 << pin);
8586
8587 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8588 AC_VERB_GET_GPIO_MASK, 0);
8589 gpiomask |= (1 << pin);
8590
8591 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8592 AC_VERB_GET_GPIO_DIRECTION, 0);
8593 gpiodir |= (1 << pin);
8594
8595
8596 snd_hda_codec_write(codec, codec->afg, 0,
8597 AC_VERB_SET_GPIO_MASK, gpiomask);
8598 snd_hda_codec_write(codec, codec->afg, 0,
8599 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8600
8601 msleep(1);
8602
8603 snd_hda_codec_write(codec, codec->afg, 0,
8604 AC_VERB_SET_GPIO_DATA, gpiostate);
8605}
8606
Takashi Iwai7debbe52007-08-16 15:01:03 +02008607/* set up GPIO at initialization */
8608static void alc885_macpro_init_hook(struct hda_codec *codec)
8609{
8610 alc882_gpio_mute(codec, 0, 0);
8611 alc882_gpio_mute(codec, 1, 0);
8612}
8613
8614/* set up GPIO and update auto-muting at initialization */
8615static void alc885_imac24_init_hook(struct hda_codec *codec)
8616{
8617 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008618 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008619}
8620
Kailang Yangdf694da2005-12-05 19:42:22 +01008621/*
8622 * generic initialization of ADC, input mixers and output mixers
8623 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008624static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008625 /*
8626 * Unmute ADC0-2 and set the default input to mic-in
8627 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008628 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8629 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8630 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8631 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8632
Kailang Yangdf694da2005-12-05 19:42:22 +01008633 /*
8634 * Set up output mixers (0x0c - 0x0f)
8635 */
8636 /* set vol=0 to output mixers */
8637 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8638 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8639 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8640 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8641 /* set up input amps for analog loopback */
8642 /* Amp Indices: DAC = 0, mixer = 1 */
8643 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8644 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8645 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8646 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8647 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8648 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8649 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8650 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8651 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8652 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8653
8654 /* FIXME: use matrix-type input source selection */
8655 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008656 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008657 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008658 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008659 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008660 { }
8661};
8662
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008663/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8664static struct hda_verb alc889A_mb31_ch2_init[] = {
8665 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8666 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8667 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8668 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8669 { } /* end */
8670};
8671
8672/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8673static struct hda_verb alc889A_mb31_ch4_init[] = {
8674 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8675 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8676 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8677 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8678 { } /* end */
8679};
8680
8681/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8682static struct hda_verb alc889A_mb31_ch5_init[] = {
8683 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8684 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8685 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8686 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8687 { } /* end */
8688};
8689
8690/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8691static struct hda_verb alc889A_mb31_ch6_init[] = {
8692 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8693 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8694 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8695 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8696 { } /* end */
8697};
8698
8699static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8700 { 2, alc889A_mb31_ch2_init },
8701 { 4, alc889A_mb31_ch4_init },
8702 { 5, alc889A_mb31_ch5_init },
8703 { 6, alc889A_mb31_ch6_init },
8704};
8705
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008706static struct hda_verb alc883_medion_eapd_verbs[] = {
8707 /* eanable EAPD on medion laptop */
8708 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8709 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8710 { }
8711};
8712
Takashi Iwai4953550a2009-06-30 15:28:30 +02008713#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008714
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008715static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8716 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8717 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8718 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8719 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8720 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8721 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8722 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8723 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8724 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8725 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8726 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8727 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8728 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008729 { } /* end */
8730};
8731
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008732static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008733 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8734 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8735 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8736 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8737 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8738 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8739 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8740 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8741 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8742 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008743 { } /* end */
8744};
8745
Jiang zhefb97dc62008-03-06 11:07:11 +01008746static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8747 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8748 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8749 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8750 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8751 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8752 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8753 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8754 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8755 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8756 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008757 { } /* end */
8758};
8759
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008760static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8761 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8762 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8763 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8764 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8765 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8766 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8767 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8768 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008769 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008770 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8771 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008772 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008773 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008774 { } /* end */
8775};
8776
8777static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8778 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8779 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8780 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8781 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8782 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8783 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8784 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8785 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8786 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8787 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8788 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8789 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8790 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8791 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008792 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008793 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8794 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008795 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008796 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008797 { } /* end */
8798};
8799
Jiang zhe17bba1b2008-06-04 12:11:07 +02008800static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8801 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8802 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8803 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8804 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8805 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8806 HDA_OUTPUT),
8807 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8808 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8809 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8810 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8811 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8812 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8813 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8814 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8815 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8816 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8817 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8818 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8819 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8820 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008821 { } /* end */
8822};
8823
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008824static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8825 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8826 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8827 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8828 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8829 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8830 HDA_OUTPUT),
8831 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8832 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8833 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8834 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8835 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8836 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8837 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8838 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8839 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8840 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8841 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8842 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8843 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8844 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8845 { } /* end */
8846};
8847
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008848static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008849 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008850 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008851 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008852 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008853 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8854 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008855 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8856 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008857 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8858 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8859 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8860 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8861 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8862 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008863 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008864 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8865 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008866 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008867 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008868 { } /* end */
8869};
8870
Sasha Alexandrc2592492009-06-16 14:52:54 -04008871static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008872 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008873 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008874 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008875 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008876 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8877 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8878 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8879 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8880 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8881 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8882 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8883 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8884 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8885 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8886 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008887 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008888 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008889 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008890};
Kailang Yangccc656c2006-10-17 12:32:26 +02008891
Sasha Alexandrc2592492009-06-16 14:52:54 -04008892static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008893 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008894 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008895 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008896 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008897 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8898 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8899 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008900 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008901 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008902 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8903 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8904 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008905 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008906};
Kailang Yangccc656c2006-10-17 12:32:26 +02008907
Takashi Iwaib99dba32009-09-17 18:23:00 +02008908static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8909 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8910 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8911 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8912 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8913 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8914 { } /* end */
8915};
8916
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008917static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8918 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8919 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008920 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8921 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008922 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8923 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8924 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8925 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008926 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008927};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008928
Kailang Yang272a5272007-05-14 11:00:38 +02008929static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8930 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8931 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8932 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8933 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8934 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8935 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8936 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson150b4322010-07-29 14:46:42 +02008937 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8938 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008939 { } /* end */
8940};
8941
8942static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8943 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8944 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8945 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8946 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8947 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8948 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8949 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8950 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8951 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008952 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008953};
Kailang Yang272a5272007-05-14 11:00:38 +02008954
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02008955static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
8956 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8957 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8958 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8959 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
8960 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
8961 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
8962 { } /* end */
8963};
8964
8965static struct hda_verb alc883_medion_wim2160_verbs[] = {
8966 /* Unmute front mixer */
8967 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8968 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8969
8970 /* Set speaker pin to front mixer */
8971 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8972
8973 /* Init headphone pin */
8974 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8975 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8976 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8977 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8978
8979 { } /* end */
8980};
8981
8982/* toggle speaker-output according to the hp-jack state */
8983static void alc883_medion_wim2160_setup(struct hda_codec *codec)
8984{
8985 struct alc_spec *spec = codec->spec;
8986
8987 spec->autocfg.hp_pins[0] = 0x1a;
8988 spec->autocfg.speaker_pins[0] = 0x15;
8989}
8990
Tobin Davis2880a8672007-08-07 11:50:26 +02008991static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008992 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8993 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a8672007-08-07 11:50:26 +02008994 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a8672007-08-07 11:50:26 +02008995 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8996 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008997 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8998 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8999 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a8672007-08-07 11:50:26 +02009000 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02009001};
Tobin Davis2880a8672007-08-07 11:50:26 +02009002
Tony Vroond2fd4b02009-06-21 00:40:10 +01009003static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
9004 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009005 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01009006 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9007 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009008 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9009 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9010 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9011 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9012 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9013 { } /* end */
9014};
9015
Kailang Yange2757d52008-08-26 13:17:46 +02009016static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
9017 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9018 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9019 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9020 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
9021 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
9022 0x0d, 1, 0x0, HDA_OUTPUT),
9023 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
9024 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
9025 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
9026 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9027 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009028 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9029 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9030 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9031 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9032 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9033 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9034 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9035 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9036 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9037 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009038 { } /* end */
9039};
9040
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009041static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
9042 /* Output mixers */
9043 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
9044 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
9045 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
9046 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
9047 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
9048 HDA_OUTPUT),
9049 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
9050 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
9051 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
9052 /* Output switches */
9053 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
9054 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
9055 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
9056 /* Boost mixers */
9057 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
9058 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
9059 /* Input mixers */
9060 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
9061 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
9062 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9063 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9064 { } /* end */
9065};
9066
Guido Günther3e1647c2009-06-05 00:47:26 +02009067static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
9068 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9069 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9070 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9071 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9072 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
9073 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9074 { } /* end */
9075};
9076
Kailang Yange2757d52008-08-26 13:17:46 +02009077static struct hda_bind_ctls alc883_bind_cap_vol = {
9078 .ops = &snd_hda_bind_vol,
9079 .values = {
9080 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9081 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9082 0
9083 },
9084};
9085
9086static struct hda_bind_ctls alc883_bind_cap_switch = {
9087 .ops = &snd_hda_bind_sw,
9088 .values = {
9089 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9090 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9091 0
9092 },
9093};
9094
9095static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
9096 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9097 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9098 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9099 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9100 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9101 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9102 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9103 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009104 { } /* end */
9105};
9106
9107static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009108 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
9109 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
9110 {
9111 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9112 /* .name = "Capture Source", */
9113 .name = "Input Source",
9114 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009115 .info = alc_mux_enum_info,
9116 .get = alc_mux_enum_get,
9117 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02009118 },
9119 { } /* end */
9120};
9121
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009122static struct snd_kcontrol_new alc883_chmode_mixer[] = {
9123 {
9124 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9125 .name = "Channel Mode",
9126 .info = alc_ch_mode_info,
9127 .get = alc_ch_mode_get,
9128 .put = alc_ch_mode_put,
9129 },
9130 { } /* end */
9131};
9132
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009133/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009134static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009135{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009136 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009137
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009138 spec->autocfg.hp_pins[0] = 0x15;
9139 spec->autocfg.speaker_pins[0] = 0x14;
9140 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009141}
9142
9143/* auto-toggle front mic */
9144/*
9145static void alc883_mitac_mic_automute(struct hda_codec *codec)
9146{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009147 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009148
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009149 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
9150}
9151*/
9152
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009153static struct hda_verb alc883_mitac_verbs[] = {
9154 /* HP */
9155 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9156 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9157 /* Subwoofer */
9158 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9159 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9160
9161 /* enable unsolicited event */
9162 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9163 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
9164
9165 { } /* end */
9166};
9167
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309168static struct hda_verb alc883_clevo_m540r_verbs[] = {
9169 /* HP */
9170 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9171 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9172 /* Int speaker */
9173 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
9174
9175 /* enable unsolicited event */
9176 /*
9177 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9178 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9179 */
9180
9181 { } /* end */
9182};
9183
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009184static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009185 /* HP */
9186 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9187 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9188 /* Int speaker */
9189 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
9190 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9191
9192 /* enable unsolicited event */
9193 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009194 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01009195
9196 { } /* end */
9197};
9198
Jiang zhefb97dc62008-03-06 11:07:11 +01009199static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
9200 /* HP */
9201 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9202 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9203 /* Subwoofer */
9204 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9205 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9206
9207 /* enable unsolicited event */
9208 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9209
9210 { } /* end */
9211};
9212
Sasha Alexandrc2592492009-06-16 14:52:54 -04009213static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009214 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9215 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9216
9217 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9218 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02009219
David Heidelberger64a8be72009-06-08 16:15:18 +02009220/* Connect Line-Out side jack (SPDIF) to Side */
9221 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9222 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9223 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9224/* Connect Mic jack to CLFE */
9225 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9226 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9227 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
9228/* Connect Line-in jack to Surround */
9229 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9230 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9231 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
9232/* Connect HP out jack to Front */
9233 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9234 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9235 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02009236
9237 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02009238
9239 { } /* end */
9240};
9241
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009242static struct hda_verb alc883_lenovo_101e_verbs[] = {
9243 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9244 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
9245 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
9246 { } /* end */
9247};
9248
Kailang Yang272a5272007-05-14 11:00:38 +02009249static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
9250 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9251 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9252 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9253 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9254 { } /* end */
9255};
9256
9257static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
9258 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9259 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9260 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9261 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
9262 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9263 { } /* end */
9264};
9265
Kailang Yang189609a2007-08-20 11:31:23 +02009266static struct hda_verb alc883_haier_w66_verbs[] = {
9267 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9268 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9269
9270 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9271
9272 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9273 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9274 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9275 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9276 { } /* end */
9277};
9278
Kailang Yange2757d52008-08-26 13:17:46 +02009279static struct hda_verb alc888_lenovo_sky_verbs[] = {
9280 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9281 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9282 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9283 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9284 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9285 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9286 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9287 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9288 { } /* end */
9289};
9290
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009291static struct hda_verb alc888_6st_dell_verbs[] = {
9292 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9293 { }
9294};
9295
Guido Günther3e1647c2009-06-05 00:47:26 +02009296static struct hda_verb alc883_vaiott_verbs[] = {
9297 /* HP */
9298 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9299 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9300
9301 /* enable unsolicited event */
9302 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9303
9304 { } /* end */
9305};
9306
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009307static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009308{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009309 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009310
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009311 spec->autocfg.hp_pins[0] = 0x1b;
9312 spec->autocfg.speaker_pins[0] = 0x14;
9313 spec->autocfg.speaker_pins[1] = 0x16;
9314 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009315}
9316
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009317static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009318 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01009319 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
9320 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009321 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009322 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009323};
9324
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009325/*
9326 * 2ch mode
9327 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009328static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009329 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9330 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9331 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9332 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009333 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009334};
9335
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009336/*
9337 * 4ch mode
9338 */
9339static struct hda_verb alc888_3st_hp_4ch_init[] = {
9340 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9341 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9342 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9343 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9344 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9345 { } /* end */
9346};
9347
9348/*
9349 * 6ch mode
9350 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009351static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009352 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9353 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009354 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009355 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9356 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009357 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9358 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009359};
9360
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009361static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009362 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009363 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009364 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009365};
9366
Kailang Yang272a5272007-05-14 11:00:38 +02009367/* toggle front-jack and RCA according to the hp-jack state */
9368static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
9369{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009370 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02009371
Takashi Iwai47fd8302007-08-10 17:11:07 +02009372 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9373 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9374 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9375 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009376}
9377
9378/* toggle RCA according to the front-jack state */
9379static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
9380{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009381 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02009382
Takashi Iwai47fd8302007-08-10 17:11:07 +02009383 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9384 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009385}
Takashi Iwai47fd8302007-08-10 17:11:07 +02009386
Kailang Yang272a5272007-05-14 11:00:38 +02009387static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
9388 unsigned int res)
9389{
9390 if ((res >> 26) == ALC880_HP_EVENT)
9391 alc888_lenovo_ms7195_front_automute(codec);
9392 if ((res >> 26) == ALC880_FRONT_EVENT)
9393 alc888_lenovo_ms7195_rca_automute(codec);
9394}
9395
9396static struct hda_verb alc883_medion_md2_verbs[] = {
9397 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9398 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9399
9400 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9401
9402 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9403 { } /* end */
9404};
9405
9406/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009407static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009408{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009409 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009410
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009411 spec->autocfg.hp_pins[0] = 0x14;
9412 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02009413}
9414
Kailang Yangccc656c2006-10-17 12:32:26 +02009415/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009416#define alc883_targa_init_hook alc882_targa_init_hook
9417#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009418
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009419static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
9420{
9421 unsigned int present;
9422
Takashi Iwaid56757a2009-11-18 08:00:14 +01009423 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009424 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
9425 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9426}
9427
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009428static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009429{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009430 struct alc_spec *spec = codec->spec;
9431
9432 spec->autocfg.hp_pins[0] = 0x15;
9433 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009434}
9435
9436static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9437{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009438 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009439 alc883_clevo_m720_mic_automute(codec);
9440}
9441
9442static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009443 unsigned int res)
9444{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009445 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009446 case ALC880_MIC_EVENT:
9447 alc883_clevo_m720_mic_automute(codec);
9448 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009449 default:
9450 alc_automute_amp_unsol_event(codec, res);
9451 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009452 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009453}
9454
Jiang zhefb97dc62008-03-06 11:07:11 +01009455/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009456static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009457{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009458 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009459
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009460 spec->autocfg.hp_pins[0] = 0x14;
9461 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01009462}
9463
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009464static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009465{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009466 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009467
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009468 spec->autocfg.hp_pins[0] = 0x1b;
9469 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02009470}
9471
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009472static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9473{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009474 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009475
Takashi Iwai47fd8302007-08-10 17:11:07 +02009476 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9477 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009478}
9479
9480static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9481{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009482 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009483
Takashi Iwai47fd8302007-08-10 17:11:07 +02009484 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9485 HDA_AMP_MUTE, bits);
9486 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9487 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009488}
9489
9490static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9491 unsigned int res)
9492{
9493 if ((res >> 26) == ALC880_HP_EVENT)
9494 alc883_lenovo_101e_all_automute(codec);
9495 if ((res >> 26) == ALC880_FRONT_EVENT)
9496 alc883_lenovo_101e_ispeaker_automute(codec);
9497}
9498
Takashi Iwai676a9b52007-08-16 15:23:35 +02009499/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009500static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009501{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009502 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009503
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009504 spec->autocfg.hp_pins[0] = 0x14;
9505 spec->autocfg.speaker_pins[0] = 0x15;
9506 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009507}
9508
Kailang Yangd1a991a2007-08-15 16:21:59 +02009509static struct hda_verb alc883_acer_eapd_verbs[] = {
9510 /* HP Pin: output 0 (0x0c) */
9511 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9512 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9513 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9514 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009515 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9516 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009517 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009518 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9519 /* eanable EAPD on medion laptop */
9520 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9521 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009522 /* enable unsolicited event */
9523 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009524 { }
9525};
9526
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009527static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
9528 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9529 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9530 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9531 { } /* end */
9532};
9533
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009534static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009535{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009536 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009537
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009538 spec->autocfg.hp_pins[0] = 0x1b;
9539 spec->autocfg.speaker_pins[0] = 0x14;
9540 spec->autocfg.speaker_pins[1] = 0x15;
9541 spec->autocfg.speaker_pins[2] = 0x16;
9542 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009543}
9544
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009545static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009546{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009547 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009548
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009549 spec->autocfg.hp_pins[0] = 0x1b;
9550 spec->autocfg.speaker_pins[0] = 0x14;
9551 spec->autocfg.speaker_pins[1] = 0x15;
9552 spec->autocfg.speaker_pins[2] = 0x16;
9553 spec->autocfg.speaker_pins[3] = 0x17;
9554 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009555}
9556
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009557static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02009558{
9559 struct alc_spec *spec = codec->spec;
9560
9561 spec->autocfg.hp_pins[0] = 0x15;
9562 spec->autocfg.speaker_pins[0] = 0x14;
9563 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02009564}
9565
Kailang Yange2757d52008-08-26 13:17:46 +02009566static struct hda_verb alc888_asus_m90v_verbs[] = {
9567 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9568 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9569 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9570 /* enable unsolicited event */
9571 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9572 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9573 { } /* end */
9574};
9575
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009576static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009577{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009578 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009579
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009580 spec->autocfg.hp_pins[0] = 0x1b;
9581 spec->autocfg.speaker_pins[0] = 0x14;
9582 spec->autocfg.speaker_pins[1] = 0x15;
9583 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009584 spec->ext_mic.pin = 0x18;
9585 spec->int_mic.pin = 0x19;
9586 spec->ext_mic.mux_idx = 0;
9587 spec->int_mic.mux_idx = 1;
9588 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009589}
9590
9591static struct hda_verb alc888_asus_eee1601_verbs[] = {
9592 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9593 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9594 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9595 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9596 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9597 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9598 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9599 /* enable unsolicited event */
9600 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9601 { } /* end */
9602};
9603
Kailang Yange2757d52008-08-26 13:17:46 +02009604static void alc883_eee1601_inithook(struct hda_codec *codec)
9605{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009606 struct alc_spec *spec = codec->spec;
9607
9608 spec->autocfg.hp_pins[0] = 0x14;
9609 spec->autocfg.speaker_pins[0] = 0x1b;
9610 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009611}
9612
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009613static struct hda_verb alc889A_mb31_verbs[] = {
9614 /* Init rear pin (used as headphone output) */
9615 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9616 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9617 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9618 /* Init line pin (used as output in 4ch and 6ch mode) */
9619 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9620 /* Init line 2 pin (used as headphone out by default) */
9621 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9622 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9623 { } /* end */
9624};
9625
9626/* Mute speakers according to the headphone jack state */
9627static void alc889A_mb31_automute(struct hda_codec *codec)
9628{
9629 unsigned int present;
9630
9631 /* Mute only in 2ch or 4ch mode */
9632 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9633 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009634 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009635 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9636 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9637 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9638 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9639 }
9640}
9641
9642static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9643{
9644 if ((res >> 26) == ALC880_HP_EVENT)
9645 alc889A_mb31_automute(codec);
9646}
9647
Takashi Iwai4953550a2009-06-30 15:28:30 +02009648
Takashi Iwaicb53c622007-08-10 17:21:45 +02009649#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009650#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009651#endif
9652
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009653/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009654#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9655#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9656#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9657#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9658
9659static hda_nid_t alc883_slave_dig_outs[] = {
9660 ALC1200_DIGOUT_NID, 0,
9661};
9662
9663static hda_nid_t alc1200_slave_dig_outs[] = {
9664 ALC883_DIGOUT_NID, 0,
9665};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009666
9667/*
9668 * configuration and preset
9669 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009670static const char *alc882_models[ALC882_MODEL_LAST] = {
9671 [ALC882_3ST_DIG] = "3stack-dig",
9672 [ALC882_6ST_DIG] = "6stack-dig",
9673 [ALC882_ARIMA] = "arima",
9674 [ALC882_W2JC] = "w2jc",
9675 [ALC882_TARGA] = "targa",
9676 [ALC882_ASUS_A7J] = "asus-a7j",
9677 [ALC882_ASUS_A7M] = "asus-a7m",
9678 [ALC885_MACPRO] = "macpro",
9679 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009680 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009681 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009682 [ALC885_MBP3] = "mbp3",
9683 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009684 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009685 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009686 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9687 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009688 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009689 [ALC883_TARGA_DIG] = "targa-dig",
9690 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009691 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009692 [ALC883_ACER] = "acer",
Tobin Davis2880a8672007-08-07 11:50:26 +02009693 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009694 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009695 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009696 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009697 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009698 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009699 [ALC883_MEDION_MD2] = "medion-md2",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009700 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009701 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009702 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009703 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9704 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009705 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009706 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009707 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009708 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009709 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309710 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009711 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009712 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009713 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009714 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009715 [ALC889A_INTEL] = "intel-alc889a",
9716 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009717 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009718 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009719 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009720 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009721};
9722
Takashi Iwai4953550a2009-06-30 15:28:30 +02009723static struct snd_pci_quirk alc882_cfg_tbl[] = {
9724 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9725
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009726 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009727 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009728 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009729 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9730 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009731 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009732 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9733 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009734 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009735 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009736 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9737 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009738 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9739 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009740 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9741 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009742 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009743 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009744 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009745 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009746 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9747 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009748 /* default Acer -- disabled as it causes more problems.
9749 * model=auto should work fine now
9750 */
9751 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009752
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009753 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009754
Tobin Davisfebe3372007-06-12 11:27:46 +02009755 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009756 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9757 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009758 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009759 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009760 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009761
9762 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9763 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9764 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009765 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009766 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9767 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9768 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009769 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009770 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009771 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009772 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009773
9774 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009775 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009776 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009777 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009778 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9779 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009780 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009781 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009782 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9783
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009784 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9785 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9786 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009787 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009788 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009789 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009790 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009791 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009792 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9793 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9794 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9795 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9796 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9797 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009798 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009799 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9800 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9801 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009802 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009803 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009804 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9805 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009806 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009807 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009808 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009809 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009810 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009811 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009812 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009813 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009814 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009815
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009816 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +02009817 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009818 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9819 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309820 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009821 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009822 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009823 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009824 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009825 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009826 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009827 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009828 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009829 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009830 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009831 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9832 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009833 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009834 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009835 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009836 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009837 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009838
Jiang zhe17bba1b2008-06-04 12:11:07 +02009839 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9840 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009841 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009842 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9843 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9844 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009845 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009846
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009847 {}
9848};
9849
Takashi Iwai4953550a2009-06-30 15:28:30 +02009850/* codec SSID table for Intel Mac */
9851static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9852 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9853 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9854 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9855 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9856 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9857 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9858 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -04009859 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -07009860 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -07009861 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -07009862 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009863 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9864 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9865 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009866 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009867 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Luke Yelavich3bfea982010-06-22 11:04:19 +10009868 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009869 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9870 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009871 */
9872 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009873 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009874 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009875 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009876};
9877
Takashi Iwai4953550a2009-06-30 15:28:30 +02009878static struct alc_config_preset alc882_presets[] = {
9879 [ALC882_3ST_DIG] = {
9880 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009881 .init_verbs = { alc882_base_init_verbs,
9882 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009883 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9884 .dac_nids = alc882_dac_nids,
9885 .dig_out_nid = ALC882_DIGOUT_NID,
9886 .dig_in_nid = ALC882_DIGIN_NID,
9887 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9888 .channel_mode = alc882_ch_modes,
9889 .need_dac_fix = 1,
9890 .input_mux = &alc882_capture_source,
9891 },
9892 [ALC882_6ST_DIG] = {
9893 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009894 .init_verbs = { alc882_base_init_verbs,
9895 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009896 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9897 .dac_nids = alc882_dac_nids,
9898 .dig_out_nid = ALC882_DIGOUT_NID,
9899 .dig_in_nid = ALC882_DIGIN_NID,
9900 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9901 .channel_mode = alc882_sixstack_modes,
9902 .input_mux = &alc882_capture_source,
9903 },
9904 [ALC882_ARIMA] = {
9905 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009906 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9907 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009908 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9909 .dac_nids = alc882_dac_nids,
9910 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9911 .channel_mode = alc882_sixstack_modes,
9912 .input_mux = &alc882_capture_source,
9913 },
9914 [ALC882_W2JC] = {
9915 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009916 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9917 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009918 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9919 .dac_nids = alc882_dac_nids,
9920 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9921 .channel_mode = alc880_threestack_modes,
9922 .need_dac_fix = 1,
9923 .input_mux = &alc882_capture_source,
9924 .dig_out_nid = ALC882_DIGOUT_NID,
9925 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009926 [ALC885_MBA21] = {
9927 .mixers = { alc885_mba21_mixer },
9928 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9929 .num_dacs = 2,
9930 .dac_nids = alc882_dac_nids,
9931 .channel_mode = alc885_mba21_ch_modes,
9932 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9933 .input_mux = &alc882_capture_source,
9934 .unsol_event = alc_automute_amp_unsol_event,
9935 .setup = alc885_mba21_setup,
9936 .init_hook = alc_automute_amp,
9937 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009938 [ALC885_MBP3] = {
9939 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9940 .init_verbs = { alc885_mbp3_init_verbs,
9941 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009942 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009943 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009944 .hp_nid = 0x04,
9945 .channel_mode = alc885_mbp_4ch_modes,
9946 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009947 .input_mux = &alc882_capture_source,
9948 .dig_out_nid = ALC882_DIGOUT_NID,
9949 .dig_in_nid = ALC882_DIGIN_NID,
9950 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009951 .setup = alc885_mbp3_setup,
9952 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009953 },
9954 [ALC885_MB5] = {
9955 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9956 .init_verbs = { alc885_mb5_init_verbs,
9957 alc880_gpio1_init_verbs },
9958 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9959 .dac_nids = alc882_dac_nids,
9960 .channel_mode = alc885_mb5_6ch_modes,
9961 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9962 .input_mux = &mb5_capture_source,
9963 .dig_out_nid = ALC882_DIGOUT_NID,
9964 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009965 .unsol_event = alc_automute_amp_unsol_event,
9966 .setup = alc885_mb5_setup,
9967 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009968 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009969 [ALC885_MACMINI3] = {
9970 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
9971 .init_verbs = { alc885_macmini3_init_verbs,
9972 alc880_gpio1_init_verbs },
9973 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9974 .dac_nids = alc882_dac_nids,
9975 .channel_mode = alc885_macmini3_6ch_modes,
9976 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
9977 .input_mux = &macmini3_capture_source,
9978 .dig_out_nid = ALC882_DIGOUT_NID,
9979 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009980 .unsol_event = alc_automute_amp_unsol_event,
9981 .setup = alc885_macmini3_setup,
9982 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009983 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009984 [ALC885_MACPRO] = {
9985 .mixers = { alc882_macpro_mixer },
9986 .init_verbs = { alc882_macpro_init_verbs },
9987 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9988 .dac_nids = alc882_dac_nids,
9989 .dig_out_nid = ALC882_DIGOUT_NID,
9990 .dig_in_nid = ALC882_DIGIN_NID,
9991 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9992 .channel_mode = alc882_ch_modes,
9993 .input_mux = &alc882_capture_source,
9994 .init_hook = alc885_macpro_init_hook,
9995 },
9996 [ALC885_IMAC24] = {
9997 .mixers = { alc885_imac24_mixer },
9998 .init_verbs = { alc885_imac24_init_verbs },
9999 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10000 .dac_nids = alc882_dac_nids,
10001 .dig_out_nid = ALC882_DIGOUT_NID,
10002 .dig_in_nid = ALC882_DIGIN_NID,
10003 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10004 .channel_mode = alc882_ch_modes,
10005 .input_mux = &alc882_capture_source,
10006 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010007 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010008 .init_hook = alc885_imac24_init_hook,
10009 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010010 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010011 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010012 .init_verbs = { alc885_imac91_init_verbs,
10013 alc880_gpio1_init_verbs },
10014 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10015 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010016 .channel_mode = alc885_mba21_ch_modes,
10017 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10018 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010019 .dig_out_nid = ALC882_DIGOUT_NID,
10020 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010021 .unsol_event = alc_automute_amp_unsol_event,
10022 .setup = alc885_imac91_setup,
10023 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010024 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010025 [ALC882_TARGA] = {
10026 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010027 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +020010028 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010029 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10030 .dac_nids = alc882_dac_nids,
10031 .dig_out_nid = ALC882_DIGOUT_NID,
10032 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10033 .adc_nids = alc882_adc_nids,
10034 .capsrc_nids = alc882_capsrc_nids,
10035 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10036 .channel_mode = alc882_3ST_6ch_modes,
10037 .need_dac_fix = 1,
10038 .input_mux = &alc882_capture_source,
10039 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010040 .setup = alc882_targa_setup,
10041 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010042 },
10043 [ALC882_ASUS_A7J] = {
10044 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010045 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10046 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010047 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10048 .dac_nids = alc882_dac_nids,
10049 .dig_out_nid = ALC882_DIGOUT_NID,
10050 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10051 .adc_nids = alc882_adc_nids,
10052 .capsrc_nids = alc882_capsrc_nids,
10053 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10054 .channel_mode = alc882_3ST_6ch_modes,
10055 .need_dac_fix = 1,
10056 .input_mux = &alc882_capture_source,
10057 },
10058 [ALC882_ASUS_A7M] = {
10059 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010060 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10061 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010062 alc882_asus_a7m_verbs },
10063 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10064 .dac_nids = alc882_dac_nids,
10065 .dig_out_nid = ALC882_DIGOUT_NID,
10066 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10067 .channel_mode = alc880_threestack_modes,
10068 .need_dac_fix = 1,
10069 .input_mux = &alc882_capture_source,
10070 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010071 [ALC883_3ST_2ch_DIG] = {
10072 .mixers = { alc883_3ST_2ch_mixer },
10073 .init_verbs = { alc883_init_verbs },
10074 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10075 .dac_nids = alc883_dac_nids,
10076 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010077 .dig_in_nid = ALC883_DIGIN_NID,
10078 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10079 .channel_mode = alc883_3ST_2ch_modes,
10080 .input_mux = &alc883_capture_source,
10081 },
10082 [ALC883_3ST_6ch_DIG] = {
10083 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10084 .init_verbs = { alc883_init_verbs },
10085 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10086 .dac_nids = alc883_dac_nids,
10087 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010088 .dig_in_nid = ALC883_DIGIN_NID,
10089 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10090 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010091 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010092 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010093 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010094 [ALC883_3ST_6ch] = {
10095 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10096 .init_verbs = { alc883_init_verbs },
10097 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10098 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010099 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10100 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010101 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010102 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010103 },
Jiang zhe17bba1b2008-06-04 12:11:07 +020010104 [ALC883_3ST_6ch_INTEL] = {
10105 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
10106 .init_verbs = { alc883_init_verbs },
10107 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10108 .dac_nids = alc883_dac_nids,
10109 .dig_out_nid = ALC883_DIGOUT_NID,
10110 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010111 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +020010112 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
10113 .channel_mode = alc883_3ST_6ch_intel_modes,
10114 .need_dac_fix = 1,
10115 .input_mux = &alc883_3stack_6ch_intel,
10116 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010117 [ALC889A_INTEL] = {
10118 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020010119 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
10120 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010121 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10122 .dac_nids = alc883_dac_nids,
10123 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10124 .adc_nids = alc889_adc_nids,
10125 .dig_out_nid = ALC883_DIGOUT_NID,
10126 .dig_in_nid = ALC883_DIGIN_NID,
10127 .slave_dig_outs = alc883_slave_dig_outs,
10128 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10129 .channel_mode = alc889_8ch_intel_modes,
10130 .capsrc_nids = alc889_capsrc_nids,
10131 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010132 .setup = alc889_automute_setup,
10133 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010134 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010135 .need_dac_fix = 1,
10136 },
10137 [ALC889_INTEL] = {
10138 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
10139 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010140 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010141 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10142 .dac_nids = alc883_dac_nids,
10143 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10144 .adc_nids = alc889_adc_nids,
10145 .dig_out_nid = ALC883_DIGOUT_NID,
10146 .dig_in_nid = ALC883_DIGIN_NID,
10147 .slave_dig_outs = alc883_slave_dig_outs,
10148 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10149 .channel_mode = alc889_8ch_intel_modes,
10150 .capsrc_nids = alc889_capsrc_nids,
10151 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010152 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010153 .init_hook = alc889_intel_init_hook,
10154 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010155 .need_dac_fix = 1,
10156 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010157 [ALC883_6ST_DIG] = {
10158 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10159 .init_verbs = { alc883_init_verbs },
10160 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10161 .dac_nids = alc883_dac_nids,
10162 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010163 .dig_in_nid = ALC883_DIGIN_NID,
10164 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10165 .channel_mode = alc883_sixstack_modes,
10166 .input_mux = &alc883_capture_source,
10167 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010168 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010169 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +020010170 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10171 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010172 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10173 .dac_nids = alc883_dac_nids,
10174 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010175 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10176 .channel_mode = alc883_3ST_6ch_modes,
10177 .need_dac_fix = 1,
10178 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010179 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010180 .setup = alc882_targa_setup,
10181 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010182 },
10183 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010184 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +020010185 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10186 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010187 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10188 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010189 .adc_nids = alc883_adc_nids_alt,
10190 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010191 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +020010192 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010193 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10194 .channel_mode = alc883_3ST_2ch_modes,
10195 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010196 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010197 .setup = alc882_targa_setup,
10198 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010199 },
David Heidelberger64a8be72009-06-08 16:15:18 +020010200 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +020010201 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
10202 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +020010203 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010204 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +020010205 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10206 .dac_nids = alc883_dac_nids,
10207 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10208 .adc_nids = alc883_adc_nids_rev,
10209 .capsrc_nids = alc883_capsrc_nids_rev,
10210 .dig_out_nid = ALC883_DIGOUT_NID,
10211 .dig_in_nid = ALC883_DIGIN_NID,
10212 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
10213 .channel_mode = alc883_4ST_8ch_modes,
10214 .need_dac_fix = 1,
10215 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010216 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010217 .setup = alc882_targa_setup,
10218 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +020010219 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +020010220 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010221 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +020010222 /* On TravelMate laptops, GPIO 0 enables the internal speaker
10223 * and the headphone jack. Turn this on and rely on the
10224 * standard mute methods whenever the user wants to turn
10225 * these outputs off.
10226 */
10227 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
10228 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10229 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +020010230 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10231 .channel_mode = alc883_3ST_2ch_modes,
10232 .input_mux = &alc883_capture_source,
10233 },
Tobin Davis2880a8672007-08-07 11:50:26 +020010234 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010235 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010236 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a8672007-08-07 11:50:26 +020010237 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10238 .dac_nids = alc883_dac_nids,
10239 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a8672007-08-07 11:50:26 +020010240 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10241 .channel_mode = alc883_3ST_2ch_modes,
10242 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010243 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010244 .setup = alc883_acer_aspire_setup,
10245 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010246 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010247 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010248 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010249 alc883_chmode_mixer },
10250 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10251 alc888_acer_aspire_4930g_verbs },
10252 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10253 .dac_nids = alc883_dac_nids,
10254 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10255 .adc_nids = alc883_adc_nids_rev,
10256 .capsrc_nids = alc883_capsrc_nids_rev,
10257 .dig_out_nid = ALC883_DIGOUT_NID,
10258 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10259 .channel_mode = alc883_3ST_6ch_modes,
10260 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +010010261 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010262 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010263 ARRAY_SIZE(alc888_2_capture_sources),
10264 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010265 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010266 .setup = alc888_acer_aspire_4930g_setup,
10267 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010268 },
Tony Vroond2fd4b02009-06-21 00:40:10 +010010269 [ALC888_ACER_ASPIRE_6530G] = {
10270 .mixers = { alc888_acer_aspire_6530_mixer },
10271 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10272 alc888_acer_aspire_6530g_verbs },
10273 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10274 .dac_nids = alc883_dac_nids,
10275 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10276 .adc_nids = alc883_adc_nids_rev,
10277 .capsrc_nids = alc883_capsrc_nids_rev,
10278 .dig_out_nid = ALC883_DIGOUT_NID,
10279 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10280 .channel_mode = alc883_3ST_2ch_modes,
10281 .num_mux_defs =
10282 ARRAY_SIZE(alc888_2_capture_sources),
10283 .input_mux = alc888_acer_aspire_6530_sources,
10284 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010285 .setup = alc888_acer_aspire_6530g_setup,
10286 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +010010287 },
Hector Martin3b315d72009-06-02 10:54:19 +020010288 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +010010289 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +020010290 alc883_chmode_mixer },
10291 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +010010292 alc889_acer_aspire_8930g_verbs,
10293 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +020010294 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10295 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +020010296 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10297 .adc_nids = alc889_adc_nids,
10298 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +020010299 .dig_out_nid = ALC883_DIGOUT_NID,
10300 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10301 .channel_mode = alc883_3ST_6ch_modes,
10302 .need_dac_fix = 1,
10303 .const_channel_count = 6,
10304 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +020010305 ARRAY_SIZE(alc889_capture_sources),
10306 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +020010307 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010308 .setup = alc889_acer_aspire_8930g_setup,
10309 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +010010310#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050010311 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +010010312#endif
Hector Martin3b315d72009-06-02 10:54:19 +020010313 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010314 [ALC888_ACER_ASPIRE_7730G] = {
10315 .mixers = { alc883_3ST_6ch_mixer,
10316 alc883_chmode_mixer },
10317 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10318 alc888_acer_aspire_7730G_verbs },
10319 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10320 .dac_nids = alc883_dac_nids,
10321 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10322 .adc_nids = alc883_adc_nids_rev,
10323 .capsrc_nids = alc883_capsrc_nids_rev,
10324 .dig_out_nid = ALC883_DIGOUT_NID,
10325 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10326 .channel_mode = alc883_3ST_6ch_modes,
10327 .need_dac_fix = 1,
10328 .const_channel_count = 6,
10329 .input_mux = &alc883_capture_source,
10330 .unsol_event = alc_automute_amp_unsol_event,
10331 .setup = alc888_acer_aspire_6530g_setup,
10332 .init_hook = alc_automute_amp,
10333 },
Tobin Davisc07584c2006-10-13 12:32:16 +020010334 [ALC883_MEDION] = {
10335 .mixers = { alc883_fivestack_mixer,
10336 alc883_chmode_mixer },
10337 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010338 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +020010339 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10340 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010341 .adc_nids = alc883_adc_nids_alt,
10342 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010343 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +020010344 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10345 .channel_mode = alc883_sixstack_modes,
10346 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010347 },
Kailang Yang272a5272007-05-14 11:00:38 +020010348 [ALC883_MEDION_MD2] = {
10349 .mixers = { alc883_medion_md2_mixer},
10350 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
10351 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10352 .dac_nids = alc883_dac_nids,
10353 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010354 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10355 .channel_mode = alc883_3ST_2ch_modes,
10356 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010357 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010358 .setup = alc883_medion_md2_setup,
10359 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020010360 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010361 [ALC883_MEDION_WIM2160] = {
10362 .mixers = { alc883_medion_wim2160_mixer },
10363 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
10364 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10365 .dac_nids = alc883_dac_nids,
10366 .dig_out_nid = ALC883_DIGOUT_NID,
10367 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
10368 .adc_nids = alc883_adc_nids,
10369 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10370 .channel_mode = alc883_3ST_2ch_modes,
10371 .input_mux = &alc883_capture_source,
10372 .unsol_event = alc_automute_amp_unsol_event,
10373 .setup = alc883_medion_wim2160_setup,
10374 .init_hook = alc_automute_amp,
10375 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010376 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010377 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010378 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10379 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10380 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010381 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10382 .channel_mode = alc883_3ST_2ch_modes,
10383 .input_mux = &alc883_capture_source,
10384 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010385 [ALC883_CLEVO_M540R] = {
10386 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10387 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10388 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10389 .dac_nids = alc883_dac_nids,
10390 .dig_out_nid = ALC883_DIGOUT_NID,
10391 .dig_in_nid = ALC883_DIGIN_NID,
10392 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10393 .channel_mode = alc883_3ST_6ch_clevo_modes,
10394 .need_dac_fix = 1,
10395 .input_mux = &alc883_capture_source,
10396 /* This machine has the hardware HP auto-muting, thus
10397 * we need no software mute via unsol event
10398 */
10399 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010400 [ALC883_CLEVO_M720] = {
10401 .mixers = { alc883_clevo_m720_mixer },
10402 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010403 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10404 .dac_nids = alc883_dac_nids,
10405 .dig_out_nid = ALC883_DIGOUT_NID,
10406 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10407 .channel_mode = alc883_3ST_2ch_modes,
10408 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010409 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010410 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010411 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010412 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010413 [ALC883_LENOVO_101E_2ch] = {
10414 .mixers = { alc883_lenovo_101e_2ch_mixer},
10415 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10416 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10417 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010418 .adc_nids = alc883_adc_nids_alt,
10419 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010420 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010421 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10422 .channel_mode = alc883_3ST_2ch_modes,
10423 .input_mux = &alc883_lenovo_101e_capture_source,
10424 .unsol_event = alc883_lenovo_101e_unsol_event,
10425 .init_hook = alc883_lenovo_101e_all_automute,
10426 },
Kailang Yang272a5272007-05-14 11:00:38 +020010427 [ALC883_LENOVO_NB0763] = {
10428 .mixers = { alc883_lenovo_nb0763_mixer },
10429 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10430 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10431 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010432 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10433 .channel_mode = alc883_3ST_2ch_modes,
10434 .need_dac_fix = 1,
10435 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010436 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010437 .setup = alc883_medion_md2_setup,
10438 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +020010439 },
10440 [ALC888_LENOVO_MS7195_DIG] = {
10441 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10442 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10443 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10444 .dac_nids = alc883_dac_nids,
10445 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010446 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10447 .channel_mode = alc883_3ST_6ch_modes,
10448 .need_dac_fix = 1,
10449 .input_mux = &alc883_capture_source,
10450 .unsol_event = alc883_lenovo_ms7195_unsol_event,
10451 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +020010452 },
10453 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010454 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010455 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10456 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10457 .dac_nids = alc883_dac_nids,
10458 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010459 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10460 .channel_mode = alc883_3ST_2ch_modes,
10461 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010462 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010463 .setup = alc883_haier_w66_setup,
10464 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010465 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010466 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010467 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010468 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010469 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10470 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010471 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10472 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010473 .need_dac_fix = 1,
10474 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010475 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010476 .setup = alc888_3st_hp_setup,
10477 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010478 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010479 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010480 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010481 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10482 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10483 .dac_nids = alc883_dac_nids,
10484 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010485 .dig_in_nid = ALC883_DIGIN_NID,
10486 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10487 .channel_mode = alc883_sixstack_modes,
10488 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010489 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010490 .setup = alc888_6st_dell_setup,
10491 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010492 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010493 [ALC883_MITAC] = {
10494 .mixers = { alc883_mitac_mixer },
10495 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10496 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10497 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010498 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10499 .channel_mode = alc883_3ST_2ch_modes,
10500 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010501 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010502 .setup = alc883_mitac_setup,
10503 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010504 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010505 [ALC883_FUJITSU_PI2515] = {
10506 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10507 .init_verbs = { alc883_init_verbs,
10508 alc883_2ch_fujitsu_pi2515_verbs},
10509 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10510 .dac_nids = alc883_dac_nids,
10511 .dig_out_nid = ALC883_DIGOUT_NID,
10512 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10513 .channel_mode = alc883_3ST_2ch_modes,
10514 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010515 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010516 .setup = alc883_2ch_fujitsu_pi2515_setup,
10517 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +010010518 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010519 [ALC888_FUJITSU_XA3530] = {
10520 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10521 .init_verbs = { alc883_init_verbs,
10522 alc888_fujitsu_xa3530_verbs },
10523 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10524 .dac_nids = alc883_dac_nids,
10525 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10526 .adc_nids = alc883_adc_nids_rev,
10527 .capsrc_nids = alc883_capsrc_nids_rev,
10528 .dig_out_nid = ALC883_DIGOUT_NID,
10529 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10530 .channel_mode = alc888_4ST_8ch_intel_modes,
10531 .num_mux_defs =
10532 ARRAY_SIZE(alc888_2_capture_sources),
10533 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010534 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010535 .setup = alc888_fujitsu_xa3530_setup,
10536 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010537 },
Kailang Yange2757d52008-08-26 13:17:46 +020010538 [ALC888_LENOVO_SKY] = {
10539 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10540 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10541 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10542 .dac_nids = alc883_dac_nids,
10543 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010544 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10545 .channel_mode = alc883_sixstack_modes,
10546 .need_dac_fix = 1,
10547 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010548 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010549 .setup = alc888_lenovo_sky_setup,
10550 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +020010551 },
10552 [ALC888_ASUS_M90V] = {
10553 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10554 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10555 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10556 .dac_nids = alc883_dac_nids,
10557 .dig_out_nid = ALC883_DIGOUT_NID,
10558 .dig_in_nid = ALC883_DIGIN_NID,
10559 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10560 .channel_mode = alc883_3ST_6ch_modes,
10561 .need_dac_fix = 1,
10562 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010563 .unsol_event = alc_sku_unsol_event,
10564 .setup = alc883_mode2_setup,
10565 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010566 },
10567 [ALC888_ASUS_EEE1601] = {
10568 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010569 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010570 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10571 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10572 .dac_nids = alc883_dac_nids,
10573 .dig_out_nid = ALC883_DIGOUT_NID,
10574 .dig_in_nid = ALC883_DIGIN_NID,
10575 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10576 .channel_mode = alc883_3ST_2ch_modes,
10577 .need_dac_fix = 1,
10578 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010579 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010580 .init_hook = alc883_eee1601_inithook,
10581 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010582 [ALC1200_ASUS_P5Q] = {
10583 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10584 .init_verbs = { alc883_init_verbs },
10585 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10586 .dac_nids = alc883_dac_nids,
10587 .dig_out_nid = ALC1200_DIGOUT_NID,
10588 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010589 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010590 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10591 .channel_mode = alc883_sixstack_modes,
10592 .input_mux = &alc883_capture_source,
10593 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010594 [ALC889A_MB31] = {
10595 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10596 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10597 alc880_gpio1_init_verbs },
10598 .adc_nids = alc883_adc_nids,
10599 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010600 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010601 .dac_nids = alc883_dac_nids,
10602 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10603 .channel_mode = alc889A_mb31_6ch_modes,
10604 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10605 .input_mux = &alc889A_mb31_capture_source,
10606 .dig_out_nid = ALC883_DIGOUT_NID,
10607 .unsol_event = alc889A_mb31_unsol_event,
10608 .init_hook = alc889A_mb31_automute,
10609 },
Guido Günther3e1647c2009-06-05 00:47:26 +020010610 [ALC883_SONY_VAIO_TT] = {
10611 .mixers = { alc883_vaiott_mixer },
10612 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10613 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10614 .dac_nids = alc883_dac_nids,
10615 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10616 .channel_mode = alc883_3ST_2ch_modes,
10617 .input_mux = &alc883_capture_source,
10618 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010619 .setup = alc883_vaiott_setup,
10620 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +020010621 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010622};
10623
10624
10625/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010626 * Pin config fixes
10627 */
10628enum {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010629 PINFIX_ABIT_AW9D_MAX,
10630 PINFIX_PB_M5210,
David Henningssonc3d226a2010-10-14 15:42:08 +020010631 PINFIX_ACER_ASPIRE_7736,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010632};
10633
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010634static const struct alc_fixup alc882_fixups[] = {
10635 [PINFIX_ABIT_AW9D_MAX] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020010636 .pins = (const struct alc_pincfg[]) {
10637 { 0x15, 0x01080104 }, /* side */
10638 { 0x16, 0x01011012 }, /* rear */
10639 { 0x17, 0x01016011 }, /* clfe */
10640 { }
10641 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010642 },
Takashi Iwai954a29c2010-07-30 10:55:44 +020010643 [PINFIX_PB_M5210] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020010644 .verbs = (const struct hda_verb[]) {
10645 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
10646 {}
10647 }
Takashi Iwai954a29c2010-07-30 10:55:44 +020010648 },
David Henningssonc3d226a2010-10-14 15:42:08 +020010649 [PINFIX_ACER_ASPIRE_7736] = {
10650 .sku = ALC_FIXUP_SKU_IGNORE,
10651 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010652};
10653
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010654static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010655 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010656 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
David Henningssonc3d226a2010-10-14 15:42:08 +020010657 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010658 {}
10659};
10660
10661/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010662 * BIOS auto configuration
10663 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010664static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10665 const struct auto_pin_cfg *cfg)
10666{
10667 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10668}
10669
Takashi Iwai4953550a2009-06-30 15:28:30 +020010670static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010671 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010672 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010673{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010674 int idx;
10675
Takashi Iwai489008c2010-04-07 09:06:00 +020010676 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010677 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010678
Takashi Iwai489008c2010-04-07 09:06:00 +020010679 if (dac == 0x25)
10680 idx = 4;
10681 else if (dac >= 0x02 && dac <= 0x05)
10682 idx = dac - 2;
10683 else
10684 return;
10685 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010686}
10687
Takashi Iwai4953550a2009-06-30 15:28:30 +020010688static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010689{
10690 struct alc_spec *spec = codec->spec;
10691 int i;
10692
10693 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010694 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010695 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010696 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010697 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010698 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010699 }
10700}
10701
Takashi Iwai4953550a2009-06-30 15:28:30 +020010702static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010703{
10704 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020010705 hda_nid_t pin, dac;
Takashi Iwai5855fb82010-09-16 18:24:02 +020010706 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010707
Takashi Iwai5855fb82010-09-16 18:24:02 +020010708 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
10709 pin = spec->autocfg.hp_pins[i];
10710 if (!pin)
10711 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010712 dac = spec->multiout.hp_nid;
10713 if (!dac)
10714 dac = spec->multiout.dac_nids[0]; /* to front */
10715 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10716 }
Takashi Iwai5855fb82010-09-16 18:24:02 +020010717 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
10718 pin = spec->autocfg.speaker_pins[i];
10719 if (!pin)
10720 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010721 dac = spec->multiout.extra_out_nid[0];
10722 if (!dac)
10723 dac = spec->multiout.dac_nids[0]; /* to front */
10724 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10725 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010726}
10727
Takashi Iwai4953550a2009-06-30 15:28:30 +020010728static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010729{
10730 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010731 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010732 int i;
10733
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010734 for (i = 0; i < cfg->num_inputs; i++) {
10735 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai30ea0982010-09-16 18:47:56 +020010736 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010737 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10738 snd_hda_codec_write(codec, nid, 0,
10739 AC_VERB_SET_AMP_GAIN_MUTE,
10740 AMP_OUT_MUTE);
10741 }
10742}
10743
10744static void alc882_auto_init_input_src(struct hda_codec *codec)
10745{
10746 struct alc_spec *spec = codec->spec;
10747 int c;
10748
10749 for (c = 0; c < spec->num_adc_nids; c++) {
10750 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10751 hda_nid_t nid = spec->capsrc_nids[c];
10752 unsigned int mux_idx;
10753 const struct hda_input_mux *imux;
10754 int conns, mute, idx, item;
10755
10756 conns = snd_hda_get_connections(codec, nid, conn_list,
10757 ARRAY_SIZE(conn_list));
10758 if (conns < 0)
10759 continue;
10760 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10761 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010762 if (!imux->num_items && mux_idx > 0)
10763 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010764 for (idx = 0; idx < conns; idx++) {
10765 /* if the current connection is the selected one,
10766 * unmute it as default - otherwise mute it
10767 */
10768 mute = AMP_IN_MUTE(idx);
10769 for (item = 0; item < imux->num_items; item++) {
10770 if (imux->items[item].index == idx) {
10771 if (spec->cur_mux[c] == item)
10772 mute = AMP_IN_UNMUTE(idx);
10773 break;
10774 }
10775 }
10776 /* check if we have a selector or mixer
10777 * we could check for the widget type instead, but
10778 * just check for Amp-In presence (in case of mixer
10779 * without amp-in there is something wrong, this
10780 * function shouldn't be used or capsrc nid is wrong)
10781 */
10782 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010783 snd_hda_codec_write(codec, nid, 0,
10784 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010785 mute);
10786 else if (mute != AMP_IN_MUTE(idx))
10787 snd_hda_codec_write(codec, nid, 0,
10788 AC_VERB_SET_CONNECT_SEL,
10789 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010790 }
10791 }
10792}
10793
Takashi Iwai4953550a2009-06-30 15:28:30 +020010794/* add mic boosts if needed */
10795static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010796{
10797 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010798 struct auto_pin_cfg *cfg = &spec->autocfg;
10799 int i, err;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010800 hda_nid_t nid;
10801
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010802 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +020010803 if (cfg->inputs[i].type > AUTO_PIN_MIC)
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010804 break;
10805 nid = cfg->inputs[i].pin;
10806 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
Takashi Iwai10a20af2010-09-09 16:28:02 +020010807 char label[32];
10808 snprintf(label, sizeof(label), "%s Boost",
10809 hda_get_autocfg_input_label(codec, cfg, i));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010810 err = add_control(spec, ALC_CTL_WIDGET_VOL, label, 0,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010811 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010812 if (err < 0)
10813 return err;
10814 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010815 }
10816 return 0;
10817}
10818
10819/* almost identical with ALC880 parser... */
10820static int alc882_parse_auto_config(struct hda_codec *codec)
10821{
10822 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010823 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai757899a2010-07-30 10:48:14 +020010824 int err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010825
Takashi Iwai05f5f472009-08-25 13:10:18 +020010826 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10827 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010828 if (err < 0)
10829 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010830 if (!spec->autocfg.line_outs)
10831 return 0; /* can't find valid BIOS pin config */
10832
10833 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10834 if (err < 0)
10835 return err;
10836 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10837 if (err < 0)
10838 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020010839 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10840 "Headphone");
10841 if (err < 0)
10842 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010843 err = alc880_auto_create_extra_out(spec,
10844 spec->autocfg.speaker_pins[0],
10845 "Speaker");
10846 if (err < 0)
10847 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010848 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10849 if (err < 0)
10850 return err;
10851
10852 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10853
Takashi Iwai757899a2010-07-30 10:48:14 +020010854 alc_auto_parse_digital(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010855
10856 if (spec->kctls.list)
10857 add_mixer(spec, spec->kctls.list);
10858
10859 add_verb(spec, alc883_auto_init_verbs);
10860 /* if ADC 0x07 is available, initialize it, too */
10861 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10862 add_verb(spec, alc882_adc1_init_verbs);
10863
10864 spec->num_mux_defs = 1;
10865 spec->input_mux = &spec->private_imux[0];
10866
Kailang Yang6227cdc2010-02-25 08:36:52 +010010867 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010868
10869 err = alc_auto_add_mic_boost(codec);
10870 if (err < 0)
10871 return err;
10872
Takashi Iwai776e1842007-08-29 15:07:11 +020010873 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010874}
10875
10876/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010877static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010878{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010879 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010880 alc882_auto_init_multi_out(codec);
10881 alc882_auto_init_hp_out(codec);
10882 alc882_auto_init_analog_input(codec);
10883 alc882_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020010884 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010885 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010886 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010887}
10888
Takashi Iwai4953550a2009-06-30 15:28:30 +020010889static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010890{
10891 struct alc_spec *spec;
10892 int err, board_config;
10893
10894 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10895 if (spec == NULL)
10896 return -ENOMEM;
10897
10898 codec->spec = spec;
10899
Takashi Iwai4953550a2009-06-30 15:28:30 +020010900 switch (codec->vendor_id) {
10901 case 0x10ec0882:
10902 case 0x10ec0885:
10903 break;
10904 default:
10905 /* ALC883 and variants */
10906 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10907 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010908 }
10909
Takashi Iwai4953550a2009-06-30 15:28:30 +020010910 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10911 alc882_models,
10912 alc882_cfg_tbl);
10913
10914 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10915 board_config = snd_hda_check_board_codec_sid_config(codec,
10916 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10917
10918 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010919 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010920 codec->chip_name);
10921 board_config = ALC882_AUTO;
10922 }
10923
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010924 if (board_config == ALC882_AUTO)
10925 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 1);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010926
David Henningsson90622912010-10-14 14:50:18 +020010927 alc_auto_parse_customize_define(codec);
10928
Takashi Iwai4953550a2009-06-30 15:28:30 +020010929 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010930 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010931 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010932 if (err < 0) {
10933 alc_free(codec);
10934 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010935 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010936 printk(KERN_INFO
10937 "hda_codec: Cannot set up configuration "
10938 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010939 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010940 }
10941 }
10942
Takashi Iwaidc1eae22010-07-29 15:30:02 +020010943 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020010944 err = snd_hda_attach_beep_device(codec, 0x1);
10945 if (err < 0) {
10946 alc_free(codec);
10947 return err;
10948 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010949 }
10950
Takashi Iwai4953550a2009-06-30 15:28:30 +020010951 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010952 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010953
Takashi Iwai4953550a2009-06-30 15:28:30 +020010954 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10955 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10956 /* FIXME: setup DAC5 */
10957 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10958 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10959
10960 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10961 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10962
Takashi Iwai4953550a2009-06-30 15:28:30 +020010963 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010964 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010965 spec->num_adc_nids = 0;
10966 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010967 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010968 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010969 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010970 hda_nid_t nid = alc882_adc_nids[i];
10971 unsigned int wcap = get_wcaps(codec, nid);
10972 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010973 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010974 if (wcap != AC_WID_AUD_IN)
10975 continue;
10976 spec->private_adc_nids[spec->num_adc_nids] = nid;
10977 err = snd_hda_get_connections(codec, nid, &cap, 1);
10978 if (err < 0)
10979 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010980 err = snd_hda_get_connections(codec, cap, items,
10981 ARRAY_SIZE(items));
10982 if (err < 0)
10983 continue;
10984 for (j = 0; j < imux->num_items; j++)
10985 if (imux->items[j].index >= err)
10986 break;
10987 if (j < imux->num_items)
10988 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010989 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10990 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010991 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010992 spec->adc_nids = spec->private_adc_nids;
10993 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010994 }
10995
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010996 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010010997
Takashi Iwaidc1eae22010-07-29 15:30:02 +020010998 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010010999 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011000
Takashi Iwai7fa90e82010-04-12 08:49:00 +020011001 if (board_config == ALC882_AUTO)
11002 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 0);
11003
Takashi Iwai2134ea42008-01-10 16:53:55 +010011004 spec->vmaster_nid = 0x0c;
11005
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011006 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011007 if (board_config == ALC882_AUTO)
11008 spec->init_hook = alc882_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020011009
11010 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020011011#ifdef CONFIG_SND_HDA_POWER_SAVE
11012 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020011013 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011014#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011015
11016 return 0;
11017}
11018
Takashi Iwai4953550a2009-06-30 15:28:30 +020011019
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011020/*
Kailang Yangdf694da2005-12-05 19:42:22 +010011021 * ALC262 support
11022 */
11023
11024#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
11025#define ALC262_DIGIN_NID ALC880_DIGIN_NID
11026
11027#define alc262_dac_nids alc260_dac_nids
11028#define alc262_adc_nids alc882_adc_nids
11029#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010011030#define alc262_capsrc_nids alc882_capsrc_nids
11031#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010011032
11033#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010011034#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010011035
Kailang Yang4e555fe2008-08-26 13:05:55 +020011036static hda_nid_t alc262_dmic_adc_nids[1] = {
11037 /* ADC0 */
11038 0x09
11039};
11040
11041static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
11042
Kailang Yangdf694da2005-12-05 19:42:22 +010011043static struct snd_kcontrol_new alc262_base_mixer[] = {
11044 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11045 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11046 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11047 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11048 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11049 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11050 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11051 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011052 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011053 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11054 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011055 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011056 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
11057 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11058 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
11059 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011060 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010011061};
11062
Takashi Iwaice875f02008-01-28 18:17:43 +010011063/* update HP, line and mono-out pins according to the master switch */
11064static void alc262_hp_master_update(struct hda_codec *codec)
11065{
11066 struct alc_spec *spec = codec->spec;
11067 int val = spec->master_sw;
11068
11069 /* HP & line-out */
11070 snd_hda_codec_write_cache(codec, 0x1b, 0,
11071 AC_VERB_SET_PIN_WIDGET_CONTROL,
11072 val ? PIN_HP : 0);
11073 snd_hda_codec_write_cache(codec, 0x15, 0,
11074 AC_VERB_SET_PIN_WIDGET_CONTROL,
11075 val ? PIN_HP : 0);
11076 /* mono (speaker) depending on the HP jack sense */
11077 val = val && !spec->jack_present;
11078 snd_hda_codec_write_cache(codec, 0x16, 0,
11079 AC_VERB_SET_PIN_WIDGET_CONTROL,
11080 val ? PIN_OUT : 0);
11081}
11082
11083static void alc262_hp_bpc_automute(struct hda_codec *codec)
11084{
11085 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011086
11087 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010011088 alc262_hp_master_update(codec);
11089}
11090
11091static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
11092{
11093 if ((res >> 26) != ALC880_HP_EVENT)
11094 return;
11095 alc262_hp_bpc_automute(codec);
11096}
11097
11098static void alc262_hp_wildwest_automute(struct hda_codec *codec)
11099{
11100 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011101
11102 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010011103 alc262_hp_master_update(codec);
11104}
11105
11106static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
11107 unsigned int res)
11108{
11109 if ((res >> 26) != ALC880_HP_EVENT)
11110 return;
11111 alc262_hp_wildwest_automute(codec);
11112}
11113
Takashi Iwaib72519b2009-05-08 14:31:55 +020011114#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010011115
11116static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
11117 struct snd_ctl_elem_value *ucontrol)
11118{
11119 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11120 struct alc_spec *spec = codec->spec;
11121 int val = !!*ucontrol->value.integer.value;
11122
11123 if (val == spec->master_sw)
11124 return 0;
11125 spec->master_sw = val;
11126 alc262_hp_master_update(codec);
11127 return 1;
11128}
11129
Takashi Iwaib72519b2009-05-08 14:31:55 +020011130#define ALC262_HP_MASTER_SWITCH \
11131 { \
11132 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11133 .name = "Master Playback Switch", \
11134 .info = snd_ctl_boolean_mono_info, \
11135 .get = alc262_hp_master_sw_get, \
11136 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011137 }, \
11138 { \
11139 .iface = NID_MAPPING, \
11140 .name = "Master Playback Switch", \
11141 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020011142 }
11143
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011144
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011145static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011146 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011147 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11148 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11149 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011150 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11151 HDA_OUTPUT),
11152 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11153 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011154 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11155 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011156 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011157 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11158 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011159 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011160 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11161 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11162 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11163 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011164 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
11165 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
11166 { } /* end */
11167};
11168
Kailang Yangcd7509a2007-01-26 18:33:17 +010011169static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011170 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010011171 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11172 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11173 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11174 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011175 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11176 HDA_OUTPUT),
11177 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11178 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011179 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
11180 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011181 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011182 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11183 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11184 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11185 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011186 { } /* end */
11187};
11188
11189static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
11190 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11191 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011192 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011193 { } /* end */
11194};
11195
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011196/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011197static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011198{
11199 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011200
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011201 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010011202 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011203}
11204
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011205static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010011206 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11207 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011208 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11209 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11210 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11211 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11212 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11213 { } /* end */
11214};
11215
11216static struct hda_verb alc262_hp_t5735_verbs[] = {
11217 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11218 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11219
11220 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11221 { }
11222};
11223
Kailang Yang8c427222008-01-10 13:03:59 +010011224static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010011225 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11226 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010011227 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11228 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010011229 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11230 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11231 { } /* end */
11232};
11233
11234static struct hda_verb alc262_hp_rp5700_verbs[] = {
11235 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11236 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11237 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11238 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11239 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11240 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11241 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11242 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11243 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11244 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11245 {}
11246};
11247
11248static struct hda_input_mux alc262_hp_rp5700_capture_source = {
11249 .num_items = 1,
11250 .items = {
11251 { "Line", 0x1 },
11252 },
11253};
11254
Takashi Iwai42171c12009-05-08 14:11:43 +020011255/* bind hp and internal speaker mute (with plug check) as master switch */
11256static void alc262_hippo_master_update(struct hda_codec *codec)
11257{
11258 struct alc_spec *spec = codec->spec;
11259 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11260 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11261 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11262 unsigned int mute;
11263
11264 /* HP */
11265 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
11266 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
11267 HDA_AMP_MUTE, mute);
11268 /* mute internal speaker per jack sense */
11269 if (spec->jack_present)
11270 mute = HDA_AMP_MUTE;
11271 if (line_nid)
11272 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
11273 HDA_AMP_MUTE, mute);
11274 if (speaker_nid && speaker_nid != line_nid)
11275 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
11276 HDA_AMP_MUTE, mute);
11277}
11278
11279#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
11280
11281static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
11282 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020011283{
11284 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020011285 struct alc_spec *spec = codec->spec;
11286 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011287
Takashi Iwai42171c12009-05-08 14:11:43 +020011288 if (val == spec->master_sw)
11289 return 0;
11290 spec->master_sw = val;
11291 alc262_hippo_master_update(codec);
11292 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011293}
Takashi Iwai5b319542007-07-26 11:49:22 +020011294
Takashi Iwai42171c12009-05-08 14:11:43 +020011295#define ALC262_HIPPO_MASTER_SWITCH \
11296 { \
11297 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11298 .name = "Master Playback Switch", \
11299 .info = snd_ctl_boolean_mono_info, \
11300 .get = alc262_hippo_master_sw_get, \
11301 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011302 }, \
11303 { \
11304 .iface = NID_MAPPING, \
11305 .name = "Master Playback Switch", \
11306 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
11307 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020011308 }
11309
11310static struct snd_kcontrol_new alc262_hippo_mixer[] = {
11311 ALC262_HIPPO_MASTER_SWITCH,
11312 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11313 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11314 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11315 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11316 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11317 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11318 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11319 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11320 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11321 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11322 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11323 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11324 { } /* end */
11325};
11326
11327static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
11328 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11329 ALC262_HIPPO_MASTER_SWITCH,
11330 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11331 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11332 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11333 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11334 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11335 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11336 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11337 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11338 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11339 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11340 { } /* end */
11341};
11342
11343/* mute/unmute internal speaker according to the hp jack and mute state */
11344static void alc262_hippo_automute(struct hda_codec *codec)
11345{
11346 struct alc_spec *spec = codec->spec;
11347 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020011348
Wu Fengguang864f92b2009-11-18 12:38:02 +080011349 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020011350 alc262_hippo_master_update(codec);
11351}
11352
11353static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
11354{
11355 if ((res >> 26) != ALC880_HP_EVENT)
11356 return;
11357 alc262_hippo_automute(codec);
11358}
11359
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011360static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011361{
11362 struct alc_spec *spec = codec->spec;
11363
11364 spec->autocfg.hp_pins[0] = 0x15;
11365 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011366}
11367
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011368static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011369{
11370 struct alc_spec *spec = codec->spec;
11371
11372 spec->autocfg.hp_pins[0] = 0x1b;
11373 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011374}
11375
11376
Kailang Yang272a5272007-05-14 11:00:38 +020011377static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011378 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011379 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011380 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11381 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11382 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11383 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11384 { } /* end */
11385};
11386
Kailang Yang83c34212007-07-05 11:43:05 +020011387static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011388 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11389 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011390 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11391 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11392 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11393 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11394 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11395 { } /* end */
11396};
Kailang Yang272a5272007-05-14 11:00:38 +020011397
Tony Vroonba340e82009-02-02 19:01:30 +000011398static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11399 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11400 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11401 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11402 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11403 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11404 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11405 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11406 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11407 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11408 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11409 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11410 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11411 { } /* end */
11412};
11413
11414static struct hda_verb alc262_tyan_verbs[] = {
11415 /* Headphone automute */
11416 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11417 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11418 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11419
11420 /* P11 AUX_IN, white 4-pin connector */
11421 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11422 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11423 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11424 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11425
11426 {}
11427};
11428
11429/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011430static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011431{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011432 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011433
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011434 spec->autocfg.hp_pins[0] = 0x1b;
11435 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000011436}
11437
Tony Vroonba340e82009-02-02 19:01:30 +000011438
Kailang Yangdf694da2005-12-05 19:42:22 +010011439#define alc262_capture_mixer alc882_capture_mixer
11440#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11441
11442/*
11443 * generic initialization of ADC, input mixers and output mixers
11444 */
11445static struct hda_verb alc262_init_verbs[] = {
11446 /*
11447 * Unmute ADC0-2 and set the default input to mic-in
11448 */
11449 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11450 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11451 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11452 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11453 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11454 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11455
Takashi Iwaicb53c622007-08-10 17:21:45 +020011456 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011457 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011458 * Note: PASD motherboards uses the Line In 2 as the input for
11459 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011460 */
11461 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011462 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11463 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11464 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11465 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11466 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011467
11468 /*
11469 * Set up output mixers (0x0c - 0x0e)
11470 */
11471 /* set vol=0 to output mixers */
11472 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11473 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11474 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11475 /* set up input amps for analog loopback */
11476 /* Amp Indices: DAC = 0, mixer = 1 */
11477 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11478 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11479 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11480 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11481 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11482 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11483
11484 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11485 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11486 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11487 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11488 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11489 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11490
11491 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11492 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11493 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11494 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11495 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011496
Kailang Yangdf694da2005-12-05 19:42:22 +010011497 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11498 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011499
Kailang Yangdf694da2005-12-05 19:42:22 +010011500 /* FIXME: use matrix-type input source selection */
11501 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11502 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11503 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11504 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11505 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11506 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11507 /* Input mixer2 */
11508 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11509 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11510 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11511 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11512 /* Input mixer3 */
11513 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11514 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11515 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011516 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011517
11518 { }
11519};
11520
Kailang Yang4e555fe2008-08-26 13:05:55 +020011521static struct hda_verb alc262_eapd_verbs[] = {
11522 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11523 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11524 { }
11525};
11526
Kailang Yangccc656c2006-10-17 12:32:26 +020011527static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11528 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11529 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11530 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11531
11532 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11533 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11534 {}
11535};
11536
Kailang Yang272a5272007-05-14 11:00:38 +020011537static struct hda_verb alc262_sony_unsol_verbs[] = {
11538 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11539 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11540 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11541
11542 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11543 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011544 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011545};
11546
Kailang Yang4e555fe2008-08-26 13:05:55 +020011547static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11548 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11549 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11550 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11551 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11552 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011553 { } /* end */
11554};
11555
11556static struct hda_verb alc262_toshiba_s06_verbs[] = {
11557 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11558 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11559 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11560 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11561 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11562 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11563 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11564 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11565 {}
11566};
11567
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011568static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011569{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011570 struct alc_spec *spec = codec->spec;
11571
11572 spec->autocfg.hp_pins[0] = 0x15;
11573 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011574 spec->ext_mic.pin = 0x18;
11575 spec->ext_mic.mux_idx = 0;
11576 spec->int_mic.pin = 0x12;
11577 spec->int_mic.mux_idx = 9;
11578 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011579}
11580
Takashi Iwai834be882006-03-01 14:16:17 +010011581/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011582 * nec model
11583 * 0x15 = headphone
11584 * 0x16 = internal speaker
11585 * 0x18 = external mic
11586 */
11587
11588static struct snd_kcontrol_new alc262_nec_mixer[] = {
11589 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11590 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11591
11592 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11593 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11594 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11595
11596 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11597 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11598 { } /* end */
11599};
11600
11601static struct hda_verb alc262_nec_verbs[] = {
11602 /* Unmute Speaker */
11603 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11604
11605 /* Headphone */
11606 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11607 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11608
11609 /* External mic to headphone */
11610 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11611 /* External mic to speaker */
11612 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11613 {}
11614};
11615
11616/*
Takashi Iwai834be882006-03-01 14:16:17 +010011617 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011618 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11619 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011620 */
11621
11622#define ALC_HP_EVENT 0x37
11623
11624static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11625 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11626 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011627 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11628 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011629 {}
11630};
11631
Jiang zhe0e31daf2008-03-20 12:12:39 +010011632static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11633 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11634 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11635 {}
11636};
11637
Daniel T Chene2595322009-12-19 18:19:02 -050011638static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11639 /* Front Mic pin: input vref at 50% */
11640 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11641 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11642 {}
11643};
11644
Takashi Iwai834be882006-03-01 14:16:17 +010011645static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011646 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011647 .items = {
11648 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011649 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011650 { "CD", 0x4 },
11651 },
11652};
11653
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011654static struct hda_input_mux alc262_HP_capture_source = {
11655 .num_items = 5,
11656 .items = {
11657 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011658 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011659 { "Line", 0x2 },
11660 { "CD", 0x4 },
11661 { "AUX IN", 0x6 },
11662 },
11663};
11664
zhejiangaccbe492007-08-31 12:36:05 +020011665static struct hda_input_mux alc262_HP_D7000_capture_source = {
11666 .num_items = 4,
11667 .items = {
11668 { "Mic", 0x0 },
11669 { "Front Mic", 0x2 },
11670 { "Line", 0x1 },
11671 { "CD", 0x4 },
11672 },
11673};
11674
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011675/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011676static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11677{
11678 struct alc_spec *spec = codec->spec;
11679 unsigned int mute;
11680
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011681 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011682 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11683 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011684 spec->sense_updated = 1;
11685 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011686 /* unmute internal speaker only if both HPs are unplugged and
11687 * master switch is on
11688 */
11689 if (spec->jack_present)
11690 mute = HDA_AMP_MUTE;
11691 else
Takashi Iwai834be882006-03-01 14:16:17 +010011692 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011693 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11694 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011695}
11696
11697/* unsolicited event for HP jack sensing */
11698static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11699 unsigned int res)
11700{
11701 if ((res >> 26) != ALC_HP_EVENT)
11702 return;
11703 alc262_fujitsu_automute(codec, 1);
11704}
11705
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011706static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11707{
11708 alc262_fujitsu_automute(codec, 1);
11709}
11710
Takashi Iwai834be882006-03-01 14:16:17 +010011711/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011712static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11713 .ops = &snd_hda_bind_vol,
11714 .values = {
11715 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11716 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11717 0
11718 },
11719};
Takashi Iwai834be882006-03-01 14:16:17 +010011720
Jiang zhe0e31daf2008-03-20 12:12:39 +010011721/* mute/unmute internal speaker according to the hp jack and mute state */
11722static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11723{
11724 struct alc_spec *spec = codec->spec;
11725 unsigned int mute;
11726
11727 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011728 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011729 spec->sense_updated = 1;
11730 }
11731 if (spec->jack_present) {
11732 /* mute internal speaker */
11733 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11734 HDA_AMP_MUTE, HDA_AMP_MUTE);
11735 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11736 HDA_AMP_MUTE, HDA_AMP_MUTE);
11737 } else {
11738 /* unmute internal speaker if necessary */
11739 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11740 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11741 HDA_AMP_MUTE, mute);
11742 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11743 HDA_AMP_MUTE, mute);
11744 }
11745}
11746
11747/* unsolicited event for HP jack sensing */
11748static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11749 unsigned int res)
11750{
11751 if ((res >> 26) != ALC_HP_EVENT)
11752 return;
11753 alc262_lenovo_3000_automute(codec, 1);
11754}
11755
Takashi Iwai8de56b72009-07-24 16:51:47 +020011756static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11757 int dir, int idx, long *valp)
11758{
11759 int i, change = 0;
11760
11761 for (i = 0; i < 2; i++, valp++)
11762 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11763 HDA_AMP_MUTE,
11764 *valp ? 0 : HDA_AMP_MUTE);
11765 return change;
11766}
11767
Takashi Iwai834be882006-03-01 14:16:17 +010011768/* bind hp and internal speaker mute (with plug check) */
11769static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11770 struct snd_ctl_elem_value *ucontrol)
11771{
11772 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11773 long *valp = ucontrol->value.integer.value;
11774 int change;
11775
Takashi Iwai8de56b72009-07-24 16:51:47 +020011776 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11777 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011778 if (change)
11779 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011780 return change;
11781}
11782
11783static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011784 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011785 {
11786 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11787 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011788 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011789 .info = snd_hda_mixer_amp_switch_info,
11790 .get = snd_hda_mixer_amp_switch_get,
11791 .put = alc262_fujitsu_master_sw_put,
11792 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11793 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011794 {
11795 .iface = NID_MAPPING,
11796 .name = "Master Playback Switch",
11797 .private_value = 0x1b,
11798 },
Takashi Iwai834be882006-03-01 14:16:17 +010011799 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11800 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11801 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11802 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11803 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011804 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11805 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11806 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011807 { } /* end */
11808};
11809
Jiang zhe0e31daf2008-03-20 12:12:39 +010011810/* bind hp and internal speaker mute (with plug check) */
11811static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11812 struct snd_ctl_elem_value *ucontrol)
11813{
11814 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11815 long *valp = ucontrol->value.integer.value;
11816 int change;
11817
Takashi Iwai8de56b72009-07-24 16:51:47 +020011818 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011819 if (change)
11820 alc262_lenovo_3000_automute(codec, 0);
11821 return change;
11822}
11823
11824static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11825 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11826 {
11827 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11828 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011829 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011830 .info = snd_hda_mixer_amp_switch_info,
11831 .get = snd_hda_mixer_amp_switch_get,
11832 .put = alc262_lenovo_3000_master_sw_put,
11833 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11834 },
11835 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11836 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11837 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11838 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11839 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11840 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11841 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11842 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11843 { } /* end */
11844};
11845
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011846static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11847 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011848 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011849 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11850 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11851 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11852 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11853 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11854 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11855 { } /* end */
11856};
11857
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011858/* additional init verbs for Benq laptops */
11859static struct hda_verb alc262_EAPD_verbs[] = {
11860 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11861 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11862 {}
11863};
11864
Kailang Yang83c34212007-07-05 11:43:05 +020011865static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11866 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11867 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11868
11869 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11870 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11871 {}
11872};
11873
Tobin Davisf651b502007-10-26 12:40:47 +020011874/* Samsung Q1 Ultra Vista model setup */
11875static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011876 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11877 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011878 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11879 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11880 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011881 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011882 { } /* end */
11883};
11884
11885static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011886 /* output mixer */
11887 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11888 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11889 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11890 /* speaker */
11891 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11892 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11893 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11894 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11895 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011896 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011897 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11898 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11899 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11900 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11901 /* internal mic */
11902 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11903 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11904 /* ADC, choose mic */
11905 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11906 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11907 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11908 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11909 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11910 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11911 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11912 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11913 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11914 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011915 {}
11916};
11917
Tobin Davisf651b502007-10-26 12:40:47 +020011918/* mute/unmute internal speaker according to the hp jack and mute state */
11919static void alc262_ultra_automute(struct hda_codec *codec)
11920{
11921 struct alc_spec *spec = codec->spec;
11922 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011923
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011924 mute = 0;
11925 /* auto-mute only when HP is used as HP */
11926 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011927 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011928 if (spec->jack_present)
11929 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011930 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011931 /* mute/unmute internal speaker */
11932 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11933 HDA_AMP_MUTE, mute);
11934 /* mute/unmute HP */
11935 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11936 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011937}
11938
11939/* unsolicited event for HP jack sensing */
11940static void alc262_ultra_unsol_event(struct hda_codec *codec,
11941 unsigned int res)
11942{
11943 if ((res >> 26) != ALC880_HP_EVENT)
11944 return;
11945 alc262_ultra_automute(codec);
11946}
11947
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011948static struct hda_input_mux alc262_ultra_capture_source = {
11949 .num_items = 2,
11950 .items = {
11951 { "Mic", 0x1 },
11952 { "Headphone", 0x7 },
11953 },
11954};
11955
11956static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11957 struct snd_ctl_elem_value *ucontrol)
11958{
11959 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11960 struct alc_spec *spec = codec->spec;
11961 int ret;
11962
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011963 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011964 if (!ret)
11965 return 0;
11966 /* reprogram the HP pin as mic or HP according to the input source */
11967 snd_hda_codec_write_cache(codec, 0x15, 0,
11968 AC_VERB_SET_PIN_WIDGET_CONTROL,
11969 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11970 alc262_ultra_automute(codec); /* mute/unmute HP */
11971 return ret;
11972}
11973
11974static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11975 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11976 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11977 {
11978 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11979 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011980 .info = alc_mux_enum_info,
11981 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011982 .put = alc262_ultra_mux_enum_put,
11983 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011984 {
11985 .iface = NID_MAPPING,
11986 .name = "Capture Source",
11987 .private_value = 0x15,
11988 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011989 { } /* end */
11990};
11991
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011992/* We use two mixers depending on the output pin; 0x16 is a mono output
11993 * and thus it's bound with a different mixer.
11994 * This function returns which mixer amp should be used.
11995 */
11996static int alc262_check_volbit(hda_nid_t nid)
11997{
11998 if (!nid)
11999 return 0;
12000 else if (nid == 0x16)
12001 return 2;
12002 else
12003 return 1;
12004}
12005
12006static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012007 const char *pfx, int *vbits, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012008{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012009 unsigned long val;
12010 int vbit;
12011
12012 vbit = alc262_check_volbit(nid);
12013 if (!vbit)
12014 return 0;
12015 if (*vbits & vbit) /* a volume control for this mixer already there */
12016 return 0;
12017 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012018 if (vbit == 2)
12019 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
12020 else
12021 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012022 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012023}
12024
12025static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012026 const char *pfx, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012027{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012028 unsigned long val;
12029
12030 if (!nid)
12031 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012032 if (nid == 0x16)
12033 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
12034 else
12035 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012036 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012037}
12038
Kailang Yangdf694da2005-12-05 19:42:22 +010012039/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012040static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
12041 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012042{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012043 const char *pfx;
12044 int vbits;
Takashi Iwai033688a2010-09-08 15:47:09 +020012045 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +010012046
12047 spec->multiout.num_dacs = 1; /* only use one dac */
12048 spec->multiout.dac_nids = spec->private_dac_nids;
12049 spec->multiout.dac_nids[0] = 2;
12050
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012051 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
12052 pfx = "Master";
12053 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12054 pfx = "Speaker";
Takashi Iwai033688a2010-09-08 15:47:09 +020012055 else if (cfg->line_out_type == AUTO_PIN_HP_OUT)
12056 pfx = "Headphone";
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012057 else
12058 pfx = "Front";
Takashi Iwai033688a2010-09-08 15:47:09 +020012059 for (i = 0; i < 2; i++) {
12060 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, i);
12061 if (err < 0)
12062 return err;
12063 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12064 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i],
12065 "Speaker", i);
12066 if (err < 0)
12067 return err;
12068 }
12069 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12070 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i],
12071 "Headphone", i);
12072 if (err < 0)
12073 return err;
12074 }
12075 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012076
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012077 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
12078 alc262_check_volbit(cfg->speaker_pins[0]) |
12079 alc262_check_volbit(cfg->hp_pins[0]);
12080 if (vbits == 1 || vbits == 2)
12081 pfx = "Master"; /* only one mixer is used */
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012082 vbits = 0;
Takashi Iwai033688a2010-09-08 15:47:09 +020012083 for (i = 0; i < 2; i++) {
12084 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx,
12085 &vbits, i);
12086 if (err < 0)
12087 return err;
12088 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12089 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i],
12090 "Speaker", &vbits, i);
12091 if (err < 0)
12092 return err;
12093 }
12094 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12095 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i],
12096 "Headphone", &vbits, i);
12097 if (err < 0)
12098 return err;
12099 }
12100 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012101 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010012102}
12103
Takashi Iwai05f5f472009-08-25 13:10:18 +020012104#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010012105 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010012106
12107/*
12108 * generic initialization of ADC, input mixers and output mixers
12109 */
12110static struct hda_verb alc262_volume_init_verbs[] = {
12111 /*
12112 * Unmute ADC0-2 and set the default input to mic-in
12113 */
12114 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12115 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12116 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12117 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12118 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12119 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12120
Takashi Iwaicb53c622007-08-10 17:21:45 +020012121 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010012122 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012123 * Note: PASD motherboards uses the Line In 2 as the input for
12124 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010012125 */
12126 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012127 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12128 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12129 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12130 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12131 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012132
12133 /*
12134 * Set up output mixers (0x0c - 0x0f)
12135 */
12136 /* set vol=0 to output mixers */
12137 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12138 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12139 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020012140
Kailang Yangdf694da2005-12-05 19:42:22 +010012141 /* set up input amps for analog loopback */
12142 /* Amp Indices: DAC = 0, mixer = 1 */
12143 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12144 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12145 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12146 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12147 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12148 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12149
12150 /* FIXME: use matrix-type input source selection */
12151 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12152 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12153 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12154 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12155 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12156 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12157 /* Input mixer2 */
12158 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12159 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12160 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12161 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12162 /* Input mixer3 */
12163 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12164 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12165 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12166 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12167
12168 { }
12169};
12170
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012171static struct hda_verb alc262_HP_BPC_init_verbs[] = {
12172 /*
12173 * Unmute ADC0-2 and set the default input to mic-in
12174 */
12175 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12176 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12177 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12178 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12179 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12180 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12181
Takashi Iwaicb53c622007-08-10 17:21:45 +020012182 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012183 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012184 * Note: PASD motherboards uses the Line In 2 as the input for
12185 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012186 */
12187 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012188 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12189 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12190 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12191 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12192 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12193 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12194 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012195
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012196 /*
12197 * Set up output mixers (0x0c - 0x0e)
12198 */
12199 /* set vol=0 to output mixers */
12200 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12201 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12202 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12203
12204 /* set up input amps for analog loopback */
12205 /* Amp Indices: DAC = 0, mixer = 1 */
12206 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12207 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12208 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12209 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12210 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12211 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12212
Takashi Iwaice875f02008-01-28 18:17:43 +010012213 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012214 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12215 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12216
12217 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12218 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12219
12220 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12221 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12222
12223 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12224 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12225 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12226 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12227 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12228
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012229 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012230 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12231 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012232 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012233 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12234 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12235
12236
12237 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012238 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
12239 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012240 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012241 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12242 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12243 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12244 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12245 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12246 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12247 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12248 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012249 /* Input mixer2 */
12250 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012251 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12252 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12253 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12254 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12255 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12256 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12257 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12258 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012259 /* Input mixer3 */
12260 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012261 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12262 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12263 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12264 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12265 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12266 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12267 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12268 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012269
Takashi Iwaice875f02008-01-28 18:17:43 +010012270 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12271
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012272 { }
12273};
12274
Kailang Yangcd7509a2007-01-26 18:33:17 +010012275static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
12276 /*
12277 * Unmute ADC0-2 and set the default input to mic-in
12278 */
12279 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12280 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12281 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12282 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12283 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12284 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12285
Takashi Iwaicb53c622007-08-10 17:21:45 +020012286 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010012287 * mixer widget
12288 * Note: PASD motherboards uses the Line In 2 as the input for front
12289 * panel mic (mic 2)
12290 */
12291 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012292 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12293 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12294 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12295 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12296 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12297 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12298 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12299 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010012300 /*
12301 * Set up output mixers (0x0c - 0x0e)
12302 */
12303 /* set vol=0 to output mixers */
12304 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12305 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12306 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12307
12308 /* set up input amps for analog loopback */
12309 /* Amp Indices: DAC = 0, mixer = 1 */
12310 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12311 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12312 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12313 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12314 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12315 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12316
12317
12318 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
12319 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
12320 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
12321 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
12322 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12323 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
12324 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
12325
12326 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12327 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12328
12329 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12330 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12331
12332 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
12333 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12334 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12335 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
12336 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12337 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12338
12339 /* FIXME: use matrix-type input source selection */
12340 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12341 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12342 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
12343 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
12344 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
12345 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
12346 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
12347 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12348 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
12349 /* Input mixer2 */
12350 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12351 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12352 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12353 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12354 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12355 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12356 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12357 /* Input mixer3 */
12358 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12359 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12360 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12361 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12362 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12363 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12364 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12365
Takashi Iwaice875f02008-01-28 18:17:43 +010012366 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12367
Kailang Yangcd7509a2007-01-26 18:33:17 +010012368 { }
12369};
12370
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012371static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
12372
12373 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12374 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12375 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12376
12377 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12378 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12379 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12380 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12381
12382 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12383 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12384 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12385 {}
12386};
12387
Takashi Iwai18675e42010-09-08 15:55:44 +020012388/*
12389 * Pin config fixes
12390 */
12391enum {
12392 PINFIX_FSC_H270,
12393};
12394
12395static const struct alc_fixup alc262_fixups[] = {
12396 [PINFIX_FSC_H270] = {
12397 .pins = (const struct alc_pincfg[]) {
12398 { 0x14, 0x99130110 }, /* speaker */
12399 { 0x15, 0x0221142f }, /* front HP */
12400 { 0x1b, 0x0121141f }, /* rear HP */
12401 { }
12402 }
12403 },
12404 [PINFIX_PB_M5210] = {
12405 .verbs = (const struct hda_verb[]) {
12406 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
12407 {}
12408 }
12409 },
12410};
12411
12412static struct snd_pci_quirk alc262_fixup_tbl[] = {
12413 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270),
12414 {}
12415};
12416
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012417
Takashi Iwaicb53c622007-08-10 17:21:45 +020012418#ifdef CONFIG_SND_HDA_POWER_SAVE
12419#define alc262_loopbacks alc880_loopbacks
12420#endif
12421
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012422/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012423#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12424#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12425#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12426#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12427
12428/*
12429 * BIOS auto configuration
12430 */
12431static int alc262_parse_auto_config(struct hda_codec *codec)
12432{
12433 struct alc_spec *spec = codec->spec;
12434 int err;
12435 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12436
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012437 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12438 alc262_ignore);
12439 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012440 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012441 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012442 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012443 spec->multiout.max_channels = 2;
12444 spec->no_analog = 1;
12445 goto dig_only;
12446 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012447 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012448 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012449 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12450 if (err < 0)
12451 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012452 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012453 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012454 return err;
12455
12456 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12457
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012458 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012459 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012460
Takashi Iwai603c4012008-07-30 15:01:44 +020012461 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012462 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012463
Takashi Iwaid88897e2008-10-31 15:01:37 +010012464 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012465 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012466 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012467
Takashi Iwai776e1842007-08-29 15:07:11 +020012468 err = alc_auto_add_mic_boost(codec);
12469 if (err < 0)
12470 return err;
12471
Kailang Yang6227cdc2010-02-25 08:36:52 +010012472 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012473
Kailang Yangdf694da2005-12-05 19:42:22 +010012474 return 1;
12475}
12476
12477#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12478#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12479#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012480#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012481
12482
12483/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012484static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012485{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012486 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012487 alc262_auto_init_multi_out(codec);
12488 alc262_auto_init_hp_out(codec);
12489 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012490 alc262_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012491 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012492 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012493 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012494}
12495
12496/*
12497 * configuration and preset
12498 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012499static const char *alc262_models[ALC262_MODEL_LAST] = {
12500 [ALC262_BASIC] = "basic",
12501 [ALC262_HIPPO] = "hippo",
12502 [ALC262_HIPPO_1] = "hippo_1",
12503 [ALC262_FUJITSU] = "fujitsu",
12504 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012505 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012506 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012507 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012508 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012509 [ALC262_BENQ_T31] = "benq-t31",
12510 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012511 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012512 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012513 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012514 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012515 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012516 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012517 [ALC262_AUTO] = "auto",
12518};
12519
12520static struct snd_pci_quirk alc262_cfg_tbl[] = {
12521 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012522 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012523 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12524 ALC262_HP_BPC),
12525 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12526 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012527 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12528 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012529 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012530 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012531 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012532 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012533 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012534 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012535 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012536 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012537 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12538 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12539 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012540 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12541 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012542 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012543 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012544 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012545 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012546 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012547 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012548 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012549 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012550#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012551 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12552 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012553#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012554 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012555 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012556 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012557 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012558 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012559 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012560 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12561 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012562 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012563 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012564 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012565 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012566 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012567 {}
12568};
12569
12570static struct alc_config_preset alc262_presets[] = {
12571 [ALC262_BASIC] = {
12572 .mixers = { alc262_base_mixer },
12573 .init_verbs = { alc262_init_verbs },
12574 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12575 .dac_nids = alc262_dac_nids,
12576 .hp_nid = 0x03,
12577 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12578 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012579 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012580 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012581 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012582 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012583 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012584 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12585 .dac_nids = alc262_dac_nids,
12586 .hp_nid = 0x03,
12587 .dig_out_nid = ALC262_DIGOUT_NID,
12588 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12589 .channel_mode = alc262_modes,
12590 .input_mux = &alc262_capture_source,
12591 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012592 .setup = alc262_hippo_setup,
12593 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012594 },
12595 [ALC262_HIPPO_1] = {
12596 .mixers = { alc262_hippo1_mixer },
12597 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12598 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12599 .dac_nids = alc262_dac_nids,
12600 .hp_nid = 0x02,
12601 .dig_out_nid = ALC262_DIGOUT_NID,
12602 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12603 .channel_mode = alc262_modes,
12604 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012605 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012606 .setup = alc262_hippo1_setup,
12607 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012608 },
Takashi Iwai834be882006-03-01 14:16:17 +010012609 [ALC262_FUJITSU] = {
12610 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012611 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12612 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012613 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12614 .dac_nids = alc262_dac_nids,
12615 .hp_nid = 0x03,
12616 .dig_out_nid = ALC262_DIGOUT_NID,
12617 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12618 .channel_mode = alc262_modes,
12619 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012620 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012621 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012622 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012623 [ALC262_HP_BPC] = {
12624 .mixers = { alc262_HP_BPC_mixer },
12625 .init_verbs = { alc262_HP_BPC_init_verbs },
12626 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12627 .dac_nids = alc262_dac_nids,
12628 .hp_nid = 0x03,
12629 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12630 .channel_mode = alc262_modes,
12631 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012632 .unsol_event = alc262_hp_bpc_unsol_event,
12633 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012634 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012635 [ALC262_HP_BPC_D7000_WF] = {
12636 .mixers = { alc262_HP_BPC_WildWest_mixer },
12637 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12638 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12639 .dac_nids = alc262_dac_nids,
12640 .hp_nid = 0x03,
12641 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12642 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012643 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012644 .unsol_event = alc262_hp_wildwest_unsol_event,
12645 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012646 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012647 [ALC262_HP_BPC_D7000_WL] = {
12648 .mixers = { alc262_HP_BPC_WildWest_mixer,
12649 alc262_HP_BPC_WildWest_option_mixer },
12650 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12651 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12652 .dac_nids = alc262_dac_nids,
12653 .hp_nid = 0x03,
12654 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12655 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012656 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012657 .unsol_event = alc262_hp_wildwest_unsol_event,
12658 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012659 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012660 [ALC262_HP_TC_T5735] = {
12661 .mixers = { alc262_hp_t5735_mixer },
12662 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12663 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12664 .dac_nids = alc262_dac_nids,
12665 .hp_nid = 0x03,
12666 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12667 .channel_mode = alc262_modes,
12668 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012669 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012670 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012671 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012672 },
12673 [ALC262_HP_RP5700] = {
12674 .mixers = { alc262_hp_rp5700_mixer },
12675 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12676 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12677 .dac_nids = alc262_dac_nids,
12678 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12679 .channel_mode = alc262_modes,
12680 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012681 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012682 [ALC262_BENQ_ED8] = {
12683 .mixers = { alc262_base_mixer },
12684 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12685 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12686 .dac_nids = alc262_dac_nids,
12687 .hp_nid = 0x03,
12688 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12689 .channel_mode = alc262_modes,
12690 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012691 },
Kailang Yang272a5272007-05-14 11:00:38 +020012692 [ALC262_SONY_ASSAMD] = {
12693 .mixers = { alc262_sony_mixer },
12694 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12695 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12696 .dac_nids = alc262_dac_nids,
12697 .hp_nid = 0x02,
12698 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12699 .channel_mode = alc262_modes,
12700 .input_mux = &alc262_capture_source,
12701 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012702 .setup = alc262_hippo_setup,
12703 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012704 },
12705 [ALC262_BENQ_T31] = {
12706 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012707 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12708 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012709 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12710 .dac_nids = alc262_dac_nids,
12711 .hp_nid = 0x03,
12712 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12713 .channel_mode = alc262_modes,
12714 .input_mux = &alc262_capture_source,
12715 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012716 .setup = alc262_hippo_setup,
12717 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012718 },
Tobin Davisf651b502007-10-26 12:40:47 +020012719 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012720 .mixers = { alc262_ultra_mixer },
12721 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012722 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012723 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12724 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012725 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12726 .channel_mode = alc262_modes,
12727 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012728 .adc_nids = alc262_adc_nids, /* ADC0 */
12729 .capsrc_nids = alc262_capsrc_nids,
12730 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012731 .unsol_event = alc262_ultra_unsol_event,
12732 .init_hook = alc262_ultra_automute,
12733 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012734 [ALC262_LENOVO_3000] = {
12735 .mixers = { alc262_lenovo_3000_mixer },
12736 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012737 alc262_lenovo_3000_unsol_verbs,
12738 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012739 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12740 .dac_nids = alc262_dac_nids,
12741 .hp_nid = 0x03,
12742 .dig_out_nid = ALC262_DIGOUT_NID,
12743 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12744 .channel_mode = alc262_modes,
12745 .input_mux = &alc262_fujitsu_capture_source,
12746 .unsol_event = alc262_lenovo_3000_unsol_event,
12747 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012748 [ALC262_NEC] = {
12749 .mixers = { alc262_nec_mixer },
12750 .init_verbs = { alc262_nec_verbs },
12751 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12752 .dac_nids = alc262_dac_nids,
12753 .hp_nid = 0x03,
12754 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12755 .channel_mode = alc262_modes,
12756 .input_mux = &alc262_capture_source,
12757 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012758 [ALC262_TOSHIBA_S06] = {
12759 .mixers = { alc262_toshiba_s06_mixer },
12760 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12761 alc262_eapd_verbs },
12762 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12763 .capsrc_nids = alc262_dmic_capsrc_nids,
12764 .dac_nids = alc262_dac_nids,
12765 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012766 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012767 .dig_out_nid = ALC262_DIGOUT_NID,
12768 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12769 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012770 .unsol_event = alc_sku_unsol_event,
12771 .setup = alc262_toshiba_s06_setup,
12772 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012773 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012774 [ALC262_TOSHIBA_RX1] = {
12775 .mixers = { alc262_toshiba_rx1_mixer },
12776 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12777 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12778 .dac_nids = alc262_dac_nids,
12779 .hp_nid = 0x03,
12780 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12781 .channel_mode = alc262_modes,
12782 .input_mux = &alc262_capture_source,
12783 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012784 .setup = alc262_hippo_setup,
12785 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012786 },
Tony Vroonba340e82009-02-02 19:01:30 +000012787 [ALC262_TYAN] = {
12788 .mixers = { alc262_tyan_mixer },
12789 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12790 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12791 .dac_nids = alc262_dac_nids,
12792 .hp_nid = 0x02,
12793 .dig_out_nid = ALC262_DIGOUT_NID,
12794 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12795 .channel_mode = alc262_modes,
12796 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012797 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012798 .setup = alc262_tyan_setup,
12799 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012800 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012801};
12802
12803static int patch_alc262(struct hda_codec *codec)
12804{
12805 struct alc_spec *spec;
12806 int board_config;
12807 int err;
12808
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012809 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012810 if (spec == NULL)
12811 return -ENOMEM;
12812
12813 codec->spec = spec;
12814#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012815 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12816 * under-run
12817 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012818 {
12819 int tmp;
12820 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12821 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12822 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12823 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12824 }
12825#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012826 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012827
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012828 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12829
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012830 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12831 alc262_models,
12832 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012833
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012834 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012835 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12836 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012837 board_config = ALC262_AUTO;
12838 }
12839
Takashi Iwai18675e42010-09-08 15:55:44 +020012840 if (board_config == ALC262_AUTO)
12841 alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 1);
12842
Kailang Yangdf694da2005-12-05 19:42:22 +010012843 if (board_config == ALC262_AUTO) {
12844 /* automatic parse from the BIOS config */
12845 err = alc262_parse_auto_config(codec);
12846 if (err < 0) {
12847 alc_free(codec);
12848 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012849 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012850 printk(KERN_INFO
12851 "hda_codec: Cannot set up configuration "
12852 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012853 board_config = ALC262_BASIC;
12854 }
12855 }
12856
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012857 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010012858 err = snd_hda_attach_beep_device(codec, 0x1);
12859 if (err < 0) {
12860 alc_free(codec);
12861 return err;
12862 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012863 }
12864
Kailang Yangdf694da2005-12-05 19:42:22 +010012865 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012866 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012867
Kailang Yangdf694da2005-12-05 19:42:22 +010012868 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12869 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012870
Kailang Yangdf694da2005-12-05 19:42:22 +010012871 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12872 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12873
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012874 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012875 int i;
12876 /* check whether the digital-mic has to be supported */
12877 for (i = 0; i < spec->input_mux->num_items; i++) {
12878 if (spec->input_mux->items[i].index >= 9)
12879 break;
12880 }
12881 if (i < spec->input_mux->num_items) {
12882 /* use only ADC0 */
12883 spec->adc_nids = alc262_dmic_adc_nids;
12884 spec->num_adc_nids = 1;
12885 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012886 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012887 /* all analog inputs */
12888 /* check whether NID 0x07 is valid */
12889 unsigned int wcap = get_wcaps(codec, 0x07);
12890
12891 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012892 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012893 if (wcap != AC_WID_AUD_IN) {
12894 spec->adc_nids = alc262_adc_nids_alt;
12895 spec->num_adc_nids =
12896 ARRAY_SIZE(alc262_adc_nids_alt);
12897 spec->capsrc_nids = alc262_capsrc_nids_alt;
12898 } else {
12899 spec->adc_nids = alc262_adc_nids;
12900 spec->num_adc_nids =
12901 ARRAY_SIZE(alc262_adc_nids);
12902 spec->capsrc_nids = alc262_capsrc_nids;
12903 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012904 }
12905 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012906 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012907 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012908 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010012909 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012910
Takashi Iwai18675e42010-09-08 15:55:44 +020012911 if (board_config == ALC262_AUTO)
12912 alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 0);
12913
Takashi Iwai2134ea42008-01-10 16:53:55 +010012914 spec->vmaster_nid = 0x0c;
12915
Kailang Yangdf694da2005-12-05 19:42:22 +010012916 codec->patch_ops = alc_patch_ops;
12917 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012918 spec->init_hook = alc262_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020012919
12920 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020012921#ifdef CONFIG_SND_HDA_POWER_SAVE
12922 if (!spec->loopback.amplist)
12923 spec->loopback.amplist = alc262_loopbacks;
12924#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012925
Kailang Yangdf694da2005-12-05 19:42:22 +010012926 return 0;
12927}
12928
Kailang Yangdf694da2005-12-05 19:42:22 +010012929/*
Kailang Yanga361d842007-06-05 12:30:55 +020012930 * ALC268 channel source setting (2 channel)
12931 */
12932#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12933#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012934
Kailang Yanga361d842007-06-05 12:30:55 +020012935static hda_nid_t alc268_dac_nids[2] = {
12936 /* front, hp */
12937 0x02, 0x03
12938};
12939
12940static hda_nid_t alc268_adc_nids[2] = {
12941 /* ADC0-1 */
12942 0x08, 0x07
12943};
12944
12945static hda_nid_t alc268_adc_nids_alt[1] = {
12946 /* ADC0 */
12947 0x08
12948};
12949
Takashi Iwaie1406342008-02-11 18:32:32 +010012950static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12951
Kailang Yanga361d842007-06-05 12:30:55 +020012952static struct snd_kcontrol_new alc268_base_mixer[] = {
12953 /* output mixer control */
12954 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12955 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12956 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12957 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012958 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12959 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12960 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012961 { }
12962};
12963
Takashi Iwai42171c12009-05-08 14:11:43 +020012964static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12965 /* output mixer control */
12966 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12967 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12968 ALC262_HIPPO_MASTER_SWITCH,
12969 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12970 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12971 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12972 { }
12973};
12974
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012975/* bind Beep switches of both NID 0x0f and 0x10 */
12976static struct hda_bind_ctls alc268_bind_beep_sw = {
12977 .ops = &snd_hda_bind_sw,
12978 .values = {
12979 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12980 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12981 0
12982 },
12983};
12984
12985static struct snd_kcontrol_new alc268_beep_mixer[] = {
12986 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12987 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12988 { }
12989};
12990
Kailang Yangd1a991a2007-08-15 16:21:59 +020012991static struct hda_verb alc268_eapd_verbs[] = {
12992 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12993 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12994 { }
12995};
12996
Takashi Iwaid2738092007-08-16 14:59:45 +020012997/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012998static struct hda_verb alc268_toshiba_verbs[] = {
12999 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13000 { } /* end */
13001};
13002
13003/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020013004/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020013005static struct hda_bind_ctls alc268_acer_bind_master_vol = {
13006 .ops = &snd_hda_bind_vol,
13007 .values = {
13008 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
13009 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
13010 0
13011 },
13012};
13013
Takashi Iwai889c4392007-08-23 18:56:52 +020013014/* mute/unmute internal speaker according to the hp jack and mute state */
13015static void alc268_acer_automute(struct hda_codec *codec, int force)
13016{
13017 struct alc_spec *spec = codec->spec;
13018 unsigned int mute;
13019
13020 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080013021 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020013022 spec->sense_updated = 1;
13023 }
13024 if (spec->jack_present)
13025 mute = HDA_AMP_MUTE; /* mute internal speaker */
13026 else /* unmute internal speaker if necessary */
13027 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13028 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13029 HDA_AMP_MUTE, mute);
13030}
13031
13032
13033/* bind hp and internal speaker mute (with plug check) */
13034static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
13035 struct snd_ctl_elem_value *ucontrol)
13036{
13037 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
13038 long *valp = ucontrol->value.integer.value;
13039 int change;
13040
Takashi Iwai8de56b72009-07-24 16:51:47 +020013041 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020013042 if (change)
13043 alc268_acer_automute(codec, 0);
13044 return change;
13045}
Takashi Iwaid2738092007-08-16 14:59:45 +020013046
Kailang Yang8ef355d2008-08-26 13:10:22 +020013047static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
13048 /* output mixer control */
13049 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13050 {
13051 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13052 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013053 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013054 .info = snd_hda_mixer_amp_switch_info,
13055 .get = snd_hda_mixer_amp_switch_get,
13056 .put = alc268_acer_master_sw_put,
13057 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13058 },
13059 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
13060 { }
13061};
13062
Takashi Iwaid2738092007-08-16 14:59:45 +020013063static struct snd_kcontrol_new alc268_acer_mixer[] = {
13064 /* output mixer control */
13065 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13066 {
13067 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13068 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013069 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020013070 .info = snd_hda_mixer_amp_switch_info,
13071 .get = snd_hda_mixer_amp_switch_get,
13072 .put = alc268_acer_master_sw_put,
13073 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13074 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020013075 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13076 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13077 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020013078 { }
13079};
13080
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013081static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
13082 /* output mixer control */
13083 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13084 {
13085 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13086 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013087 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013088 .info = snd_hda_mixer_amp_switch_info,
13089 .get = snd_hda_mixer_amp_switch_get,
13090 .put = alc268_acer_master_sw_put,
13091 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13092 },
13093 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13094 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
13095 { }
13096};
13097
Kailang Yang8ef355d2008-08-26 13:10:22 +020013098static struct hda_verb alc268_acer_aspire_one_verbs[] = {
13099 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13100 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13101 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13102 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13103 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
13104 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
13105 { }
13106};
13107
Takashi Iwaid2738092007-08-16 14:59:45 +020013108static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013109 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
13110 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020013111 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13112 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013113 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13114 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020013115 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13116 { }
13117};
13118
13119/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020013120#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013121#define alc268_toshiba_setup alc262_hippo_setup
13122#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020013123
13124static void alc268_acer_unsol_event(struct hda_codec *codec,
13125 unsigned int res)
13126{
Takashi Iwai889c4392007-08-23 18:56:52 +020013127 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020013128 return;
13129 alc268_acer_automute(codec, 1);
13130}
13131
Takashi Iwai889c4392007-08-23 18:56:52 +020013132static void alc268_acer_init_hook(struct hda_codec *codec)
13133{
13134 alc268_acer_automute(codec, 1);
13135}
13136
Kailang Yang8ef355d2008-08-26 13:10:22 +020013137/* toggle speaker-output according to the hp-jack state */
13138static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
13139{
13140 unsigned int present;
13141 unsigned char bits;
13142
Wu Fengguang864f92b2009-11-18 12:38:02 +080013143 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013144 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013145 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013146 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013147 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013148 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013149}
13150
Kailang Yang8ef355d2008-08-26 13:10:22 +020013151static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
13152 unsigned int res)
13153{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013154 switch (res >> 26) {
13155 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020013156 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013157 break;
13158 case ALC880_MIC_EVENT:
13159 alc_mic_automute(codec);
13160 break;
13161 }
13162}
13163
13164static void alc268_acer_lc_setup(struct hda_codec *codec)
13165{
13166 struct alc_spec *spec = codec->spec;
13167 spec->ext_mic.pin = 0x18;
13168 spec->ext_mic.mux_idx = 0;
13169 spec->int_mic.pin = 0x12;
13170 spec->int_mic.mux_idx = 6;
13171 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013172}
13173
13174static void alc268_acer_lc_init_hook(struct hda_codec *codec)
13175{
13176 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013177 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013178}
13179
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013180static struct snd_kcontrol_new alc268_dell_mixer[] = {
13181 /* output mixer control */
13182 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13183 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13184 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13185 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13186 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13187 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13188 { }
13189};
13190
13191static struct hda_verb alc268_dell_verbs[] = {
13192 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13193 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13194 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013195 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013196 { }
13197};
13198
13199/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013200static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013201{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013202 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013203
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013204 spec->autocfg.hp_pins[0] = 0x15;
13205 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013206 spec->ext_mic.pin = 0x18;
13207 spec->ext_mic.mux_idx = 0;
13208 spec->int_mic.pin = 0x19;
13209 spec->int_mic.mux_idx = 1;
13210 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013211}
13212
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013213static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
13214 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13215 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13216 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13217 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13218 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13219 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
13220 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
13221 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
13222 { }
13223};
13224
13225static struct hda_verb alc267_quanta_il1_verbs[] = {
13226 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13227 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
13228 { }
13229};
13230
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013231static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013232{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013233 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013234 spec->autocfg.hp_pins[0] = 0x15;
13235 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013236 spec->ext_mic.pin = 0x18;
13237 spec->ext_mic.mux_idx = 0;
13238 spec->int_mic.pin = 0x19;
13239 spec->int_mic.mux_idx = 1;
13240 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013241}
13242
Kailang Yanga361d842007-06-05 12:30:55 +020013243/*
13244 * generic initialization of ADC, input mixers and output mixers
13245 */
13246static struct hda_verb alc268_base_init_verbs[] = {
13247 /* Unmute DAC0-1 and set vol = 0 */
13248 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013249 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013250
13251 /*
13252 * Set up output mixers (0x0c - 0x0e)
13253 */
13254 /* set vol=0 to output mixers */
13255 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013256 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
13257
13258 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13259 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13260
13261 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13262 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
13263 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13264 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13265 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13266 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13267 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13268 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13269
13270 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13271 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13272 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13273 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013274 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013275
13276 /* set PCBEEP vol = 0, mute connections */
13277 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13278 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13279 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013280
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013281 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013282
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013283 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13284 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13285 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13286 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013287
Kailang Yanga361d842007-06-05 12:30:55 +020013288 { }
13289};
13290
13291/*
13292 * generic initialization of ADC, input mixers and output mixers
13293 */
13294static struct hda_verb alc268_volume_init_verbs[] = {
13295 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013296 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13297 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013298
13299 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13300 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13301 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13302 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13303 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13304
Kailang Yanga361d842007-06-05 12:30:55 +020013305 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013306 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13307 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13308
13309 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013310 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013311
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013312 /* set PCBEEP vol = 0, mute connections */
13313 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13314 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13315 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013316
13317 { }
13318};
13319
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013320static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
13321 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13322 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13323 { } /* end */
13324};
13325
Kailang Yanga361d842007-06-05 12:30:55 +020013326static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
13327 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13328 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013329 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013330 { } /* end */
13331};
13332
13333static struct snd_kcontrol_new alc268_capture_mixer[] = {
13334 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13335 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13336 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13337 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013338 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013339 { } /* end */
13340};
13341
13342static struct hda_input_mux alc268_capture_source = {
13343 .num_items = 4,
13344 .items = {
13345 { "Mic", 0x0 },
13346 { "Front Mic", 0x1 },
13347 { "Line", 0x2 },
13348 { "CD", 0x3 },
13349 },
13350};
13351
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013352static struct hda_input_mux alc268_acer_capture_source = {
13353 .num_items = 3,
13354 .items = {
13355 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013356 { "Internal Mic", 0x1 },
13357 { "Line", 0x2 },
13358 },
13359};
13360
13361static struct hda_input_mux alc268_acer_dmic_capture_source = {
13362 .num_items = 3,
13363 .items = {
13364 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013365 { "Internal Mic", 0x6 },
13366 { "Line", 0x2 },
13367 },
13368};
13369
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013370#ifdef CONFIG_SND_DEBUG
13371static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013372 /* Volume widgets */
13373 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13374 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13375 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13376 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13377 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13378 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13379 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13380 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13381 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13382 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13383 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13384 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13385 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013386 /* The below appears problematic on some hardwares */
13387 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013388 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13389 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13390 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13391 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13392
13393 /* Modes for retasking pin widgets */
13394 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13395 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13396 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13397 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13398
13399 /* Controls for GPIO pins, assuming they are configured as outputs */
13400 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13401 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13402 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13403 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13404
13405 /* Switches to allow the digital SPDIF output pin to be enabled.
13406 * The ALC268 does not have an SPDIF input.
13407 */
13408 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13409
13410 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13411 * this output to turn on an external amplifier.
13412 */
13413 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13414 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13415
13416 { } /* end */
13417};
13418#endif
13419
Kailang Yanga361d842007-06-05 12:30:55 +020013420/* create input playback/capture controls for the given pin */
13421static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13422 const char *ctlname, int idx)
13423{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013424 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013425 int err;
13426
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013427 switch (nid) {
13428 case 0x14:
13429 case 0x16:
13430 dac = 0x02;
13431 break;
13432 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013433 case 0x1a: /* ALC259/269 only */
13434 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013435 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013436 dac = 0x03;
13437 break;
13438 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013439 snd_printd(KERN_WARNING "hda_codec: "
13440 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013441 return 0;
13442 }
13443 if (spec->multiout.dac_nids[0] != dac &&
13444 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013445 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013446 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013447 HDA_OUTPUT));
13448 if (err < 0)
13449 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013450 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13451 }
13452
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013453 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013454 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013455 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013456 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013457 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013458 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013459 if (err < 0)
13460 return err;
13461 return 0;
13462}
13463
13464/* add playback controls from the parsed DAC table */
13465static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13466 const struct auto_pin_cfg *cfg)
13467{
13468 hda_nid_t nid;
13469 int err;
13470
Kailang Yanga361d842007-06-05 12:30:55 +020013471 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013472
13473 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013474 if (nid) {
13475 const char *name;
13476 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13477 name = "Speaker";
13478 else
13479 name = "Front";
13480 err = alc268_new_analog_output(spec, nid, name, 0);
13481 if (err < 0)
13482 return err;
13483 }
Kailang Yanga361d842007-06-05 12:30:55 +020013484
13485 nid = cfg->speaker_pins[0];
13486 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013487 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013488 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13489 if (err < 0)
13490 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013491 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013492 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13493 if (err < 0)
13494 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013495 }
13496 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013497 if (nid) {
13498 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13499 if (err < 0)
13500 return err;
13501 }
Kailang Yanga361d842007-06-05 12:30:55 +020013502
13503 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13504 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013505 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013506 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013507 if (err < 0)
13508 return err;
13509 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013510 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013511}
13512
13513/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013514static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013515 const struct auto_pin_cfg *cfg)
13516{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013517 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013518}
13519
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013520static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13521 hda_nid_t nid, int pin_type)
13522{
13523 int idx;
13524
13525 alc_set_pin_output(codec, nid, pin_type);
13526 if (nid == 0x14 || nid == 0x16)
13527 idx = 0;
13528 else
13529 idx = 1;
13530 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13531}
13532
13533static void alc268_auto_init_multi_out(struct hda_codec *codec)
13534{
13535 struct alc_spec *spec = codec->spec;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013536 int i;
13537
13538 for (i = 0; i < spec->autocfg.line_outs; i++) {
13539 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013540 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13541 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13542 }
13543}
13544
13545static void alc268_auto_init_hp_out(struct hda_codec *codec)
13546{
13547 struct alc_spec *spec = codec->spec;
13548 hda_nid_t pin;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013549 int i;
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013550
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013551 for (i = 0; i < spec->autocfg.hp_outs; i++) {
13552 pin = spec->autocfg.hp_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013553 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013554 }
13555 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
13556 pin = spec->autocfg.speaker_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013557 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013558 }
13559 if (spec->autocfg.mono_out_pin)
13560 snd_hda_codec_write(codec, spec->autocfg.mono_out_pin, 0,
13561 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013562}
13563
Kailang Yanga361d842007-06-05 12:30:55 +020013564static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13565{
13566 struct alc_spec *spec = codec->spec;
13567 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13568 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13569 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13570 unsigned int dac_vol1, dac_vol2;
13571
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013572 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013573 snd_hda_codec_write(codec, speaker_nid, 0,
13574 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013575 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013576 snd_hda_codec_write(codec, 0x0f, 0,
13577 AC_VERB_SET_AMP_GAIN_MUTE,
13578 AMP_IN_UNMUTE(1));
13579 snd_hda_codec_write(codec, 0x10, 0,
13580 AC_VERB_SET_AMP_GAIN_MUTE,
13581 AMP_IN_UNMUTE(1));
13582 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013583 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013584 snd_hda_codec_write(codec, 0x0f, 0,
13585 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13586 snd_hda_codec_write(codec, 0x10, 0,
13587 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13588 }
13589
13590 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013591 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013592 dac_vol2 = AMP_OUT_ZERO;
13593 else if (line_nid == 0x15)
13594 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013595 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013596 dac_vol2 = AMP_OUT_ZERO;
13597 else if (hp_nid == 0x15)
13598 dac_vol1 = AMP_OUT_ZERO;
13599 if (line_nid != 0x16 || hp_nid != 0x16 ||
13600 spec->autocfg.line_out_pins[1] != 0x16 ||
13601 spec->autocfg.line_out_pins[2] != 0x16)
13602 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13603
13604 snd_hda_codec_write(codec, 0x02, 0,
13605 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13606 snd_hda_codec_write(codec, 0x03, 0,
13607 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13608}
13609
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013610/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013611#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13612#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013613#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013614#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13615
13616/*
13617 * BIOS auto configuration
13618 */
13619static int alc268_parse_auto_config(struct hda_codec *codec)
13620{
13621 struct alc_spec *spec = codec->spec;
13622 int err;
13623 static hda_nid_t alc268_ignore[] = { 0 };
13624
13625 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13626 alc268_ignore);
13627 if (err < 0)
13628 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013629 if (!spec->autocfg.line_outs) {
13630 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13631 spec->multiout.max_channels = 2;
13632 spec->no_analog = 1;
13633 goto dig_only;
13634 }
Kailang Yanga361d842007-06-05 12:30:55 +020013635 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013636 }
Kailang Yanga361d842007-06-05 12:30:55 +020013637 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13638 if (err < 0)
13639 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013640 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013641 if (err < 0)
13642 return err;
13643
13644 spec->multiout.max_channels = 2;
13645
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013646 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013647 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013648 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013649 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013650 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013651
Takashi Iwai892981f2009-03-02 08:04:35 +010013652 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013653 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013654
Takashi Iwaid88897e2008-10-31 15:01:37 +010013655 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013656 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013657 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013658
Takashi Iwai776e1842007-08-29 15:07:11 +020013659 err = alc_auto_add_mic_boost(codec);
13660 if (err < 0)
13661 return err;
13662
Kailang Yang6227cdc2010-02-25 08:36:52 +010013663 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013664
Kailang Yanga361d842007-06-05 12:30:55 +020013665 return 1;
13666}
13667
Kailang Yanga361d842007-06-05 12:30:55 +020013668#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13669
13670/* init callback for auto-configuration model -- overriding the default init */
13671static void alc268_auto_init(struct hda_codec *codec)
13672{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013673 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013674 alc268_auto_init_multi_out(codec);
13675 alc268_auto_init_hp_out(codec);
13676 alc268_auto_init_mono_speaker_out(codec);
13677 alc268_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013678 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013679 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013680 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013681}
13682
13683/*
13684 * configuration and preset
13685 */
13686static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013687 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013688 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013689 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013690 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013691 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013692 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013693 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013694 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013695#ifdef CONFIG_SND_DEBUG
13696 [ALC268_TEST] = "test",
13697#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013698 [ALC268_AUTO] = "auto",
13699};
13700
13701static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013702 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013703 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013704 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013705 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013706 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013707 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13708 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013709 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013710 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13711 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013712 /* almost compatible with toshiba but with optional digital outs;
13713 * auto-probing seems working fine
13714 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013715 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013716 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013717 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013718 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013719 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013720 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013721 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013722 {}
13723};
13724
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013725/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13726static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13727 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13728 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13729 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13730 ALC268_TOSHIBA),
13731 {}
13732};
13733
Kailang Yanga361d842007-06-05 12:30:55 +020013734static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013735 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013736 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13737 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013738 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13739 alc267_quanta_il1_verbs },
13740 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13741 .dac_nids = alc268_dac_nids,
13742 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13743 .adc_nids = alc268_adc_nids_alt,
13744 .hp_nid = 0x03,
13745 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13746 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013747 .unsol_event = alc_sku_unsol_event,
13748 .setup = alc267_quanta_il1_setup,
13749 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013750 },
Kailang Yanga361d842007-06-05 12:30:55 +020013751 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013752 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13753 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013754 .init_verbs = { alc268_base_init_verbs },
13755 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13756 .dac_nids = alc268_dac_nids,
13757 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13758 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013759 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013760 .hp_nid = 0x03,
13761 .dig_out_nid = ALC268_DIGOUT_NID,
13762 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13763 .channel_mode = alc268_modes,
13764 .input_mux = &alc268_capture_source,
13765 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013766 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013767 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013768 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013769 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13770 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013771 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13772 .dac_nids = alc268_dac_nids,
13773 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13774 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013775 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013776 .hp_nid = 0x03,
13777 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13778 .channel_mode = alc268_modes,
13779 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013780 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013781 .setup = alc268_toshiba_setup,
13782 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013783 },
13784 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013785 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013786 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013787 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13788 alc268_acer_verbs },
13789 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13790 .dac_nids = alc268_dac_nids,
13791 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13792 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013793 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013794 .hp_nid = 0x02,
13795 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13796 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013797 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013798 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013799 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013800 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013801 [ALC268_ACER_DMIC] = {
13802 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13803 alc268_beep_mixer },
13804 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13805 alc268_acer_verbs },
13806 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13807 .dac_nids = alc268_dac_nids,
13808 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13809 .adc_nids = alc268_adc_nids_alt,
13810 .capsrc_nids = alc268_capsrc_nids,
13811 .hp_nid = 0x02,
13812 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13813 .channel_mode = alc268_modes,
13814 .input_mux = &alc268_acer_dmic_capture_source,
13815 .unsol_event = alc268_acer_unsol_event,
13816 .init_hook = alc268_acer_init_hook,
13817 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013818 [ALC268_ACER_ASPIRE_ONE] = {
13819 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013820 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013821 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013822 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13823 alc268_acer_aspire_one_verbs },
13824 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13825 .dac_nids = alc268_dac_nids,
13826 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13827 .adc_nids = alc268_adc_nids_alt,
13828 .capsrc_nids = alc268_capsrc_nids,
13829 .hp_nid = 0x03,
13830 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13831 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013832 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013833 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013834 .init_hook = alc268_acer_lc_init_hook,
13835 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013836 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013837 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13838 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013839 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13840 alc268_dell_verbs },
13841 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13842 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013843 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13844 .adc_nids = alc268_adc_nids_alt,
13845 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013846 .hp_nid = 0x02,
13847 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13848 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013849 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013850 .setup = alc268_dell_setup,
13851 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013852 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013853 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013854 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13855 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013856 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13857 alc268_toshiba_verbs },
13858 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13859 .dac_nids = alc268_dac_nids,
13860 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13861 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013862 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013863 .hp_nid = 0x03,
13864 .dig_out_nid = ALC268_DIGOUT_NID,
13865 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13866 .channel_mode = alc268_modes,
13867 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013868 .setup = alc268_toshiba_setup,
13869 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013870 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013871#ifdef CONFIG_SND_DEBUG
13872 [ALC268_TEST] = {
13873 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13874 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13875 alc268_volume_init_verbs },
13876 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13877 .dac_nids = alc268_dac_nids,
13878 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13879 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013880 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013881 .hp_nid = 0x03,
13882 .dig_out_nid = ALC268_DIGOUT_NID,
13883 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13884 .channel_mode = alc268_modes,
13885 .input_mux = &alc268_capture_source,
13886 },
13887#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013888};
13889
13890static int patch_alc268(struct hda_codec *codec)
13891{
13892 struct alc_spec *spec;
13893 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013894 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013895
Julia Lawallef86f582009-12-19 08:18:03 +010013896 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013897 if (spec == NULL)
13898 return -ENOMEM;
13899
13900 codec->spec = spec;
13901
13902 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13903 alc268_models,
13904 alc268_cfg_tbl);
13905
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013906 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13907 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013908 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013909
Kailang Yanga361d842007-06-05 12:30:55 +020013910 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013911 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13912 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013913 board_config = ALC268_AUTO;
13914 }
13915
13916 if (board_config == ALC268_AUTO) {
13917 /* automatic parse from the BIOS config */
13918 err = alc268_parse_auto_config(codec);
13919 if (err < 0) {
13920 alc_free(codec);
13921 return err;
13922 } else if (!err) {
13923 printk(KERN_INFO
13924 "hda_codec: Cannot set up configuration "
13925 "from BIOS. Using base mode...\n");
13926 board_config = ALC268_3ST;
13927 }
13928 }
13929
13930 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013931 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013932
Kailang Yanga361d842007-06-05 12:30:55 +020013933 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13934 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013935 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013936
Kailang Yanga361d842007-06-05 12:30:55 +020013937 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13938
Takashi Iwai22971e32009-02-10 11:56:44 +010013939 has_beep = 0;
13940 for (i = 0; i < spec->num_mixers; i++) {
13941 if (spec->mixers[i] == alc268_beep_mixer) {
13942 has_beep = 1;
13943 break;
13944 }
13945 }
13946
13947 if (has_beep) {
13948 err = snd_hda_attach_beep_device(codec, 0x1);
13949 if (err < 0) {
13950 alc_free(codec);
13951 return err;
13952 }
13953 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13954 /* override the amp caps for beep generator */
13955 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013956 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13957 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13958 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13959 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013960 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013961
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013962 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013963 /* check whether NID 0x07 is valid */
13964 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013965 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013966
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013967 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013968 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013969 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013970 if (spec->auto_mic ||
13971 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013972 spec->adc_nids = alc268_adc_nids_alt;
13973 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013974 if (spec->auto_mic)
13975 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013976 if (spec->auto_mic || spec->input_mux->num_items == 1)
13977 add_mixer(spec, alc268_capture_nosrc_mixer);
13978 else
13979 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013980 } else {
13981 spec->adc_nids = alc268_adc_nids;
13982 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013983 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013984 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013985 /* set default input source */
13986 for (i = 0; i < spec->num_adc_nids; i++)
13987 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13988 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013989 i < spec->num_mux_defs ?
13990 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013991 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013992 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013993
13994 spec->vmaster_nid = 0x02;
13995
Kailang Yanga361d842007-06-05 12:30:55 +020013996 codec->patch_ops = alc_patch_ops;
13997 if (board_config == ALC268_AUTO)
13998 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020013999
Kailang Yangbf1b0222010-10-21 08:49:56 +020014000 alc_init_jacks(codec);
14001
Kailang Yanga361d842007-06-05 12:30:55 +020014002 return 0;
14003}
14004
14005/*
Kailang Yangf6a92242007-12-13 16:52:54 +010014006 * ALC269 channel source setting (2 channel)
14007 */
14008#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
14009
14010#define alc269_dac_nids alc260_dac_nids
14011
14012static hda_nid_t alc269_adc_nids[1] = {
14013 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020014014 0x08,
14015};
14016
Takashi Iwaie01bf502008-08-21 16:25:07 +020014017static hda_nid_t alc269_capsrc_nids[1] = {
14018 0x23,
14019};
14020
Kailang Yang84898e82010-02-04 14:16:14 +010014021static hda_nid_t alc269vb_adc_nids[1] = {
14022 /* ADC1 */
14023 0x09,
14024};
14025
14026static hda_nid_t alc269vb_capsrc_nids[1] = {
14027 0x22,
14028};
14029
Takashi Iwai66946352010-03-29 17:21:45 +020014030static hda_nid_t alc269_adc_candidates[] = {
14031 0x08, 0x09, 0x07,
14032};
Takashi Iwaie01bf502008-08-21 16:25:07 +020014033
Kailang Yangf6a92242007-12-13 16:52:54 +010014034#define alc269_modes alc260_modes
14035#define alc269_capture_source alc880_lg_lw_capture_source
14036
14037static struct snd_kcontrol_new alc269_base_mixer[] = {
14038 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14039 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14040 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14041 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14042 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14043 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14044 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14045 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14046 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
14047 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14048 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14049 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
14050 { } /* end */
14051};
14052
Kailang Yang60db6b52008-08-26 13:13:00 +020014053static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
14054 /* output mixer control */
14055 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14056 {
14057 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14058 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014059 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020014060 .info = snd_hda_mixer_amp_switch_info,
14061 .get = snd_hda_mixer_amp_switch_get,
14062 .put = alc268_acer_master_sw_put,
14063 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14064 },
14065 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14066 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14067 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14068 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14069 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
14070 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014071 { }
14072};
14073
Tony Vroon64154832008-11-06 15:08:49 +000014074static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
14075 /* output mixer control */
14076 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14077 {
14078 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14079 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014080 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000014081 .info = snd_hda_mixer_amp_switch_info,
14082 .get = snd_hda_mixer_amp_switch_get,
14083 .put = alc268_acer_master_sw_put,
14084 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14085 },
14086 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14087 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14088 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14089 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14090 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
14091 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
14092 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
14093 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
14094 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014095 { }
14096};
14097
Kailang Yang84898e82010-02-04 14:16:14 +010014098static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020014099 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014100 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020014101 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014102 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020014103 { } /* end */
14104};
14105
Kailang Yang84898e82010-02-04 14:16:14 +010014106static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
14107 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14108 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14109 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14110 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14111 { } /* end */
14112};
14113
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014114static struct snd_kcontrol_new alc269_asus_mixer[] = {
14115 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14116 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
14117 { } /* end */
14118};
14119
Kailang Yangf6a92242007-12-13 16:52:54 +010014120/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010014121static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
14122 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14123 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
14124 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14125 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
14126 { } /* end */
14127};
14128
14129static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020014130 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14131 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010014132 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14133 { } /* end */
14134};
14135
Kailang Yang84898e82010-02-04 14:16:14 +010014136static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
14137 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14138 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14139 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14140 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
14141 { } /* end */
14142};
14143
14144static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
14145 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14146 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14147 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14148 { } /* end */
14149};
14150
Takashi Iwai26f5df22008-11-03 17:39:46 +010014151/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010014152#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020014153
Kailang Yang60db6b52008-08-26 13:13:00 +020014154static struct hda_verb alc269_quanta_fl1_verbs[] = {
14155 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14156 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14157 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14158 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14159 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14160 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14161 { }
14162};
14163
Tony Vroon64154832008-11-06 15:08:49 +000014164static struct hda_verb alc269_lifebook_verbs[] = {
14165 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14166 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
14167 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14168 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14169 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14170 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14171 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14172 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14173 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14174 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14175 { }
14176};
14177
Kailang Yang60db6b52008-08-26 13:13:00 +020014178/* toggle speaker-output according to the hp-jack state */
14179static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
14180{
14181 unsigned int present;
14182 unsigned char bits;
14183
Wu Fengguang864f92b2009-11-18 12:38:02 +080014184 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014185 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014186 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014187 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014188 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014189 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014190
14191 snd_hda_codec_write(codec, 0x20, 0,
14192 AC_VERB_SET_COEF_INDEX, 0x0c);
14193 snd_hda_codec_write(codec, 0x20, 0,
14194 AC_VERB_SET_PROC_COEF, 0x680);
14195
14196 snd_hda_codec_write(codec, 0x20, 0,
14197 AC_VERB_SET_COEF_INDEX, 0x0c);
14198 snd_hda_codec_write(codec, 0x20, 0,
14199 AC_VERB_SET_PROC_COEF, 0x480);
14200}
14201
Tony Vroon64154832008-11-06 15:08:49 +000014202/* toggle speaker-output according to the hp-jacks state */
14203static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
14204{
14205 unsigned int present;
14206 unsigned char bits;
14207
14208 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014209 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000014210
14211 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014212 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000014213
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014214 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000014215 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014216 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014217 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014218 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014219
14220 snd_hda_codec_write(codec, 0x20, 0,
14221 AC_VERB_SET_COEF_INDEX, 0x0c);
14222 snd_hda_codec_write(codec, 0x20, 0,
14223 AC_VERB_SET_PROC_COEF, 0x680);
14224
14225 snd_hda_codec_write(codec, 0x20, 0,
14226 AC_VERB_SET_COEF_INDEX, 0x0c);
14227 snd_hda_codec_write(codec, 0x20, 0,
14228 AC_VERB_SET_PROC_COEF, 0x480);
14229}
14230
Tony Vroon64154832008-11-06 15:08:49 +000014231static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
14232{
14233 unsigned int present_laptop;
14234 unsigned int present_dock;
14235
Wu Fengguang864f92b2009-11-18 12:38:02 +080014236 present_laptop = snd_hda_jack_detect(codec, 0x18);
14237 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000014238
14239 /* Laptop mic port overrides dock mic port, design decision */
14240 if (present_dock)
14241 snd_hda_codec_write(codec, 0x23, 0,
14242 AC_VERB_SET_CONNECT_SEL, 0x3);
14243 if (present_laptop)
14244 snd_hda_codec_write(codec, 0x23, 0,
14245 AC_VERB_SET_CONNECT_SEL, 0x0);
14246 if (!present_dock && !present_laptop)
14247 snd_hda_codec_write(codec, 0x23, 0,
14248 AC_VERB_SET_CONNECT_SEL, 0x1);
14249}
14250
Kailang Yang60db6b52008-08-26 13:13:00 +020014251static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
14252 unsigned int res)
14253{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014254 switch (res >> 26) {
14255 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014256 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014257 break;
14258 case ALC880_MIC_EVENT:
14259 alc_mic_automute(codec);
14260 break;
14261 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014262}
14263
Tony Vroon64154832008-11-06 15:08:49 +000014264static void alc269_lifebook_unsol_event(struct hda_codec *codec,
14265 unsigned int res)
14266{
14267 if ((res >> 26) == ALC880_HP_EVENT)
14268 alc269_lifebook_speaker_automute(codec);
14269 if ((res >> 26) == ALC880_MIC_EVENT)
14270 alc269_lifebook_mic_autoswitch(codec);
14271}
14272
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014273static void alc269_quanta_fl1_setup(struct hda_codec *codec)
14274{
14275 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014276 spec->autocfg.hp_pins[0] = 0x15;
14277 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014278 spec->ext_mic.pin = 0x18;
14279 spec->ext_mic.mux_idx = 0;
14280 spec->int_mic.pin = 0x19;
14281 spec->int_mic.mux_idx = 1;
14282 spec->auto_mic = 1;
14283}
14284
Kailang Yang60db6b52008-08-26 13:13:00 +020014285static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
14286{
14287 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014288 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014289}
14290
Tony Vroon64154832008-11-06 15:08:49 +000014291static void alc269_lifebook_init_hook(struct hda_codec *codec)
14292{
14293 alc269_lifebook_speaker_automute(codec);
14294 alc269_lifebook_mic_autoswitch(codec);
14295}
14296
Kailang Yang84898e82010-02-04 14:16:14 +010014297static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014298 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14299 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14300 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14301 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14302 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14303 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14304 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14305 {}
14306};
14307
Kailang Yang84898e82010-02-04 14:16:14 +010014308static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014309 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14310 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14311 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14312 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
14313 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14314 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14315 {}
14316};
14317
Kailang Yang84898e82010-02-04 14:16:14 +010014318static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
14319 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14320 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14321 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14322 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14323 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14324 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14325 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14326 {}
14327};
14328
14329static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
14330 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14331 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14332 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14333 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14334 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14335 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14336 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14337 {}
14338};
14339
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014340static struct hda_verb alc271_acer_dmic_verbs[] = {
14341 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14342 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14343 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14344 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14345 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14346 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14347 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14348 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14349 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14350 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14351 { }
14352};
14353
Kailang Yang60db6b52008-08-26 13:13:00 +020014354/* toggle speaker-output according to the hp-jack state */
14355static void alc269_speaker_automute(struct hda_codec *codec)
14356{
Kailang Yangebb83ee2009-12-17 12:23:00 +010014357 struct alc_spec *spec = codec->spec;
14358 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020014359 unsigned int present;
14360 unsigned char bits;
14361
Kailang Yangebb83ee2009-12-17 12:23:00 +010014362 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014363 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014364 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014365 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014366 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014367 HDA_AMP_MUTE, bits);
Kailang Yangbf1b0222010-10-21 08:49:56 +020014368 alc_report_jack(codec, nid);
Kailang Yang60db6b52008-08-26 13:13:00 +020014369}
14370
Kailang Yang60db6b52008-08-26 13:13:00 +020014371/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010014372static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020014373 unsigned int res)
14374{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014375 switch (res >> 26) {
14376 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014377 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014378 break;
14379 case ALC880_MIC_EVENT:
14380 alc_mic_automute(codec);
14381 break;
14382 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014383}
14384
Kailang Yang226b1ec2010-04-09 11:01:20 +020014385static void alc269_laptop_amic_setup(struct hda_codec *codec)
14386{
14387 struct alc_spec *spec = codec->spec;
14388 spec->autocfg.hp_pins[0] = 0x15;
14389 spec->autocfg.speaker_pins[0] = 0x14;
14390 spec->ext_mic.pin = 0x18;
14391 spec->ext_mic.mux_idx = 0;
14392 spec->int_mic.pin = 0x19;
14393 spec->int_mic.mux_idx = 1;
14394 spec->auto_mic = 1;
14395}
14396
Kailang Yang84898e82010-02-04 14:16:14 +010014397static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014398{
14399 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014400 spec->autocfg.hp_pins[0] = 0x15;
14401 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014402 spec->ext_mic.pin = 0x18;
14403 spec->ext_mic.mux_idx = 0;
14404 spec->int_mic.pin = 0x12;
14405 spec->int_mic.mux_idx = 5;
14406 spec->auto_mic = 1;
14407}
14408
Kailang Yang226b1ec2010-04-09 11:01:20 +020014409static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014410{
14411 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014412 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014413 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014414 spec->ext_mic.pin = 0x18;
14415 spec->ext_mic.mux_idx = 0;
14416 spec->int_mic.pin = 0x19;
14417 spec->int_mic.mux_idx = 1;
14418 spec->auto_mic = 1;
14419}
14420
Kailang Yang226b1ec2010-04-09 11:01:20 +020014421static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14422{
14423 struct alc_spec *spec = codec->spec;
14424 spec->autocfg.hp_pins[0] = 0x21;
14425 spec->autocfg.speaker_pins[0] = 0x14;
14426 spec->ext_mic.pin = 0x18;
14427 spec->ext_mic.mux_idx = 0;
14428 spec->int_mic.pin = 0x12;
14429 spec->int_mic.mux_idx = 6;
14430 spec->auto_mic = 1;
14431}
14432
Kailang Yang84898e82010-02-04 14:16:14 +010014433static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020014434{
14435 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014436 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014437}
14438
Kailang Yangf6a92242007-12-13 16:52:54 +010014439/*
14440 * generic initialization of ADC, input mixers and output mixers
14441 */
14442static struct hda_verb alc269_init_verbs[] = {
14443 /*
14444 * Unmute ADC0 and set the default input to mic-in
14445 */
Kailang Yang84898e82010-02-04 14:16:14 +010014446 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014447
14448 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014449 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014450 */
14451 /* set vol=0 to output mixers */
14452 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14453 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14454
14455 /* set up input amps for analog loopback */
14456 /* Amp Indices: DAC = 0, mixer = 1 */
14457 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14458 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14459 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14460 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14461 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14462 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14463
14464 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14465 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14466 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14467 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14468 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14469 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14470 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14471
14472 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14473 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014474
Kailang Yang84898e82010-02-04 14:16:14 +010014475 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014476 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14477 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014478 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014479
14480 /* set EAPD */
14481 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014482 { }
14483};
14484
14485static struct hda_verb alc269vb_init_verbs[] = {
14486 /*
14487 * Unmute ADC0 and set the default input to mic-in
14488 */
14489 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14490
14491 /*
14492 * Set up output mixers (0x02 - 0x03)
14493 */
14494 /* set vol=0 to output mixers */
14495 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14496 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14497
14498 /* set up input amps for analog loopback */
14499 /* Amp Indices: DAC = 0, mixer = 1 */
14500 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14501 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14502 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14503 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14504 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14505 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14506
14507 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14508 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14509 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14510 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14511 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14512 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14513 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14514
14515 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14516 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14517
14518 /* FIXME: use Mux-type input source selection */
14519 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14520 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14521 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14522
14523 /* set EAPD */
14524 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014525 { }
14526};
14527
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014528#define alc269_auto_create_multi_out_ctls \
14529 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014530#define alc269_auto_create_input_ctls \
14531 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014532
14533#ifdef CONFIG_SND_HDA_POWER_SAVE
14534#define alc269_loopbacks alc880_loopbacks
14535#endif
14536
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014537/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014538#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14539#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14540#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14541#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14542
Takashi Iwaif03d3112009-03-05 14:18:16 +010014543static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14544 .substreams = 1,
14545 .channels_min = 2,
14546 .channels_max = 8,
14547 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14548 /* NID is set in alc_build_pcms */
14549 .ops = {
14550 .open = alc880_playback_pcm_open,
14551 .prepare = alc880_playback_pcm_prepare,
14552 .cleanup = alc880_playback_pcm_cleanup
14553 },
14554};
14555
14556static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14557 .substreams = 1,
14558 .channels_min = 2,
14559 .channels_max = 2,
14560 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14561 /* NID is set in alc_build_pcms */
14562};
14563
Takashi Iwaiad358792010-03-30 18:00:59 +020014564#ifdef CONFIG_SND_HDA_POWER_SAVE
14565static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14566{
14567 switch (codec->subsystem_id) {
14568 case 0x103c1586:
14569 return 1;
14570 }
14571 return 0;
14572}
14573
14574static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14575{
14576 /* update mute-LED according to the speaker mute state */
14577 if (nid == 0x01 || nid == 0x14) {
14578 int pinval;
14579 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14580 HDA_AMP_MUTE)
14581 pinval = 0x24;
14582 else
14583 pinval = 0x20;
14584 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a52010-03-30 18:03:44 +020014585 snd_hda_codec_update_cache(codec, 0x19, 0,
14586 AC_VERB_SET_PIN_WIDGET_CONTROL,
14587 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014588 }
14589 return alc_check_power_status(codec, nid);
14590}
14591#endif /* CONFIG_SND_HDA_POWER_SAVE */
14592
Takashi Iwai840b64c2010-07-13 22:49:01 +020014593static int alc275_setup_dual_adc(struct hda_codec *codec)
14594{
14595 struct alc_spec *spec = codec->spec;
14596
14597 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14598 return 0;
14599 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14600 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14601 if (spec->ext_mic.pin <= 0x12) {
14602 spec->private_adc_nids[0] = 0x08;
14603 spec->private_adc_nids[1] = 0x11;
14604 spec->private_capsrc_nids[0] = 0x23;
14605 spec->private_capsrc_nids[1] = 0x22;
14606 } else {
14607 spec->private_adc_nids[0] = 0x11;
14608 spec->private_adc_nids[1] = 0x08;
14609 spec->private_capsrc_nids[0] = 0x22;
14610 spec->private_capsrc_nids[1] = 0x23;
14611 }
14612 spec->adc_nids = spec->private_adc_nids;
14613 spec->capsrc_nids = spec->private_capsrc_nids;
14614 spec->num_adc_nids = 2;
14615 spec->dual_adc_switch = 1;
14616 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14617 spec->adc_nids[0], spec->adc_nids[1]);
14618 return 1;
14619 }
14620 return 0;
14621}
14622
Takashi Iwaid433a672010-09-20 15:11:54 +020014623/* different alc269-variants */
14624enum {
14625 ALC269_TYPE_NORMAL,
14626 ALC269_TYPE_ALC259,
14627 ALC269_TYPE_ALC271X,
14628};
14629
Kailang Yangf6a92242007-12-13 16:52:54 +010014630/*
14631 * BIOS auto configuration
14632 */
14633static int alc269_parse_auto_config(struct hda_codec *codec)
14634{
14635 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014636 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014637 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14638
14639 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14640 alc269_ignore);
14641 if (err < 0)
14642 return err;
14643
14644 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14645 if (err < 0)
14646 return err;
Takashi Iwaif3550d12010-09-20 15:09:03 +020014647 if (spec->codec_variant == ALC269_TYPE_NORMAL)
14648 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
14649 else
14650 err = alc_auto_create_input_ctls(codec, &spec->autocfg, 0,
14651 0x22, 0);
Kailang Yangf6a92242007-12-13 16:52:54 +010014652 if (err < 0)
14653 return err;
14654
14655 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14656
Takashi Iwai757899a2010-07-30 10:48:14 +020014657 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014658
Takashi Iwai603c4012008-07-30 15:01:44 +020014659 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014660 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014661
Takashi Iwaid433a672010-09-20 15:11:54 +020014662 if (spec->codec_variant != ALC269_TYPE_NORMAL) {
Kailang Yang84898e82010-02-04 14:16:14 +010014663 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014664 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014665 } else {
14666 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014667 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014668 }
14669
Kailang Yangf6a92242007-12-13 16:52:54 +010014670 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014671 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014672
14673 if (!alc275_setup_dual_adc(codec))
14674 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14675 sizeof(alc269_adc_candidates));
Takashi Iwai66946352010-03-29 17:21:45 +020014676
Takashi Iwaie01bf502008-08-21 16:25:07 +020014677 /* set default input source */
Takashi Iwai840b64c2010-07-13 22:49:01 +020014678 if (!spec->dual_adc_switch)
Takashi Iwai748cce42010-08-04 07:37:39 +020014679 select_or_unmute_capsrc(codec, spec->capsrc_nids[0],
14680 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010014681
14682 err = alc_auto_add_mic_boost(codec);
14683 if (err < 0)
14684 return err;
14685
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014686 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014687 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014688
Kailang Yangf6a92242007-12-13 16:52:54 +010014689 return 1;
14690}
14691
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014692#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14693#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014694#define alc269_auto_init_analog_input alc882_auto_init_analog_input
14695
14696
14697/* init callback for auto-configuration model -- overriding the default init */
14698static void alc269_auto_init(struct hda_codec *codec)
14699{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014700 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014701 alc269_auto_init_multi_out(codec);
14702 alc269_auto_init_hp_out(codec);
14703 alc269_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014704 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014705 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014706 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014707}
14708
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014709#ifdef SND_HDA_NEEDS_RESUME
14710static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
14711{
14712 int val = alc_read_coef_idx(codec, 0x04);
14713 if (power_up)
14714 val |= 1 << 11;
14715 else
14716 val &= ~(1 << 11);
14717 alc_write_coef_idx(codec, 0x04, val);
14718}
14719
Kailang Yang977ddd62010-09-15 10:02:29 +020014720#ifdef CONFIG_SND_HDA_POWER_SAVE
14721static int alc269_suspend(struct hda_codec *codec, pm_message_t state)
14722{
14723 struct alc_spec *spec = codec->spec;
Kailang Yang977ddd62010-09-15 10:02:29 +020014724
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014725 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017)
14726 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014727 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014728 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014729 msleep(150);
14730 }
14731
14732 alc_shutup(codec);
14733 if (spec && spec->power_hook)
14734 spec->power_hook(codec);
14735 return 0;
14736}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014737#endif /* CONFIG_SND_HDA_POWER_SAVE */
14738
Kailang Yang977ddd62010-09-15 10:02:29 +020014739static int alc269_resume(struct hda_codec *codec)
14740{
Kailang Yang977ddd62010-09-15 10:02:29 +020014741 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014742 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014743 msleep(150);
14744 }
14745
14746 codec->patch_ops.init(codec);
14747
14748 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014749 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014750 msleep(200);
14751 }
14752
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014753 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018)
14754 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014755
14756 snd_hda_codec_resume_amp(codec);
14757 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +020014758 hda_call_check_power_status(codec, 0x01);
Kailang Yang977ddd62010-09-15 10:02:29 +020014759 return 0;
14760}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014761#endif /* SND_HDA_NEEDS_RESUME */
Kailang Yang977ddd62010-09-15 10:02:29 +020014762
Takashi Iwaiff818c22010-04-12 08:59:25 +020014763enum {
14764 ALC269_FIXUP_SONY_VAIO,
David Henningsson145a9022010-09-16 10:07:53 +020014765 ALC269_FIXUP_DELL_M101Z,
Takashi Iwaiff818c22010-04-12 08:59:25 +020014766};
14767
Takashi Iwaiff818c22010-04-12 08:59:25 +020014768static const struct alc_fixup alc269_fixups[] = {
14769 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020014770 .verbs = (const struct hda_verb[]) {
14771 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14772 {}
14773 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014774 },
David Henningsson145a9022010-09-16 10:07:53 +020014775 [ALC269_FIXUP_DELL_M101Z] = {
14776 .verbs = (const struct hda_verb[]) {
14777 /* Enables internal speaker */
14778 {0x20, AC_VERB_SET_COEF_INDEX, 13},
14779 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
14780 {}
14781 }
14782 },
Takashi Iwaiff818c22010-04-12 08:59:25 +020014783};
14784
14785static struct snd_pci_quirk alc269_fixup_tbl[] = {
Takashi Iwaiabdd8f52010-09-21 17:38:14 +020014786 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningsson145a9022010-09-16 10:07:53 +020014787 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014788 {}
14789};
14790
14791
Kailang Yangf6a92242007-12-13 16:52:54 +010014792/*
14793 * configuration and preset
14794 */
14795static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014796 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014797 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014798 [ALC269_AMIC] = "laptop-amic",
14799 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014800 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014801 [ALC269_LIFEBOOK] = "lifebook",
14802 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014803};
14804
14805static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014806 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014807 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020014808 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014809 ALC269_AMIC),
14810 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14811 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14812 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14813 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14814 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14815 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14816 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14817 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14818 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
14819 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
14820 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14821 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14822 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14823 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14824 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14825 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14826 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14827 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14828 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14829 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14830 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14831 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14832 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14833 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14834 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14835 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14836 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14837 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14838 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14839 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14840 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14841 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14842 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14843 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14844 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14845 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014846 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014847 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014848 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014849 ALC269_DMIC),
14850 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14851 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014852 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000014853 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014854 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14855 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14856 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14857 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14858 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14859 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014860 {}
14861};
14862
14863static struct alc_config_preset alc269_presets[] = {
14864 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014865 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010014866 .init_verbs = { alc269_init_verbs },
14867 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14868 .dac_nids = alc269_dac_nids,
14869 .hp_nid = 0x03,
14870 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14871 .channel_mode = alc269_modes,
14872 .input_mux = &alc269_capture_source,
14873 },
Kailang Yang60db6b52008-08-26 13:13:00 +020014874 [ALC269_QUANTA_FL1] = {
14875 .mixers = { alc269_quanta_fl1_mixer },
14876 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
14877 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14878 .dac_nids = alc269_dac_nids,
14879 .hp_nid = 0x03,
14880 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14881 .channel_mode = alc269_modes,
14882 .input_mux = &alc269_capture_source,
14883 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014884 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020014885 .init_hook = alc269_quanta_fl1_init_hook,
14886 },
Kailang Yang84898e82010-02-04 14:16:14 +010014887 [ALC269_AMIC] = {
14888 .mixers = { alc269_laptop_mixer },
14889 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014890 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014891 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014892 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14893 .dac_nids = alc269_dac_nids,
14894 .hp_nid = 0x03,
14895 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14896 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014897 .unsol_event = alc269_laptop_unsol_event,
14898 .setup = alc269_laptop_amic_setup,
14899 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014900 },
Kailang Yang84898e82010-02-04 14:16:14 +010014901 [ALC269_DMIC] = {
14902 .mixers = { alc269_laptop_mixer },
14903 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014904 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014905 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014906 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14907 .dac_nids = alc269_dac_nids,
14908 .hp_nid = 0x03,
14909 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14910 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014911 .unsol_event = alc269_laptop_unsol_event,
14912 .setup = alc269_laptop_dmic_setup,
14913 .init_hook = alc269_laptop_inithook,
14914 },
14915 [ALC269VB_AMIC] = {
14916 .mixers = { alc269vb_laptop_mixer },
14917 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14918 .init_verbs = { alc269vb_init_verbs,
14919 alc269vb_laptop_amic_init_verbs },
14920 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14921 .dac_nids = alc269_dac_nids,
14922 .hp_nid = 0x03,
14923 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14924 .channel_mode = alc269_modes,
14925 .unsol_event = alc269_laptop_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020014926 .setup = alc269vb_laptop_amic_setup,
Kailang Yang84898e82010-02-04 14:16:14 +010014927 .init_hook = alc269_laptop_inithook,
14928 },
14929 [ALC269VB_DMIC] = {
14930 .mixers = { alc269vb_laptop_mixer },
14931 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14932 .init_verbs = { alc269vb_init_verbs,
14933 alc269vb_laptop_dmic_init_verbs },
14934 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14935 .dac_nids = alc269_dac_nids,
14936 .hp_nid = 0x03,
14937 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14938 .channel_mode = alc269_modes,
14939 .unsol_event = alc269_laptop_unsol_event,
14940 .setup = alc269vb_laptop_dmic_setup,
14941 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014942 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014943 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014944 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014945 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014946 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014947 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014948 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14949 .dac_nids = alc269_dac_nids,
14950 .hp_nid = 0x03,
14951 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14952 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014953 .unsol_event = alc269_laptop_unsol_event,
14954 .setup = alc269_laptop_dmic_setup,
14955 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014956 },
Tony Vroon64154832008-11-06 15:08:49 +000014957 [ALC269_LIFEBOOK] = {
14958 .mixers = { alc269_lifebook_mixer },
14959 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
14960 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14961 .dac_nids = alc269_dac_nids,
14962 .hp_nid = 0x03,
14963 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14964 .channel_mode = alc269_modes,
14965 .input_mux = &alc269_capture_source,
14966 .unsol_event = alc269_lifebook_unsol_event,
14967 .init_hook = alc269_lifebook_init_hook,
14968 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014969 [ALC271_ACER] = {
14970 .mixers = { alc269_asus_mixer },
14971 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14972 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
14973 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14974 .dac_nids = alc269_dac_nids,
14975 .adc_nids = alc262_dmic_adc_nids,
14976 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
14977 .capsrc_nids = alc262_dmic_capsrc_nids,
14978 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14979 .channel_mode = alc269_modes,
14980 .input_mux = &alc269_capture_source,
14981 .dig_out_nid = ALC880_DIGOUT_NID,
14982 .unsol_event = alc_sku_unsol_event,
14983 .setup = alc269vb_laptop_dmic_setup,
14984 .init_hook = alc_inithook,
14985 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014986};
14987
Kailang Yang977ddd62010-09-15 10:02:29 +020014988static int alc269_fill_coef(struct hda_codec *codec)
14989{
14990 int val;
14991
14992 if ((alc_read_coef_idx(codec, 0) & 0x00ff) < 0x015) {
14993 alc_write_coef_idx(codec, 0xf, 0x960b);
14994 alc_write_coef_idx(codec, 0xe, 0x8817);
14995 }
14996
14997 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x016) {
14998 alc_write_coef_idx(codec, 0xf, 0x960b);
14999 alc_write_coef_idx(codec, 0xe, 0x8814);
15000 }
15001
15002 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
15003 val = alc_read_coef_idx(codec, 0x04);
15004 /* Power up output pin */
15005 alc_write_coef_idx(codec, 0x04, val | (1<<11));
15006 }
15007
15008 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
15009 val = alc_read_coef_idx(codec, 0xd);
15010 if ((val & 0x0c00) >> 10 != 0x1) {
15011 /* Capless ramp up clock control */
15012 alc_write_coef_idx(codec, 0xd, val | 1<<10);
15013 }
15014 val = alc_read_coef_idx(codec, 0x17);
15015 if ((val & 0x01c0) >> 6 != 0x4) {
15016 /* Class D power on reset */
15017 alc_write_coef_idx(codec, 0x17, val | 1<<7);
15018 }
15019 }
15020 return 0;
15021}
15022
Kailang Yangf6a92242007-12-13 16:52:54 +010015023static int patch_alc269(struct hda_codec *codec)
15024{
15025 struct alc_spec *spec;
15026 int board_config;
15027 int err;
15028
15029 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15030 if (spec == NULL)
15031 return -ENOMEM;
15032
15033 codec->spec = spec;
15034
Kailang Yangda00c242010-03-19 11:23:45 +010015035 alc_auto_parse_customize_define(codec);
15036
Kailang Yang274693f2009-12-03 10:07:50 +010015037 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
Kailang Yangc027ddc2010-03-19 11:33:06 +010015038 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
Takashi Iwaid433a672010-09-20 15:11:54 +020015039 spec->cdefine.platform_type == 1) {
Kailang Yangc027ddc2010-03-19 11:33:06 +010015040 alc_codec_rename(codec, "ALC271X");
Takashi Iwaid433a672010-09-20 15:11:54 +020015041 spec->codec_variant = ALC269_TYPE_ALC271X;
15042 } else {
Kailang Yangc027ddc2010-03-19 11:33:06 +010015043 alc_codec_rename(codec, "ALC259");
Takashi Iwaid433a672010-09-20 15:11:54 +020015044 spec->codec_variant = ALC269_TYPE_ALC259;
15045 }
Kailang Yangc027ddc2010-03-19 11:33:06 +010015046 } else
15047 alc_fix_pll_init(codec, 0x20, 0x04, 15);
Kailang Yang274693f2009-12-03 10:07:50 +010015048
Kailang Yang977ddd62010-09-15 10:02:29 +020015049 alc269_fill_coef(codec);
15050
Kailang Yangf6a92242007-12-13 16:52:54 +010015051 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
15052 alc269_models,
15053 alc269_cfg_tbl);
15054
15055 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015056 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15057 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010015058 board_config = ALC269_AUTO;
15059 }
15060
Takashi Iwaiff818c22010-04-12 08:59:25 +020015061 if (board_config == ALC269_AUTO)
15062 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 1);
15063
Kailang Yangf6a92242007-12-13 16:52:54 +010015064 if (board_config == ALC269_AUTO) {
15065 /* automatic parse from the BIOS config */
15066 err = alc269_parse_auto_config(codec);
15067 if (err < 0) {
15068 alc_free(codec);
15069 return err;
15070 } else if (!err) {
15071 printk(KERN_INFO
15072 "hda_codec: Cannot set up configuration "
15073 "from BIOS. Using base mode...\n");
15074 board_config = ALC269_BASIC;
15075 }
15076 }
15077
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015078 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020015079 err = snd_hda_attach_beep_device(codec, 0x1);
15080 if (err < 0) {
15081 alc_free(codec);
15082 return err;
15083 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015084 }
15085
Kailang Yangf6a92242007-12-13 16:52:54 +010015086 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015087 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010015088
Kailang Yang84898e82010-02-04 14:16:14 +010015089 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010015090 /* Due to a hardware problem on Lenovo Ideadpad, we need to
15091 * fix the sample rate of analog I/O to 44.1kHz
15092 */
15093 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
15094 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020015095 } else if (spec->dual_adc_switch) {
15096 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15097 /* switch ADC dynamically */
15098 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010015099 } else {
15100 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15101 spec->stream_analog_capture = &alc269_pcm_analog_capture;
15102 }
Kailang Yangf6a92242007-12-13 16:52:54 +010015103 spec->stream_digital_playback = &alc269_pcm_digital_playback;
15104 spec->stream_digital_capture = &alc269_pcm_digital_capture;
15105
Takashi Iwai66946352010-03-29 17:21:45 +020015106 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
Takashi Iwaid433a672010-09-20 15:11:54 +020015107 if (spec->codec_variant != ALC269_TYPE_NORMAL) {
Takashi Iwai66946352010-03-29 17:21:45 +020015108 spec->adc_nids = alc269_adc_nids;
15109 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
15110 spec->capsrc_nids = alc269_capsrc_nids;
15111 } else {
15112 spec->adc_nids = alc269vb_adc_nids;
15113 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
15114 spec->capsrc_nids = alc269vb_capsrc_nids;
15115 }
Kailang Yang84898e82010-02-04 14:16:14 +010015116 }
15117
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015118 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015119 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015120 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010015121 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010015122
Takashi Iwaiff818c22010-04-12 08:59:25 +020015123 if (board_config == ALC269_AUTO)
15124 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 0);
15125
Takashi Iwai100d5eb2009-08-10 11:55:51 +020015126 spec->vmaster_nid = 0x02;
15127
Kailang Yangf6a92242007-12-13 16:52:54 +010015128 codec->patch_ops = alc_patch_ops;
Kailang Yang977ddd62010-09-15 10:02:29 +020015129#ifdef CONFIG_SND_HDA_POWER_SAVE
15130 codec->patch_ops.suspend = alc269_suspend;
15131#endif
15132#ifdef SND_HDA_NEEDS_RESUME
15133 codec->patch_ops.resume = alc269_resume;
15134#endif
Kailang Yangf6a92242007-12-13 16:52:54 +010015135 if (board_config == ALC269_AUTO)
15136 spec->init_hook = alc269_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020015137
15138 alc_init_jacks(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010015139#ifdef CONFIG_SND_HDA_POWER_SAVE
15140 if (!spec->loopback.amplist)
15141 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020015142 if (alc269_mic2_for_mute_led(codec))
15143 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010015144#endif
15145
15146 return 0;
15147}
15148
15149/*
Kailang Yangdf694da2005-12-05 19:42:22 +010015150 * ALC861 channel source setting (2/6 channel selection for 3-stack)
15151 */
15152
15153/*
15154 * set the path ways for 2 channel output
15155 * need to set the codec line out and mic 1 pin widgets to inputs
15156 */
15157static struct hda_verb alc861_threestack_ch2_init[] = {
15158 /* set pin widget 1Ah (line in) for input */
15159 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015160 /* set pin widget 18h (mic1/2) for input, for mic also enable
15161 * the vref
15162 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015163 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15164
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015165 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15166#if 0
15167 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15168 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15169#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015170 { } /* end */
15171};
15172/*
15173 * 6ch mode
15174 * need to set the codec line out and mic 1 pin widgets to outputs
15175 */
15176static struct hda_verb alc861_threestack_ch6_init[] = {
15177 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15178 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15179 /* set pin widget 18h (mic1) for output (CLFE)*/
15180 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15181
15182 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015183 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015184
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015185 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15186#if 0
15187 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15188 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15189#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015190 { } /* end */
15191};
15192
15193static struct hda_channel_mode alc861_threestack_modes[2] = {
15194 { 2, alc861_threestack_ch2_init },
15195 { 6, alc861_threestack_ch6_init },
15196};
Takashi Iwai22309c32006-08-09 16:57:28 +020015197/* Set mic1 as input and unmute the mixer */
15198static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
15199 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15200 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15201 { } /* end */
15202};
15203/* Set mic1 as output and mute mixer */
15204static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
15205 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15206 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15207 { } /* end */
15208};
15209
15210static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
15211 { 2, alc861_uniwill_m31_ch2_init },
15212 { 4, alc861_uniwill_m31_ch4_init },
15213};
Kailang Yangdf694da2005-12-05 19:42:22 +010015214
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015215/* Set mic1 and line-in as input and unmute the mixer */
15216static struct hda_verb alc861_asus_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 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015222 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15223
15224 { 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
15229 { } /* end */
15230};
15231/* Set mic1 nad line-in as output and mute mixer */
15232static struct hda_verb alc861_asus_ch6_init[] = {
15233 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15234 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15235 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15236 /* set pin widget 18h (mic1) for output (CLFE)*/
15237 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15238 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15239 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
15240 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
15241
15242 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15243#if 0
15244 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15245 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15246#endif
15247 { } /* end */
15248};
15249
15250static struct hda_channel_mode alc861_asus_modes[2] = {
15251 { 2, alc861_asus_ch2_init },
15252 { 6, alc861_asus_ch6_init },
15253};
15254
Kailang Yangdf694da2005-12-05 19:42:22 +010015255/* patch-ALC861 */
15256
15257static struct snd_kcontrol_new alc861_base_mixer[] = {
15258 /* output mixer control */
15259 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15260 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15261 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15262 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15263 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15264
15265 /*Input mixer control */
15266 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15267 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15268 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15269 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15270 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15271 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15272 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15273 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15274 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15275 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015276
Kailang Yangdf694da2005-12-05 19:42:22 +010015277 { } /* end */
15278};
15279
15280static struct snd_kcontrol_new alc861_3ST_mixer[] = {
15281 /* output mixer control */
15282 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15283 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15284 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15285 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15286 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15287
15288 /* Input mixer control */
15289 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15290 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15291 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15292 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15293 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15294 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15295 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15296 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15297 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15298 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015299
Kailang Yangdf694da2005-12-05 19:42:22 +010015300 {
15301 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15302 .name = "Channel Mode",
15303 .info = alc_ch_mode_info,
15304 .get = alc_ch_mode_get,
15305 .put = alc_ch_mode_put,
15306 .private_value = ARRAY_SIZE(alc861_threestack_modes),
15307 },
15308 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015309};
15310
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015311static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015312 /* output mixer control */
15313 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15314 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15315 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015316
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015317 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015318};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015319
Takashi Iwai22309c32006-08-09 16:57:28 +020015320static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
15321 /* output mixer control */
15322 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15323 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15324 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15325 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15326 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15327
15328 /* Input mixer control */
15329 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15330 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15331 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15332 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15333 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15334 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15335 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15336 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15337 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15338 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015339
Takashi Iwai22309c32006-08-09 16:57:28 +020015340 {
15341 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15342 .name = "Channel Mode",
15343 .info = alc_ch_mode_info,
15344 .get = alc_ch_mode_get,
15345 .put = alc_ch_mode_put,
15346 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
15347 },
15348 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015349};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015350
15351static struct snd_kcontrol_new alc861_asus_mixer[] = {
15352 /* output mixer control */
15353 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15354 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15355 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15356 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15357 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15358
15359 /* Input mixer control */
15360 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15361 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15362 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15363 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15364 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15365 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15366 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15367 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15368 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015369 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
15370
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015371 {
15372 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15373 .name = "Channel Mode",
15374 .info = alc_ch_mode_info,
15375 .get = alc_ch_mode_get,
15376 .put = alc_ch_mode_put,
15377 .private_value = ARRAY_SIZE(alc861_asus_modes),
15378 },
15379 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015380};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015381
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015382/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015383static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015384 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15385 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015386 { }
15387};
15388
Kailang Yangdf694da2005-12-05 19:42:22 +010015389/*
15390 * generic initialization of ADC, input mixers and output mixers
15391 */
15392static struct hda_verb alc861_base_init_verbs[] = {
15393 /*
15394 * Unmute ADC0 and set the default input to mic-in
15395 */
15396 /* port-A for surround (rear panel) */
15397 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15398 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
15399 /* port-B for mic-in (rear panel) with vref */
15400 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15401 /* port-C for line-in (rear panel) */
15402 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15403 /* port-D for Front */
15404 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15405 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15406 /* port-E for HP out (front panel) */
15407 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15408 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015409 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015410 /* port-F for mic-in (front panel) with vref */
15411 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15412 /* port-G for CLFE (rear panel) */
15413 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15414 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15415 /* port-H for side (rear panel) */
15416 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15417 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15418 /* CD-in */
15419 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15420 /* route front mic to ADC1*/
15421 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15422 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015423
Kailang Yangdf694da2005-12-05 19:42:22 +010015424 /* Unmute DAC0~3 & spdif out*/
15425 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15426 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15427 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15428 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15429 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015430
Kailang Yangdf694da2005-12-05 19:42:22 +010015431 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15432 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15433 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15434 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15435 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015436
Kailang Yangdf694da2005-12-05 19:42:22 +010015437 /* Unmute Stereo Mixer 15 */
15438 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15439 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15440 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015441 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015442
15443 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15444 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15445 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15446 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15447 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15448 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15449 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15450 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015451 /* hp used DAC 3 (Front) */
15452 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015453 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15454
15455 { }
15456};
15457
15458static struct hda_verb alc861_threestack_init_verbs[] = {
15459 /*
15460 * Unmute ADC0 and set the default input to mic-in
15461 */
15462 /* port-A for surround (rear panel) */
15463 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15464 /* port-B for mic-in (rear panel) with vref */
15465 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15466 /* port-C for line-in (rear panel) */
15467 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15468 /* port-D for Front */
15469 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15470 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15471 /* port-E for HP out (front panel) */
15472 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15473 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015474 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015475 /* port-F for mic-in (front panel) with vref */
15476 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15477 /* port-G for CLFE (rear panel) */
15478 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15479 /* port-H for side (rear panel) */
15480 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15481 /* CD-in */
15482 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15483 /* route front mic to ADC1*/
15484 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15485 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15486 /* Unmute DAC0~3 & spdif out*/
15487 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15488 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15489 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15490 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15491 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015492
Kailang Yangdf694da2005-12-05 19:42:22 +010015493 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15494 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15495 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15496 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15497 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015498
Kailang Yangdf694da2005-12-05 19:42:22 +010015499 /* Unmute Stereo Mixer 15 */
15500 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15501 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15502 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015503 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015504
15505 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15506 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15507 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15508 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15509 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15510 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15511 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15512 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015513 /* hp used DAC 3 (Front) */
15514 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015515 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15516 { }
15517};
Takashi Iwai22309c32006-08-09 16:57:28 +020015518
15519static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
15520 /*
15521 * Unmute ADC0 and set the default input to mic-in
15522 */
15523 /* port-A for surround (rear panel) */
15524 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15525 /* port-B for mic-in (rear panel) with vref */
15526 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15527 /* port-C for line-in (rear panel) */
15528 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15529 /* port-D for Front */
15530 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15531 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15532 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015533 /* this has to be set to VREF80 */
15534 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015535 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015536 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015537 /* port-F for mic-in (front panel) with vref */
15538 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15539 /* port-G for CLFE (rear panel) */
15540 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15541 /* port-H for side (rear panel) */
15542 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15543 /* CD-in */
15544 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15545 /* route front mic to ADC1*/
15546 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15547 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15548 /* Unmute DAC0~3 & spdif out*/
15549 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15550 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15551 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15552 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15553 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015554
Takashi Iwai22309c32006-08-09 16:57:28 +020015555 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15556 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15557 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15558 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15559 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015560
Takashi Iwai22309c32006-08-09 16:57:28 +020015561 /* Unmute Stereo Mixer 15 */
15562 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15563 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15564 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015565 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015566
15567 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15568 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15569 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15570 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15571 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15572 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15573 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15574 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015575 /* hp used DAC 3 (Front) */
15576 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015577 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15578 { }
15579};
15580
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015581static struct hda_verb alc861_asus_init_verbs[] = {
15582 /*
15583 * Unmute ADC0 and set the default input to mic-in
15584 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015585 /* port-A for surround (rear panel)
15586 * according to codec#0 this is the HP jack
15587 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015588 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15589 /* route front PCM to HP */
15590 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15591 /* port-B for mic-in (rear panel) with vref */
15592 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15593 /* port-C for line-in (rear panel) */
15594 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15595 /* port-D for Front */
15596 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15597 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15598 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015599 /* this has to be set to VREF80 */
15600 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015601 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015602 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015603 /* port-F for mic-in (front panel) with vref */
15604 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15605 /* port-G for CLFE (rear panel) */
15606 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15607 /* port-H for side (rear panel) */
15608 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15609 /* CD-in */
15610 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15611 /* route front mic to ADC1*/
15612 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15613 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15614 /* Unmute DAC0~3 & spdif out*/
15615 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15616 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15617 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15618 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15619 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15620 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15621 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15622 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15623 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15624 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015625
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015626 /* Unmute Stereo Mixer 15 */
15627 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15628 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15629 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015630 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015631
15632 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15633 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15634 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15635 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15636 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15637 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15638 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15639 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015640 /* hp used DAC 3 (Front) */
15641 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015642 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15643 { }
15644};
15645
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015646/* additional init verbs for ASUS laptops */
15647static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15648 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15649 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15650 { }
15651};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015652
Kailang Yangdf694da2005-12-05 19:42:22 +010015653/*
15654 * generic initialization of ADC, input mixers and output mixers
15655 */
15656static struct hda_verb alc861_auto_init_verbs[] = {
15657 /*
15658 * Unmute ADC0 and set the default input to mic-in
15659 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015660 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015661 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015662
Kailang Yangdf694da2005-12-05 19:42:22 +010015663 /* Unmute DAC0~3 & spdif out*/
15664 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15665 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15666 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15667 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15668 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015669
Kailang Yangdf694da2005-12-05 19:42:22 +010015670 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15671 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15672 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15673 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15674 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015675
Kailang Yangdf694da2005-12-05 19:42:22 +010015676 /* Unmute Stereo Mixer 15 */
15677 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15678 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15679 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15680 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15681
Takashi Iwai1c209302009-07-22 15:17:45 +020015682 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15683 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15684 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15685 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15686 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15687 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15688 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15689 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015690
15691 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15692 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015693 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15694 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015695 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15696 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015697 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15698 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015699
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015700 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015701
15702 { }
15703};
15704
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015705static struct hda_verb alc861_toshiba_init_verbs[] = {
15706 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015707
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015708 { }
15709};
15710
15711/* toggle speaker-output according to the hp-jack state */
15712static void alc861_toshiba_automute(struct hda_codec *codec)
15713{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015714 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015715
Takashi Iwai47fd8302007-08-10 17:11:07 +020015716 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15717 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15718 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15719 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015720}
15721
15722static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15723 unsigned int res)
15724{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015725 if ((res >> 26) == ALC880_HP_EVENT)
15726 alc861_toshiba_automute(codec);
15727}
15728
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015729/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015730#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15731#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15732#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15733#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15734
15735
15736#define ALC861_DIGOUT_NID 0x07
15737
15738static struct hda_channel_mode alc861_8ch_modes[1] = {
15739 { 8, NULL }
15740};
15741
15742static hda_nid_t alc861_dac_nids[4] = {
15743 /* front, surround, clfe, side */
15744 0x03, 0x06, 0x05, 0x04
15745};
15746
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015747static hda_nid_t alc660_dac_nids[3] = {
15748 /* front, clfe, surround */
15749 0x03, 0x05, 0x06
15750};
15751
Kailang Yangdf694da2005-12-05 19:42:22 +010015752static hda_nid_t alc861_adc_nids[1] = {
15753 /* ADC0-2 */
15754 0x08,
15755};
15756
15757static struct hda_input_mux alc861_capture_source = {
15758 .num_items = 5,
15759 .items = {
15760 { "Mic", 0x0 },
15761 { "Front Mic", 0x3 },
15762 { "Line", 0x1 },
15763 { "CD", 0x4 },
15764 { "Mixer", 0x5 },
15765 },
15766};
15767
Takashi Iwai1c209302009-07-22 15:17:45 +020015768static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15769{
15770 struct alc_spec *spec = codec->spec;
15771 hda_nid_t mix, srcs[5];
15772 int i, j, num;
15773
15774 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15775 return 0;
15776 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15777 if (num < 0)
15778 return 0;
15779 for (i = 0; i < num; i++) {
15780 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015781 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015782 if (type != AC_WID_AUD_OUT)
15783 continue;
15784 for (j = 0; j < spec->multiout.num_dacs; j++)
15785 if (spec->multiout.dac_nids[j] == srcs[i])
15786 break;
15787 if (j >= spec->multiout.num_dacs)
15788 return srcs[i];
15789 }
15790 return 0;
15791}
15792
Kailang Yangdf694da2005-12-05 19:42:22 +010015793/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015794static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015795 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015796{
Takashi Iwai1c209302009-07-22 15:17:45 +020015797 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015798 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015799 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015800
15801 spec->multiout.dac_nids = spec->private_dac_nids;
15802 for (i = 0; i < cfg->line_outs; i++) {
15803 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015804 dac = alc861_look_for_dac(codec, nid);
15805 if (!dac)
15806 continue;
15807 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015808 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015809 return 0;
15810}
15811
Takashi Iwai1c209302009-07-22 15:17:45 +020015812static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15813 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015814{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015815 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015816 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15817}
15818
15819/* add playback controls from the parsed DAC table */
15820static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15821 const struct auto_pin_cfg *cfg)
15822{
15823 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015824 static const char *chname[4] = {
15825 "Front", "Surround", NULL /*CLFE*/, "Side"
15826 };
Kailang Yangdf694da2005-12-05 19:42:22 +010015827 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020015828 int i, err;
15829
15830 if (cfg->line_outs == 1) {
15831 const char *pfx = NULL;
15832 if (!cfg->hp_outs)
15833 pfx = "Master";
15834 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15835 pfx = "Speaker";
15836 if (pfx) {
15837 nid = spec->multiout.dac_nids[0];
15838 return alc861_create_out_sw(codec, pfx, nid, 3);
15839 }
15840 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015841
15842 for (i = 0; i < cfg->line_outs; i++) {
15843 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015844 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015845 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020015846 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015847 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015848 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015849 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015850 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015851 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015852 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015853 return err;
15854 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020015855 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015856 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015857 return err;
15858 }
15859 }
15860 return 0;
15861}
15862
Takashi Iwai1c209302009-07-22 15:17:45 +020015863static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015864{
Takashi Iwai1c209302009-07-22 15:17:45 +020015865 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015866 int err;
15867 hda_nid_t nid;
15868
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015869 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015870 return 0;
15871
15872 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020015873 nid = alc861_look_for_dac(codec, pin);
15874 if (nid) {
15875 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
15876 if (err < 0)
15877 return err;
15878 spec->multiout.hp_nid = nid;
15879 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015880 }
15881 return 0;
15882}
15883
15884/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015885static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015886 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015887{
Takashi Iwai05f5f472009-08-25 13:10:18 +020015888 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010015889}
15890
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015891static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
15892 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020015893 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010015894{
Takashi Iwai1c209302009-07-22 15:17:45 +020015895 hda_nid_t mix, srcs[5];
15896 int i, num;
15897
Jacek Luczak564c5be2008-05-03 18:41:23 +020015898 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
15899 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020015900 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020015901 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020015902 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
15903 return;
15904 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15905 if (num < 0)
15906 return;
15907 for (i = 0; i < num; i++) {
15908 unsigned int mute;
15909 if (srcs[i] == dac || srcs[i] == 0x15)
15910 mute = AMP_IN_UNMUTE(i);
15911 else
15912 mute = AMP_IN_MUTE(i);
15913 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15914 mute);
15915 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015916}
15917
15918static void alc861_auto_init_multi_out(struct hda_codec *codec)
15919{
15920 struct alc_spec *spec = codec->spec;
15921 int i;
15922
15923 for (i = 0; i < spec->autocfg.line_outs; i++) {
15924 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015925 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015926 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015927 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015928 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015929 }
15930}
15931
15932static void alc861_auto_init_hp_out(struct hda_codec *codec)
15933{
15934 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015935
Takashi Iwai15870f02009-10-05 08:25:13 +020015936 if (spec->autocfg.hp_outs)
15937 alc861_auto_set_output_and_unmute(codec,
15938 spec->autocfg.hp_pins[0],
15939 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020015940 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020015941 if (spec->autocfg.speaker_outs)
15942 alc861_auto_set_output_and_unmute(codec,
15943 spec->autocfg.speaker_pins[0],
15944 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020015945 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015946}
15947
15948static void alc861_auto_init_analog_input(struct hda_codec *codec)
15949{
15950 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020015951 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +010015952 int i;
15953
Takashi Iwai66ceeb62010-08-30 13:05:52 +020015954 for (i = 0; i < cfg->num_inputs; i++) {
15955 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai23f0c042009-02-26 13:03:58 +010015956 if (nid >= 0x0c && nid <= 0x11)
Takashi Iwai30ea0982010-09-16 18:47:56 +020015957 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015958 }
15959}
15960
15961/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015962/* return 1 if successful, 0 if the proper config is not found,
15963 * or a negative error code
15964 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015965static int alc861_parse_auto_config(struct hda_codec *codec)
15966{
15967 struct alc_spec *spec = codec->spec;
15968 int err;
15969 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
15970
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015971 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15972 alc861_ignore);
15973 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015974 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015975 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015976 return 0; /* can't find valid BIOS pin config */
15977
Takashi Iwai1c209302009-07-22 15:17:45 +020015978 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015979 if (err < 0)
15980 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015981 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015982 if (err < 0)
15983 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015984 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015985 if (err < 0)
15986 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015987 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015988 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015989 return err;
15990
15991 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15992
Takashi Iwai757899a2010-07-30 10:48:14 +020015993 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015994
Takashi Iwai603c4012008-07-30 15:01:44 +020015995 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015996 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010015997
Takashi Iwaid88897e2008-10-31 15:01:37 +010015998 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010015999
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020016000 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016001 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010016002
16003 spec->adc_nids = alc861_adc_nids;
16004 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016005 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016006
Kailang Yang6227cdc2010-02-25 08:36:52 +010016007 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016008
Kailang Yangdf694da2005-12-05 19:42:22 +010016009 return 1;
16010}
16011
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016012/* additional initialization for auto-configuration model */
16013static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010016014{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016015 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016016 alc861_auto_init_multi_out(codec);
16017 alc861_auto_init_hp_out(codec);
16018 alc861_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020016019 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016020 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016021 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016022}
16023
Takashi Iwaicb53c622007-08-10 17:21:45 +020016024#ifdef CONFIG_SND_HDA_POWER_SAVE
16025static struct hda_amp_list alc861_loopbacks[] = {
16026 { 0x15, HDA_INPUT, 0 },
16027 { 0x15, HDA_INPUT, 1 },
16028 { 0x15, HDA_INPUT, 2 },
16029 { 0x15, HDA_INPUT, 3 },
16030 { } /* end */
16031};
16032#endif
16033
Kailang Yangdf694da2005-12-05 19:42:22 +010016034
16035/*
16036 * configuration and preset
16037 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016038static const char *alc861_models[ALC861_MODEL_LAST] = {
16039 [ALC861_3ST] = "3stack",
16040 [ALC660_3ST] = "3stack-660",
16041 [ALC861_3ST_DIG] = "3stack-dig",
16042 [ALC861_6ST_DIG] = "6stack-dig",
16043 [ALC861_UNIWILL_M31] = "uniwill-m31",
16044 [ALC861_TOSHIBA] = "toshiba",
16045 [ALC861_ASUS] = "asus",
16046 [ALC861_ASUS_LAPTOP] = "asus-laptop",
16047 [ALC861_AUTO] = "auto",
16048};
16049
16050static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010016051 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016052 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16053 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16054 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016055 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020016056 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010016057 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020016058 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
16059 * Any other models that need this preset?
16060 */
16061 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020016062 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
16063 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016064 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
16065 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
16066 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
16067 /* FIXME: the below seems conflict */
16068 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
16069 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
16070 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010016071 {}
16072};
16073
16074static struct alc_config_preset alc861_presets[] = {
16075 [ALC861_3ST] = {
16076 .mixers = { alc861_3ST_mixer },
16077 .init_verbs = { alc861_threestack_init_verbs },
16078 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16079 .dac_nids = alc861_dac_nids,
16080 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16081 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016082 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016083 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16084 .adc_nids = alc861_adc_nids,
16085 .input_mux = &alc861_capture_source,
16086 },
16087 [ALC861_3ST_DIG] = {
16088 .mixers = { alc861_base_mixer },
16089 .init_verbs = { alc861_threestack_init_verbs },
16090 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16091 .dac_nids = alc861_dac_nids,
16092 .dig_out_nid = ALC861_DIGOUT_NID,
16093 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16094 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016095 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016096 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16097 .adc_nids = alc861_adc_nids,
16098 .input_mux = &alc861_capture_source,
16099 },
16100 [ALC861_6ST_DIG] = {
16101 .mixers = { alc861_base_mixer },
16102 .init_verbs = { alc861_base_init_verbs },
16103 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16104 .dac_nids = alc861_dac_nids,
16105 .dig_out_nid = ALC861_DIGOUT_NID,
16106 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
16107 .channel_mode = alc861_8ch_modes,
16108 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16109 .adc_nids = alc861_adc_nids,
16110 .input_mux = &alc861_capture_source,
16111 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016112 [ALC660_3ST] = {
16113 .mixers = { alc861_3ST_mixer },
16114 .init_verbs = { alc861_threestack_init_verbs },
16115 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
16116 .dac_nids = alc660_dac_nids,
16117 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16118 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016119 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016120 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16121 .adc_nids = alc861_adc_nids,
16122 .input_mux = &alc861_capture_source,
16123 },
Takashi Iwai22309c32006-08-09 16:57:28 +020016124 [ALC861_UNIWILL_M31] = {
16125 .mixers = { alc861_uniwill_m31_mixer },
16126 .init_verbs = { alc861_uniwill_m31_init_verbs },
16127 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16128 .dac_nids = alc861_dac_nids,
16129 .dig_out_nid = ALC861_DIGOUT_NID,
16130 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
16131 .channel_mode = alc861_uniwill_m31_modes,
16132 .need_dac_fix = 1,
16133 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16134 .adc_nids = alc861_adc_nids,
16135 .input_mux = &alc861_capture_source,
16136 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016137 [ALC861_TOSHIBA] = {
16138 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016139 .init_verbs = { alc861_base_init_verbs,
16140 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016141 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16142 .dac_nids = alc861_dac_nids,
16143 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16144 .channel_mode = alc883_3ST_2ch_modes,
16145 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16146 .adc_nids = alc861_adc_nids,
16147 .input_mux = &alc861_capture_source,
16148 .unsol_event = alc861_toshiba_unsol_event,
16149 .init_hook = alc861_toshiba_automute,
16150 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020016151 [ALC861_ASUS] = {
16152 .mixers = { alc861_asus_mixer },
16153 .init_verbs = { alc861_asus_init_verbs },
16154 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16155 .dac_nids = alc861_dac_nids,
16156 .dig_out_nid = ALC861_DIGOUT_NID,
16157 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
16158 .channel_mode = alc861_asus_modes,
16159 .need_dac_fix = 1,
16160 .hp_nid = 0x06,
16161 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16162 .adc_nids = alc861_adc_nids,
16163 .input_mux = &alc861_capture_source,
16164 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010016165 [ALC861_ASUS_LAPTOP] = {
16166 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
16167 .init_verbs = { alc861_asus_init_verbs,
16168 alc861_asus_laptop_init_verbs },
16169 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16170 .dac_nids = alc861_dac_nids,
16171 .dig_out_nid = ALC861_DIGOUT_NID,
16172 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16173 .channel_mode = alc883_3ST_2ch_modes,
16174 .need_dac_fix = 1,
16175 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16176 .adc_nids = alc861_adc_nids,
16177 .input_mux = &alc861_capture_source,
16178 },
16179};
Kailang Yangdf694da2005-12-05 19:42:22 +010016180
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016181/* Pin config fixes */
16182enum {
16183 PINFIX_FSC_AMILO_PI1505,
16184};
16185
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016186static const struct alc_fixup alc861_fixups[] = {
16187 [PINFIX_FSC_AMILO_PI1505] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020016188 .pins = (const struct alc_pincfg[]) {
16189 { 0x0b, 0x0221101f }, /* HP */
16190 { 0x0f, 0x90170310 }, /* speaker */
16191 { }
16192 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016193 },
16194};
16195
16196static struct snd_pci_quirk alc861_fixup_tbl[] = {
16197 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
16198 {}
16199};
Kailang Yangdf694da2005-12-05 19:42:22 +010016200
16201static int patch_alc861(struct hda_codec *codec)
16202{
16203 struct alc_spec *spec;
16204 int board_config;
16205 int err;
16206
Robert P. J. Daydc041e02006-12-19 14:44:15 +010016207 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010016208 if (spec == NULL)
16209 return -ENOMEM;
16210
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016211 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016212
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016213 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
16214 alc861_models,
16215 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016216
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016217 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016218 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16219 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010016220 board_config = ALC861_AUTO;
16221 }
16222
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016223 if (board_config == ALC861_AUTO)
16224 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 1);
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016225
Kailang Yangdf694da2005-12-05 19:42:22 +010016226 if (board_config == ALC861_AUTO) {
16227 /* automatic parse from the BIOS config */
16228 err = alc861_parse_auto_config(codec);
16229 if (err < 0) {
16230 alc_free(codec);
16231 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016232 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016233 printk(KERN_INFO
16234 "hda_codec: Cannot set up configuration "
16235 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010016236 board_config = ALC861_3ST_DIG;
16237 }
16238 }
16239
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016240 err = snd_hda_attach_beep_device(codec, 0x23);
16241 if (err < 0) {
16242 alc_free(codec);
16243 return err;
16244 }
16245
Kailang Yangdf694da2005-12-05 19:42:22 +010016246 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016247 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016248
Kailang Yangdf694da2005-12-05 19:42:22 +010016249 spec->stream_analog_playback = &alc861_pcm_analog_playback;
16250 spec->stream_analog_capture = &alc861_pcm_analog_capture;
16251
Kailang Yangdf694da2005-12-05 19:42:22 +010016252 spec->stream_digital_playback = &alc861_pcm_digital_playback;
16253 spec->stream_digital_capture = &alc861_pcm_digital_capture;
16254
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010016255 if (!spec->cap_mixer)
16256 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016257 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
16258
Takashi Iwai2134ea42008-01-10 16:53:55 +010016259 spec->vmaster_nid = 0x03;
16260
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016261 if (board_config == ALC861_AUTO)
16262 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 0);
16263
Kailang Yangdf694da2005-12-05 19:42:22 +010016264 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050016265 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016266 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016267#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050016268 spec->power_hook = alc_power_eapd;
16269#endif
16270 }
16271#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020016272 if (!spec->loopback.amplist)
16273 spec->loopback.amplist = alc861_loopbacks;
16274#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020016275
Kailang Yangdf694da2005-12-05 19:42:22 +010016276 return 0;
16277}
16278
16279/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016280 * ALC861-VD support
16281 *
16282 * Based on ALC882
16283 *
16284 * In addition, an independent DAC
16285 */
16286#define ALC861VD_DIGOUT_NID 0x06
16287
16288static hda_nid_t alc861vd_dac_nids[4] = {
16289 /* front, surr, clfe, side surr */
16290 0x02, 0x03, 0x04, 0x05
16291};
16292
16293/* dac_nids for ALC660vd are in a different order - according to
16294 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016295 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016296 * of ALC660vd codecs, but for now there is only 3stack mixer
16297 * - and it is the same as in 861vd.
16298 * adc_nids in ALC660vd are (is) the same as in 861vd
16299 */
16300static hda_nid_t alc660vd_dac_nids[3] = {
16301 /* front, rear, clfe, rear_surr */
16302 0x02, 0x04, 0x03
16303};
16304
16305static hda_nid_t alc861vd_adc_nids[1] = {
16306 /* ADC0 */
16307 0x09,
16308};
16309
Takashi Iwaie1406342008-02-11 18:32:32 +010016310static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
16311
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016312/* input MUX */
16313/* FIXME: should be a matrix-type input source selection */
16314static struct hda_input_mux alc861vd_capture_source = {
16315 .num_items = 4,
16316 .items = {
16317 { "Mic", 0x0 },
16318 { "Front Mic", 0x1 },
16319 { "Line", 0x2 },
16320 { "CD", 0x4 },
16321 },
16322};
16323
Kailang Yang272a5272007-05-14 11:00:38 +020016324static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010016325 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020016326 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010016327 { "Ext Mic", 0x0 },
16328 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020016329 },
16330};
16331
Kailang Yangd1a991a2007-08-15 16:21:59 +020016332static struct hda_input_mux alc861vd_hp_capture_source = {
16333 .num_items = 2,
16334 .items = {
16335 { "Front Mic", 0x0 },
16336 { "ATAPI Mic", 0x1 },
16337 },
16338};
16339
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016340/*
16341 * 2ch mode
16342 */
16343static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
16344 { 2, NULL }
16345};
16346
16347/*
16348 * 6ch mode
16349 */
16350static struct hda_verb alc861vd_6stack_ch6_init[] = {
16351 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16352 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16353 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16354 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16355 { } /* end */
16356};
16357
16358/*
16359 * 8ch mode
16360 */
16361static struct hda_verb alc861vd_6stack_ch8_init[] = {
16362 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16363 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16364 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16365 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16366 { } /* end */
16367};
16368
16369static struct hda_channel_mode alc861vd_6stack_modes[2] = {
16370 { 6, alc861vd_6stack_ch6_init },
16371 { 8, alc861vd_6stack_ch8_init },
16372};
16373
16374static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
16375 {
16376 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16377 .name = "Channel Mode",
16378 .info = alc_ch_mode_info,
16379 .get = alc_ch_mode_get,
16380 .put = alc_ch_mode_put,
16381 },
16382 { } /* end */
16383};
16384
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016385/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16386 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16387 */
16388static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
16389 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16390 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16391
16392 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16393 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16394
16395 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16396 HDA_OUTPUT),
16397 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16398 HDA_OUTPUT),
16399 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16400 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16401
16402 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16403 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16404
16405 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16406
16407 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16408 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16409 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16410
16411 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16412 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16413 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16414
16415 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16416 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16417
16418 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16419 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16420
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016421 { } /* end */
16422};
16423
16424static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
16425 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16426 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16427
16428 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16429
16430 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16431 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16432 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16433
16434 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16435 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16436 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16437
16438 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16439 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16440
16441 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16442 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16443
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016444 { } /* end */
16445};
16446
Kailang Yangbdd148a2007-05-08 15:19:08 +020016447static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
16448 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16449 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16450 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16451
16452 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16453
16454 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16455 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16456 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16457
16458 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16459 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16460 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16461
16462 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16463 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16464
16465 { } /* end */
16466};
16467
Tobin Davisb419f342008-03-07 11:57:51 +010016468/* Pin assignment: Speaker=0x14, HP = 0x15,
16469 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016470 */
16471static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016472 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16473 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016474 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16475 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010016476 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16477 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16478 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16479 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16480 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16481 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016482 { } /* end */
16483};
16484
Kailang Yangd1a991a2007-08-15 16:21:59 +020016485/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16486 * Front Mic=0x18, ATAPI Mic = 0x19,
16487 */
16488static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
16489 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16490 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16491 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16492 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16493 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16494 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16495 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16496 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016497
Kailang Yangd1a991a2007-08-15 16:21:59 +020016498 { } /* end */
16499};
16500
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016501/*
16502 * generic initialization of ADC, input mixers and output mixers
16503 */
16504static struct hda_verb alc861vd_volume_init_verbs[] = {
16505 /*
16506 * Unmute ADC0 and set the default input to mic-in
16507 */
16508 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16509 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16510
16511 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16512 * the analog-loopback mixer widget
16513 */
16514 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016515 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16516 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16517 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16518 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16519 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016520
16521 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016522 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16523 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16524 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016525 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016526
16527 /*
16528 * Set up output mixers (0x02 - 0x05)
16529 */
16530 /* set vol=0 to output mixers */
16531 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16532 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16533 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16534 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16535
16536 /* set up input amps for analog loopback */
16537 /* Amp Indices: DAC = 0, mixer = 1 */
16538 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16539 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16540 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16541 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16542 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16543 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16544 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16545 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16546
16547 { }
16548};
16549
16550/*
16551 * 3-stack pin configuration:
16552 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16553 */
16554static struct hda_verb alc861vd_3stack_init_verbs[] = {
16555 /*
16556 * Set pin mode and muting
16557 */
16558 /* set front pin widgets 0x14 for output */
16559 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16560 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16561 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16562
16563 /* Mic (rear) pin: input vref at 80% */
16564 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16565 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16566 /* Front Mic pin: input vref at 80% */
16567 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16568 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16569 /* Line In pin: input */
16570 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16571 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16572 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16573 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16574 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16575 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16576 /* CD pin widget for input */
16577 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16578
16579 { }
16580};
16581
16582/*
16583 * 6-stack pin configuration:
16584 */
16585static struct hda_verb alc861vd_6stack_init_verbs[] = {
16586 /*
16587 * Set pin mode and muting
16588 */
16589 /* set front pin widgets 0x14 for output */
16590 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16591 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16592 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16593
16594 /* Rear Pin: output 1 (0x0d) */
16595 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16596 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16597 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16598 /* CLFE Pin: output 2 (0x0e) */
16599 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16600 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16601 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16602 /* Side Pin: output 3 (0x0f) */
16603 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16604 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16605 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16606
16607 /* Mic (rear) pin: input vref at 80% */
16608 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16609 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16610 /* Front Mic pin: input vref at 80% */
16611 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16612 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16613 /* Line In pin: input */
16614 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16615 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16616 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16617 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16618 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16619 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16620 /* CD pin widget for input */
16621 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16622
16623 { }
16624};
16625
Kailang Yangbdd148a2007-05-08 15:19:08 +020016626static struct hda_verb alc861vd_eapd_verbs[] = {
16627 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16628 { }
16629};
16630
Kailang Yangf9423e72008-05-27 12:32:25 +020016631static struct hda_verb alc660vd_eapd_verbs[] = {
16632 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16633 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16634 { }
16635};
16636
Kailang Yangbdd148a2007-05-08 15:19:08 +020016637static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16638 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16639 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16641 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016642 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016643 {}
16644};
16645
Kailang Yangbdd148a2007-05-08 15:19:08 +020016646static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
16647{
16648 unsigned int present;
16649 unsigned char bits;
16650
Wu Fengguang864f92b2009-11-18 12:38:02 +080016651 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016652 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016653
Takashi Iwai47fd8302007-08-10 17:11:07 +020016654 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
16655 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016656}
16657
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016658static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016659{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016660 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016661 spec->autocfg.hp_pins[0] = 0x1b;
16662 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016663}
16664
16665static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16666{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016667 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016668 alc861vd_lenovo_mic_automute(codec);
16669}
16670
16671static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16672 unsigned int res)
16673{
16674 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016675 case ALC880_MIC_EVENT:
16676 alc861vd_lenovo_mic_automute(codec);
16677 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016678 default:
16679 alc_automute_amp_unsol_event(codec, res);
16680 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016681 }
16682}
16683
Kailang Yang272a5272007-05-14 11:00:38 +020016684static struct hda_verb alc861vd_dallas_verbs[] = {
16685 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16686 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16687 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16688 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16689
16690 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16691 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16692 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16693 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16694 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16695 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16696 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16697 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016698
Kailang Yang272a5272007-05-14 11:00:38 +020016699 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16700 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16701 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16702 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16703 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16704 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16705 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16706 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16707
16708 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16709 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16710 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16711 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16712 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16713 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16714 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16715 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16716
16717 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16718 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16719 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16720 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16721
16722 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016723 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016724 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16725
16726 { } /* end */
16727};
16728
16729/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016730static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016731{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016732 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016733
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016734 spec->autocfg.hp_pins[0] = 0x15;
16735 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020016736}
16737
Takashi Iwaicb53c622007-08-10 17:21:45 +020016738#ifdef CONFIG_SND_HDA_POWER_SAVE
16739#define alc861vd_loopbacks alc880_loopbacks
16740#endif
16741
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016742/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016743#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16744#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16745#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16746#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16747
16748/*
16749 * configuration and preset
16750 */
16751static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
16752 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016753 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016754 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016755 [ALC861VD_3ST] = "3stack",
16756 [ALC861VD_3ST_DIG] = "3stack-digout",
16757 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016758 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016759 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016760 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016761 [ALC861VD_AUTO] = "auto",
16762};
16763
16764static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016765 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16766 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016767 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016768 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016769 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016770 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016771 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016772 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016773 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016774 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016775 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016776 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016777 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016778 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016779 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016780 {}
16781};
16782
16783static struct alc_config_preset alc861vd_presets[] = {
16784 [ALC660VD_3ST] = {
16785 .mixers = { alc861vd_3st_mixer },
16786 .init_verbs = { alc861vd_volume_init_verbs,
16787 alc861vd_3stack_init_verbs },
16788 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16789 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016790 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16791 .channel_mode = alc861vd_3stack_2ch_modes,
16792 .input_mux = &alc861vd_capture_source,
16793 },
Mike Crash6963f842007-06-25 12:12:51 +020016794 [ALC660VD_3ST_DIG] = {
16795 .mixers = { alc861vd_3st_mixer },
16796 .init_verbs = { alc861vd_volume_init_verbs,
16797 alc861vd_3stack_init_verbs },
16798 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16799 .dac_nids = alc660vd_dac_nids,
16800 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016801 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16802 .channel_mode = alc861vd_3stack_2ch_modes,
16803 .input_mux = &alc861vd_capture_source,
16804 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016805 [ALC861VD_3ST] = {
16806 .mixers = { alc861vd_3st_mixer },
16807 .init_verbs = { alc861vd_volume_init_verbs,
16808 alc861vd_3stack_init_verbs },
16809 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16810 .dac_nids = alc861vd_dac_nids,
16811 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16812 .channel_mode = alc861vd_3stack_2ch_modes,
16813 .input_mux = &alc861vd_capture_source,
16814 },
16815 [ALC861VD_3ST_DIG] = {
16816 .mixers = { alc861vd_3st_mixer },
16817 .init_verbs = { alc861vd_volume_init_verbs,
16818 alc861vd_3stack_init_verbs },
16819 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16820 .dac_nids = alc861vd_dac_nids,
16821 .dig_out_nid = ALC861VD_DIGOUT_NID,
16822 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16823 .channel_mode = alc861vd_3stack_2ch_modes,
16824 .input_mux = &alc861vd_capture_source,
16825 },
16826 [ALC861VD_6ST_DIG] = {
16827 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16828 .init_verbs = { alc861vd_volume_init_verbs,
16829 alc861vd_6stack_init_verbs },
16830 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16831 .dac_nids = alc861vd_dac_nids,
16832 .dig_out_nid = ALC861VD_DIGOUT_NID,
16833 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16834 .channel_mode = alc861vd_6stack_modes,
16835 .input_mux = &alc861vd_capture_source,
16836 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016837 [ALC861VD_LENOVO] = {
16838 .mixers = { alc861vd_lenovo_mixer },
16839 .init_verbs = { alc861vd_volume_init_verbs,
16840 alc861vd_3stack_init_verbs,
16841 alc861vd_eapd_verbs,
16842 alc861vd_lenovo_unsol_verbs },
16843 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16844 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016845 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16846 .channel_mode = alc861vd_3stack_2ch_modes,
16847 .input_mux = &alc861vd_capture_source,
16848 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016849 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016850 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016851 },
Kailang Yang272a5272007-05-14 11:00:38 +020016852 [ALC861VD_DALLAS] = {
16853 .mixers = { alc861vd_dallas_mixer },
16854 .init_verbs = { alc861vd_dallas_verbs },
16855 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16856 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016857 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16858 .channel_mode = alc861vd_3stack_2ch_modes,
16859 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016860 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016861 .setup = alc861vd_dallas_setup,
16862 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016863 },
16864 [ALC861VD_HP] = {
16865 .mixers = { alc861vd_hp_mixer },
16866 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
16867 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16868 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016869 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016870 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16871 .channel_mode = alc861vd_3stack_2ch_modes,
16872 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016873 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016874 .setup = alc861vd_dallas_setup,
16875 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020016876 },
Takashi Iwai13c94742008-11-05 08:06:08 +010016877 [ALC660VD_ASUS_V1S] = {
16878 .mixers = { alc861vd_lenovo_mixer },
16879 .init_verbs = { alc861vd_volume_init_verbs,
16880 alc861vd_3stack_init_verbs,
16881 alc861vd_eapd_verbs,
16882 alc861vd_lenovo_unsol_verbs },
16883 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16884 .dac_nids = alc660vd_dac_nids,
16885 .dig_out_nid = ALC861VD_DIGOUT_NID,
16886 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16887 .channel_mode = alc861vd_3stack_2ch_modes,
16888 .input_mux = &alc861vd_capture_source,
16889 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016890 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016891 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010016892 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016893};
16894
16895/*
16896 * BIOS auto configuration
16897 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016898static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
16899 const struct auto_pin_cfg *cfg)
16900{
Kailang Yang6227cdc2010-02-25 08:36:52 +010016901 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020016902}
16903
16904
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016905static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
16906 hda_nid_t nid, int pin_type, int dac_idx)
16907{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016908 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016909}
16910
16911static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
16912{
16913 struct alc_spec *spec = codec->spec;
16914 int i;
16915
16916 for (i = 0; i <= HDA_SIDE; i++) {
16917 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016918 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016919 if (nid)
16920 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016921 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016922 }
16923}
16924
16925
16926static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
16927{
16928 struct alc_spec *spec = codec->spec;
16929 hda_nid_t pin;
16930
16931 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016932 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016933 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016934 pin = spec->autocfg.speaker_pins[0];
16935 if (pin)
16936 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016937}
16938
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016939#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
16940
16941static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
16942{
16943 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016944 struct auto_pin_cfg *cfg = &spec->autocfg;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016945 int i;
16946
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016947 for (i = 0; i < cfg->num_inputs; i++) {
16948 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016949 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020016950 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +010016951 if (nid != ALC861VD_PIN_CD_NID &&
16952 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016953 snd_hda_codec_write(codec, nid, 0,
16954 AC_VERB_SET_AMP_GAIN_MUTE,
16955 AMP_OUT_MUTE);
16956 }
16957 }
16958}
16959
Takashi Iwaif511b012008-08-15 16:46:42 +020016960#define alc861vd_auto_init_input_src alc882_auto_init_input_src
16961
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016962#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
16963#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
16964
16965/* add playback controls from the parsed DAC table */
16966/* Based on ALC880 version. But ALC861VD has separate,
16967 * different NIDs for mute/unmute switch and volume control */
16968static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
16969 const struct auto_pin_cfg *cfg)
16970{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016971 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
16972 hda_nid_t nid_v, nid_s;
16973 int i, err;
16974
16975 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016976 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016977 continue;
16978 nid_v = alc861vd_idx_to_mixer_vol(
16979 alc880_dac_to_idx(
16980 spec->multiout.dac_nids[i]));
16981 nid_s = alc861vd_idx_to_mixer_switch(
16982 alc880_dac_to_idx(
16983 spec->multiout.dac_nids[i]));
16984
16985 if (i == 2) {
16986 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016987 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16988 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016989 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
16990 HDA_OUTPUT));
16991 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016992 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016993 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16994 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016995 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
16996 HDA_OUTPUT));
16997 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016998 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016999 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17000 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017001 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
17002 HDA_INPUT));
17003 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017004 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017005 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17006 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017007 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
17008 HDA_INPUT));
17009 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017010 return err;
17011 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020017012 const char *pfx;
17013 if (cfg->line_outs == 1 &&
17014 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
17015 if (!cfg->hp_pins)
17016 pfx = "Speaker";
17017 else
17018 pfx = "PCM";
17019 } else
17020 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017021 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017022 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
17023 HDA_OUTPUT));
17024 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017025 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020017026 if (cfg->line_outs == 1 &&
17027 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
17028 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017029 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020017030 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017031 HDA_INPUT));
17032 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017033 return err;
17034 }
17035 }
17036 return 0;
17037}
17038
17039/* add playback controls for speaker and HP outputs */
17040/* Based on ALC880 version. But ALC861VD has separate,
17041 * different NIDs for mute/unmute switch and volume control */
17042static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
17043 hda_nid_t pin, const char *pfx)
17044{
17045 hda_nid_t nid_v, nid_s;
17046 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017047
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017048 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017049 return 0;
17050
17051 if (alc880_is_fixed_pin(pin)) {
17052 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17053 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017054 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017055 spec->multiout.hp_nid = nid_v;
17056 else
17057 spec->multiout.extra_out_nid[0] = nid_v;
17058 /* control HP volume/switch on the output mixer amp */
17059 nid_v = alc861vd_idx_to_mixer_vol(
17060 alc880_fixed_pin_idx(pin));
17061 nid_s = alc861vd_idx_to_mixer_switch(
17062 alc880_fixed_pin_idx(pin));
17063
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017064 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017065 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
17066 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017067 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017068 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017069 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
17070 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017071 return err;
17072 } else if (alc880_is_multi_pin(pin)) {
17073 /* set manual connection */
17074 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017075 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017076 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17077 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017078 return err;
17079 }
17080 return 0;
17081}
17082
17083/* parse the BIOS configuration and set up the alc_spec
17084 * return 1 if successful, 0 if the proper config is not found,
17085 * or a negative error code
17086 * Based on ALC880 version - had to change it to override
17087 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
17088static int alc861vd_parse_auto_config(struct hda_codec *codec)
17089{
17090 struct alc_spec *spec = codec->spec;
17091 int err;
17092 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
17093
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017094 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17095 alc861vd_ignore);
17096 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017097 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017098 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017099 return 0; /* can't find valid BIOS pin config */
17100
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017101 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17102 if (err < 0)
17103 return err;
17104 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
17105 if (err < 0)
17106 return err;
17107 err = alc861vd_auto_create_extra_out(spec,
17108 spec->autocfg.speaker_pins[0],
17109 "Speaker");
17110 if (err < 0)
17111 return err;
17112 err = alc861vd_auto_create_extra_out(spec,
17113 spec->autocfg.hp_pins[0],
17114 "Headphone");
17115 if (err < 0)
17116 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017117 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017118 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017119 return err;
17120
17121 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17122
Takashi Iwai757899a2010-07-30 10:48:14 +020017123 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017124
Takashi Iwai603c4012008-07-30 15:01:44 +020017125 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017126 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017127
Takashi Iwaid88897e2008-10-31 15:01:37 +010017128 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017129
17130 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017131 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017132
Takashi Iwai776e1842007-08-29 15:07:11 +020017133 err = alc_auto_add_mic_boost(codec);
17134 if (err < 0)
17135 return err;
17136
Kailang Yang6227cdc2010-02-25 08:36:52 +010017137 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017138
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017139 return 1;
17140}
17141
17142/* additional initialization for auto-configuration model */
17143static void alc861vd_auto_init(struct hda_codec *codec)
17144{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017145 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017146 alc861vd_auto_init_multi_out(codec);
17147 alc861vd_auto_init_hp_out(codec);
17148 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017149 alc861vd_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020017150 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017151 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017152 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017153}
17154
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017155enum {
17156 ALC660VD_FIX_ASUS_GPIO1
17157};
17158
17159/* reset GPIO1 */
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017160static const struct alc_fixup alc861vd_fixups[] = {
17161 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020017162 .verbs = (const struct hda_verb[]) {
17163 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
17164 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
17165 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
17166 { }
17167 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017168 },
17169};
17170
17171static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
17172 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
17173 {}
17174};
17175
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017176static int patch_alc861vd(struct hda_codec *codec)
17177{
17178 struct alc_spec *spec;
17179 int err, board_config;
17180
17181 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17182 if (spec == NULL)
17183 return -ENOMEM;
17184
17185 codec->spec = spec;
17186
17187 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
17188 alc861vd_models,
17189 alc861vd_cfg_tbl);
17190
17191 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017192 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17193 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017194 board_config = ALC861VD_AUTO;
17195 }
17196
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017197 if (board_config == ALC861VD_AUTO)
17198 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 1);
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017199
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017200 if (board_config == ALC861VD_AUTO) {
17201 /* automatic parse from the BIOS config */
17202 err = alc861vd_parse_auto_config(codec);
17203 if (err < 0) {
17204 alc_free(codec);
17205 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017206 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017207 printk(KERN_INFO
17208 "hda_codec: Cannot set up configuration "
17209 "from BIOS. Using base mode...\n");
17210 board_config = ALC861VD_3ST;
17211 }
17212 }
17213
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017214 err = snd_hda_attach_beep_device(codec, 0x23);
17215 if (err < 0) {
17216 alc_free(codec);
17217 return err;
17218 }
17219
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017220 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017221 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017222
Kailang Yang2f893282008-05-27 12:14:47 +020017223 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020017224 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010017225 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020017226 }
17227
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017228 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
17229 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
17230
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017231 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
17232 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
17233
Takashi Iwaidd704692009-08-11 08:45:11 +020017234 if (!spec->adc_nids) {
17235 spec->adc_nids = alc861vd_adc_nids;
17236 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
17237 }
17238 if (!spec->capsrc_nids)
17239 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017240
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017241 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010017242 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017243
Takashi Iwai2134ea42008-01-10 16:53:55 +010017244 spec->vmaster_nid = 0x02;
17245
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017246 if (board_config == ALC861VD_AUTO)
17247 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 0);
17248
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017249 codec->patch_ops = alc_patch_ops;
17250
17251 if (board_config == ALC861VD_AUTO)
17252 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017253#ifdef CONFIG_SND_HDA_POWER_SAVE
17254 if (!spec->loopback.amplist)
17255 spec->loopback.amplist = alc861vd_loopbacks;
17256#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017257
17258 return 0;
17259}
17260
17261/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017262 * ALC662 support
17263 *
17264 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
17265 * configuration. Each pin widget can choose any input DACs and a mixer.
17266 * Each ADC is connected from a mixer of all inputs. This makes possible
17267 * 6-channel independent captures.
17268 *
17269 * In addition, an independent DAC for the multi-playback (not used in this
17270 * driver yet).
17271 */
17272#define ALC662_DIGOUT_NID 0x06
17273#define ALC662_DIGIN_NID 0x0a
17274
17275static hda_nid_t alc662_dac_nids[4] = {
17276 /* front, rear, clfe, rear_surr */
17277 0x02, 0x03, 0x04
17278};
17279
Kailang Yang622e84c2009-04-21 07:39:04 +020017280static hda_nid_t alc272_dac_nids[2] = {
17281 0x02, 0x03
17282};
17283
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017284static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017285 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017286 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017287};
Takashi Iwaie1406342008-02-11 18:32:32 +010017288
Kailang Yang622e84c2009-04-21 07:39:04 +020017289static hda_nid_t alc272_adc_nids[1] = {
17290 /* ADC1-2 */
17291 0x08,
17292};
17293
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017294static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020017295static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
17296
Takashi Iwaie1406342008-02-11 18:32:32 +010017297
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017298/* input MUX */
17299/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017300static struct hda_input_mux alc662_capture_source = {
17301 .num_items = 4,
17302 .items = {
17303 { "Mic", 0x0 },
17304 { "Front Mic", 0x1 },
17305 { "Line", 0x2 },
17306 { "CD", 0x4 },
17307 },
17308};
17309
17310static struct hda_input_mux alc662_lenovo_101e_capture_source = {
17311 .num_items = 2,
17312 .items = {
17313 { "Mic", 0x1 },
17314 { "Line", 0x2 },
17315 },
17316};
Kailang Yang291702f2007-10-16 14:28:03 +020017317
Kailang Yang6dda9f42008-05-27 12:05:31 +020017318static struct hda_input_mux alc663_capture_source = {
17319 .num_items = 3,
17320 .items = {
17321 { "Mic", 0x0 },
17322 { "Front Mic", 0x1 },
17323 { "Line", 0x2 },
17324 },
17325};
17326
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017327#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020017328static struct hda_input_mux alc272_nc10_capture_source = {
17329 .num_items = 16,
17330 .items = {
17331 { "Autoselect Mic", 0x0 },
17332 { "Internal Mic", 0x1 },
17333 { "In-0x02", 0x2 },
17334 { "In-0x03", 0x3 },
17335 { "In-0x04", 0x4 },
17336 { "In-0x05", 0x5 },
17337 { "In-0x06", 0x6 },
17338 { "In-0x07", 0x7 },
17339 { "In-0x08", 0x8 },
17340 { "In-0x09", 0x9 },
17341 { "In-0x0a", 0x0a },
17342 { "In-0x0b", 0x0b },
17343 { "In-0x0c", 0x0c },
17344 { "In-0x0d", 0x0d },
17345 { "In-0x0e", 0x0e },
17346 { "In-0x0f", 0x0f },
17347 },
17348};
17349#endif
17350
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017351/*
17352 * 2ch mode
17353 */
17354static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
17355 { 2, NULL }
17356};
17357
17358/*
17359 * 2ch mode
17360 */
17361static struct hda_verb alc662_3ST_ch2_init[] = {
17362 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
17363 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17364 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
17365 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17366 { } /* end */
17367};
17368
17369/*
17370 * 6ch mode
17371 */
17372static struct hda_verb alc662_3ST_ch6_init[] = {
17373 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17374 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17375 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17376 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17377 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17378 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17379 { } /* end */
17380};
17381
17382static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
17383 { 2, alc662_3ST_ch2_init },
17384 { 6, alc662_3ST_ch6_init },
17385};
17386
17387/*
17388 * 2ch mode
17389 */
17390static struct hda_verb alc662_sixstack_ch6_init[] = {
17391 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17392 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17393 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17394 { } /* end */
17395};
17396
17397/*
17398 * 6ch mode
17399 */
17400static struct hda_verb alc662_sixstack_ch8_init[] = {
17401 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17402 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17403 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17404 { } /* end */
17405};
17406
17407static struct hda_channel_mode alc662_5stack_modes[2] = {
17408 { 2, alc662_sixstack_ch6_init },
17409 { 6, alc662_sixstack_ch8_init },
17410};
17411
17412/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17413 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17414 */
17415
17416static struct snd_kcontrol_new alc662_base_mixer[] = {
17417 /* output mixer control */
17418 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017419 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017420 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017421 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017422 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17423 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017424 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17425 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017426 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17427
17428 /*Input mixer control */
17429 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17430 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17431 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17432 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17433 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17434 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17435 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17436 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017437 { } /* end */
17438};
17439
17440static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
17441 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017442 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017443 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17444 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17445 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17446 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17447 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17448 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17449 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17450 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17451 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017452 { } /* end */
17453};
17454
17455static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
17456 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017457 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017458 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017459 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017460 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17461 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017462 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17463 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017464 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17465 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17466 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17467 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17468 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17469 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17470 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17471 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17472 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017473 { } /* end */
17474};
17475
17476static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
17477 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17478 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017479 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17480 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017481 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17482 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17483 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17484 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17485 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017486 { } /* end */
17487};
17488
Kailang Yang291702f2007-10-16 14:28:03 +020017489static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017490 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17491 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017492
17493 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
17494 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17495 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17496
17497 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17498 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17499 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17500 { } /* end */
17501};
17502
Kailang Yang8c427222008-01-10 13:03:59 +010017503static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017504 ALC262_HIPPO_MASTER_SWITCH,
17505 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017506 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017507 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17508 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017509 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17510 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17511 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17512 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17513 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17514 { } /* end */
17515};
17516
Kailang Yangf1d4e282008-08-26 14:03:29 +020017517static struct hda_bind_ctls alc663_asus_bind_master_vol = {
17518 .ops = &snd_hda_bind_vol,
17519 .values = {
17520 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17521 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17522 0
17523 },
17524};
17525
17526static struct hda_bind_ctls alc663_asus_one_bind_switch = {
17527 .ops = &snd_hda_bind_sw,
17528 .values = {
17529 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17530 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17531 0
17532 },
17533};
17534
Kailang Yang6dda9f42008-05-27 12:05:31 +020017535static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017536 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17537 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17538 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17539 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17540 { } /* end */
17541};
17542
17543static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
17544 .ops = &snd_hda_bind_sw,
17545 .values = {
17546 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17547 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17548 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17549 0
17550 },
17551};
17552
17553static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
17554 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17555 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17556 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17557 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17558 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17559 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17560
17561 { } /* end */
17562};
17563
17564static struct hda_bind_ctls alc663_asus_four_bind_switch = {
17565 .ops = &snd_hda_bind_sw,
17566 .values = {
17567 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17568 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17569 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17570 0
17571 },
17572};
17573
17574static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
17575 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17576 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17577 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17578 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17579 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17580 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17581 { } /* end */
17582};
17583
17584static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017585 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17586 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017587 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17588 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17589 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17590 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17591 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17592 { } /* end */
17593};
17594
17595static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
17596 .ops = &snd_hda_bind_vol,
17597 .values = {
17598 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17599 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17600 0
17601 },
17602};
17603
17604static struct hda_bind_ctls alc663_asus_two_bind_switch = {
17605 .ops = &snd_hda_bind_sw,
17606 .values = {
17607 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17608 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17609 0
17610 },
17611};
17612
17613static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17614 HDA_BIND_VOL("Master Playback Volume",
17615 &alc663_asus_two_bind_master_vol),
17616 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17617 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017618 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17619 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17620 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017621 { } /* end */
17622};
17623
17624static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17625 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17626 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17627 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17628 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17629 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17630 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017631 { } /* end */
17632};
17633
17634static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17635 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17636 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17637 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17638 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17639 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17640
17641 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17642 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17643 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17644 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17645 { } /* end */
17646};
17647
17648static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17649 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17650 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17651 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17652
17653 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17654 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17655 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17656 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17657 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17658 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17659 { } /* end */
17660};
17661
Kailang Yangebb83ee2009-12-17 12:23:00 +010017662static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17663 .ops = &snd_hda_bind_sw,
17664 .values = {
17665 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17666 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17667 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17668 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17669 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17670 0
17671 },
17672};
17673
17674static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17675 .ops = &snd_hda_bind_sw,
17676 .values = {
17677 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17678 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17679 0
17680 },
17681};
17682
17683static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17684 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17685 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17686 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17687 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17688 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17689 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17690 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17691 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17692 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17693 { } /* end */
17694};
17695
17696static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17697 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17698 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17699 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17700 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17701 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17702 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17703 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17704 { } /* end */
17705};
17706
17707
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017708static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17709 {
17710 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17711 .name = "Channel Mode",
17712 .info = alc_ch_mode_info,
17713 .get = alc_ch_mode_get,
17714 .put = alc_ch_mode_put,
17715 },
17716 { } /* end */
17717};
17718
17719static struct hda_verb alc662_init_verbs[] = {
17720 /* ADC: mute amp left and right */
17721 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17722 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017723
Kailang Yangb60dd392007-09-20 12:50:29 +020017724 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17725 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17726 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17727 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17728 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17729 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017730
17731 /* Front Pin: output 0 (0x0c) */
17732 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17733 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17734
17735 /* Rear Pin: output 1 (0x0d) */
17736 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17737 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17738
17739 /* CLFE Pin: output 2 (0x0e) */
17740 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17741 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17742
17743 /* Mic (rear) pin: input vref at 80% */
17744 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17745 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17746 /* Front Mic pin: input vref at 80% */
17747 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17748 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17749 /* Line In pin: input */
17750 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17751 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17752 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17753 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17754 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17755 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17756 /* CD pin widget for input */
17757 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17758
17759 /* FIXME: use matrix-type input source selection */
17760 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17761 /* Input mixer */
17762 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017763 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017764
17765 /* always trun on EAPD */
17766 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17767 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17768
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017769 { }
17770};
17771
Kailang Yangcec27c82010-02-04 14:18:18 +010017772static struct hda_verb alc663_init_verbs[] = {
17773 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17774 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17775 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17776 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17777 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17778 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17779 { }
17780};
17781
17782static struct hda_verb alc272_init_verbs[] = {
17783 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17784 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17785 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17786 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17787 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17788 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17789 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17790 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17791 { }
17792};
17793
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017794static struct hda_verb alc662_sue_init_verbs[] = {
17795 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17796 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017797 {}
17798};
17799
17800static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17801 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17802 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17803 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017804};
17805
Kailang Yang8c427222008-01-10 13:03:59 +010017806/* Set Unsolicited Event*/
17807static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17808 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17809 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17810 {}
17811};
17812
Kailang Yang6dda9f42008-05-27 12:05:31 +020017813static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017814 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17815 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017816 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17817 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017818 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17819 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17820 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017821 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17822 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17823 {}
17824};
17825
Kailang Yangf1d4e282008-08-26 14:03:29 +020017826static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17827 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17828 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17829 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17830 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17831 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17832 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17833 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17834 {}
17835};
17836
17837static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17838 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17839 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17840 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17841 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17842 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17843 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17844 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17845 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17846 {}
17847};
17848
17849static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17850 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17851 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17852 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17853 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17854 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17855 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17856 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17857 {}
17858};
17859
17860static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
17861 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17862 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17863 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17864 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17865 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17866 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17867 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17868 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17869 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17870 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17871 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17872 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17873 {}
17874};
17875
17876static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
17877 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17878 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17879 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17880 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17881 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17882 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17883 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17884 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17885 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17886 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17887 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17888 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17889 {}
17890};
17891
Kailang Yang6dda9f42008-05-27 12:05:31 +020017892static struct hda_verb alc663_g71v_init_verbs[] = {
17893 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17894 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
17895 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
17896
17897 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17898 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17899 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17900
17901 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17902 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
17903 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
17904 {}
17905};
17906
17907static struct hda_verb alc663_g50v_init_verbs[] = {
17908 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17909 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17910 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17911
17912 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17913 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17914 {}
17915};
17916
Kailang Yangf1d4e282008-08-26 14:03:29 +020017917static struct hda_verb alc662_ecs_init_verbs[] = {
17918 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
17919 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17920 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17921 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17922 {}
17923};
17924
Kailang Yang622e84c2009-04-21 07:39:04 +020017925static struct hda_verb alc272_dell_zm1_init_verbs[] = {
17926 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17927 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17928 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17929 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17930 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17931 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17932 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17933 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17934 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17935 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17936 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17937 {}
17938};
17939
17940static struct hda_verb alc272_dell_init_verbs[] = {
17941 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17942 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17943 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17944 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17945 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17946 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17947 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17948 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17949 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17950 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17951 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17952 {}
17953};
17954
Kailang Yangebb83ee2009-12-17 12:23:00 +010017955static struct hda_verb alc663_mode7_init_verbs[] = {
17956 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17957 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17958 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17959 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17960 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17961 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17962 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
17963 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17964 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17965 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17966 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17967 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17968 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17969 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17970 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17971 {}
17972};
17973
17974static struct hda_verb alc663_mode8_init_verbs[] = {
17975 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17976 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17977 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17978 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
17979 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17980 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17981 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17982 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17983 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17984 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17985 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17986 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17987 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17988 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17989 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17990 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17991 {}
17992};
17993
Kailang Yangf1d4e282008-08-26 14:03:29 +020017994static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
17995 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
17996 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
17997 { } /* end */
17998};
17999
Kailang Yang622e84c2009-04-21 07:39:04 +020018000static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
18001 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
18002 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
18003 { } /* end */
18004};
18005
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018006static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
18007{
18008 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018009 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018010
Wu Fengguang864f92b2009-11-18 12:38:02 +080018011 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018012 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018013
Takashi Iwai47fd8302007-08-10 17:11:07 +020018014 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18015 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018016}
18017
18018static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
18019{
18020 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018021 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018022
Wu Fengguang864f92b2009-11-18 12:38:02 +080018023 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018024 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018025
Takashi Iwai47fd8302007-08-10 17:11:07 +020018026 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18027 HDA_AMP_MUTE, bits);
18028 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18029 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018030}
18031
18032static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
18033 unsigned int res)
18034{
18035 if ((res >> 26) == ALC880_HP_EVENT)
18036 alc662_lenovo_101e_all_automute(codec);
18037 if ((res >> 26) == ALC880_FRONT_EVENT)
18038 alc662_lenovo_101e_ispeaker_automute(codec);
18039}
18040
Kailang Yang291702f2007-10-16 14:28:03 +020018041/* unsolicited event for HP jack sensing */
18042static void alc662_eeepc_unsol_event(struct hda_codec *codec,
18043 unsigned int res)
18044{
Kailang Yang291702f2007-10-16 14:28:03 +020018045 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018046 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020018047 else
18048 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020018049}
18050
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018051static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020018052{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018053 struct alc_spec *spec = codec->spec;
18054
18055 alc262_hippo1_setup(codec);
18056 spec->ext_mic.pin = 0x18;
18057 spec->ext_mic.mux_idx = 0;
18058 spec->int_mic.pin = 0x19;
18059 spec->int_mic.mux_idx = 1;
18060 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020018061}
18062
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018063static void alc662_eeepc_inithook(struct hda_codec *codec)
18064{
18065 alc262_hippo_automute(codec);
18066 alc_mic_automute(codec);
18067}
18068
18069static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010018070{
Takashi Iwai42171c12009-05-08 14:11:43 +020018071 struct alc_spec *spec = codec->spec;
18072
18073 spec->autocfg.hp_pins[0] = 0x14;
18074 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010018075}
18076
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018077#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
18078
Kailang Yang6dda9f42008-05-27 12:05:31 +020018079static void alc663_m51va_speaker_automute(struct hda_codec *codec)
18080{
18081 unsigned int present;
18082 unsigned char bits;
18083
Wu Fengguang864f92b2009-11-18 12:38:02 +080018084 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018085 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018086 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018087 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018088 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018089 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018090}
18091
18092static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
18093{
18094 unsigned int present;
18095 unsigned char bits;
18096
Wu Fengguang864f92b2009-11-18 12:38:02 +080018097 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018098 bits = present ? HDA_AMP_MUTE : 0;
18099 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018100 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018101 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018102 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018103 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018104 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018105 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018106 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018107}
18108
18109static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
18110{
18111 unsigned int present;
18112 unsigned char bits;
18113
Wu Fengguang864f92b2009-11-18 12:38:02 +080018114 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018115 bits = present ? HDA_AMP_MUTE : 0;
18116 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018117 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018118 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018119 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018120 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018121 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018122 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018123 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018124}
18125
18126static void alc662_f5z_speaker_automute(struct hda_codec *codec)
18127{
18128 unsigned int present;
18129 unsigned char bits;
18130
Wu Fengguang864f92b2009-11-18 12:38:02 +080018131 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018132 bits = present ? 0 : PIN_OUT;
18133 snd_hda_codec_write(codec, 0x14, 0,
18134 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
18135}
18136
18137static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
18138{
18139 unsigned int present1, present2;
18140
Wu Fengguang864f92b2009-11-18 12:38:02 +080018141 present1 = snd_hda_jack_detect(codec, 0x21);
18142 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018143
18144 if (present1 || present2) {
18145 snd_hda_codec_write_cache(codec, 0x14, 0,
18146 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18147 } else {
18148 snd_hda_codec_write_cache(codec, 0x14, 0,
18149 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18150 }
18151}
18152
18153static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
18154{
18155 unsigned int present1, present2;
18156
Wu Fengguang864f92b2009-11-18 12:38:02 +080018157 present1 = snd_hda_jack_detect(codec, 0x1b);
18158 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018159
18160 if (present1 || present2) {
18161 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018162 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018163 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018164 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018165 } else {
18166 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018167 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018168 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018169 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018170 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020018171}
18172
Kailang Yangebb83ee2009-12-17 12:23:00 +010018173static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
18174{
18175 unsigned int present1, present2;
18176
18177 present1 = snd_hda_codec_read(codec, 0x1b, 0,
18178 AC_VERB_GET_PIN_SENSE, 0)
18179 & AC_PINSENSE_PRESENCE;
18180 present2 = snd_hda_codec_read(codec, 0x21, 0,
18181 AC_VERB_GET_PIN_SENSE, 0)
18182 & AC_PINSENSE_PRESENCE;
18183
18184 if (present1 || present2) {
18185 snd_hda_codec_write_cache(codec, 0x14, 0,
18186 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18187 snd_hda_codec_write_cache(codec, 0x17, 0,
18188 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18189 } else {
18190 snd_hda_codec_write_cache(codec, 0x14, 0,
18191 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18192 snd_hda_codec_write_cache(codec, 0x17, 0,
18193 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18194 }
18195}
18196
18197static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
18198{
18199 unsigned int present1, present2;
18200
18201 present1 = snd_hda_codec_read(codec, 0x21, 0,
18202 AC_VERB_GET_PIN_SENSE, 0)
18203 & AC_PINSENSE_PRESENCE;
18204 present2 = snd_hda_codec_read(codec, 0x15, 0,
18205 AC_VERB_GET_PIN_SENSE, 0)
18206 & AC_PINSENSE_PRESENCE;
18207
18208 if (present1 || present2) {
18209 snd_hda_codec_write_cache(codec, 0x14, 0,
18210 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18211 snd_hda_codec_write_cache(codec, 0x17, 0,
18212 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18213 } else {
18214 snd_hda_codec_write_cache(codec, 0x14, 0,
18215 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18216 snd_hda_codec_write_cache(codec, 0x17, 0,
18217 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18218 }
18219}
18220
Kailang Yang6dda9f42008-05-27 12:05:31 +020018221static void alc663_m51va_unsol_event(struct hda_codec *codec,
18222 unsigned int res)
18223{
18224 switch (res >> 26) {
18225 case ALC880_HP_EVENT:
18226 alc663_m51va_speaker_automute(codec);
18227 break;
18228 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018229 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018230 break;
18231 }
18232}
18233
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018234static void alc663_m51va_setup(struct hda_codec *codec)
18235{
18236 struct alc_spec *spec = codec->spec;
18237 spec->ext_mic.pin = 0x18;
18238 spec->ext_mic.mux_idx = 0;
18239 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018240 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018241 spec->auto_mic = 1;
18242}
18243
Kailang Yang6dda9f42008-05-27 12:05:31 +020018244static void alc663_m51va_inithook(struct hda_codec *codec)
18245{
18246 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018247 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018248}
18249
Kailang Yangf1d4e282008-08-26 14:03:29 +020018250/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018251#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010018252
18253static void alc663_mode1_setup(struct hda_codec *codec)
18254{
18255 struct alc_spec *spec = codec->spec;
18256 spec->ext_mic.pin = 0x18;
18257 spec->ext_mic.mux_idx = 0;
18258 spec->int_mic.pin = 0x19;
18259 spec->int_mic.mux_idx = 1;
18260 spec->auto_mic = 1;
18261}
18262
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018263#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020018264
Kailang Yangf1d4e282008-08-26 14:03:29 +020018265/* ***************** Mode2 ******************************/
18266static void alc662_mode2_unsol_event(struct hda_codec *codec,
18267 unsigned int res)
18268{
18269 switch (res >> 26) {
18270 case ALC880_HP_EVENT:
18271 alc662_f5z_speaker_automute(codec);
18272 break;
18273 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018274 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018275 break;
18276 }
18277}
18278
Kailang Yangebb83ee2009-12-17 12:23:00 +010018279#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018280
Kailang Yangf1d4e282008-08-26 14:03:29 +020018281static void alc662_mode2_inithook(struct hda_codec *codec)
18282{
18283 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018284 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018285}
18286/* ***************** Mode3 ******************************/
18287static void alc663_mode3_unsol_event(struct hda_codec *codec,
18288 unsigned int res)
18289{
18290 switch (res >> 26) {
18291 case ALC880_HP_EVENT:
18292 alc663_two_hp_m1_speaker_automute(codec);
18293 break;
18294 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018295 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018296 break;
18297 }
18298}
18299
Kailang Yangebb83ee2009-12-17 12:23:00 +010018300#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018301
Kailang Yangf1d4e282008-08-26 14:03:29 +020018302static void alc663_mode3_inithook(struct hda_codec *codec)
18303{
18304 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018305 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018306}
18307/* ***************** Mode4 ******************************/
18308static void alc663_mode4_unsol_event(struct hda_codec *codec,
18309 unsigned int res)
18310{
18311 switch (res >> 26) {
18312 case ALC880_HP_EVENT:
18313 alc663_21jd_two_speaker_automute(codec);
18314 break;
18315 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018316 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018317 break;
18318 }
18319}
18320
Kailang Yangebb83ee2009-12-17 12:23:00 +010018321#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018322
Kailang Yangf1d4e282008-08-26 14:03:29 +020018323static void alc663_mode4_inithook(struct hda_codec *codec)
18324{
18325 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018326 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018327}
18328/* ***************** Mode5 ******************************/
18329static void alc663_mode5_unsol_event(struct hda_codec *codec,
18330 unsigned int res)
18331{
18332 switch (res >> 26) {
18333 case ALC880_HP_EVENT:
18334 alc663_15jd_two_speaker_automute(codec);
18335 break;
18336 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018337 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018338 break;
18339 }
18340}
18341
Kailang Yangebb83ee2009-12-17 12:23:00 +010018342#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018343
Kailang Yangf1d4e282008-08-26 14:03:29 +020018344static void alc663_mode5_inithook(struct hda_codec *codec)
18345{
18346 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018347 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018348}
18349/* ***************** Mode6 ******************************/
18350static void alc663_mode6_unsol_event(struct hda_codec *codec,
18351 unsigned int res)
18352{
18353 switch (res >> 26) {
18354 case ALC880_HP_EVENT:
18355 alc663_two_hp_m2_speaker_automute(codec);
18356 break;
18357 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018358 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018359 break;
18360 }
18361}
18362
Kailang Yangebb83ee2009-12-17 12:23:00 +010018363#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018364
Kailang Yangf1d4e282008-08-26 14:03:29 +020018365static void alc663_mode6_inithook(struct hda_codec *codec)
18366{
18367 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018368 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018369}
18370
Kailang Yangebb83ee2009-12-17 12:23:00 +010018371/* ***************** Mode7 ******************************/
18372static void alc663_mode7_unsol_event(struct hda_codec *codec,
18373 unsigned int res)
18374{
18375 switch (res >> 26) {
18376 case ALC880_HP_EVENT:
18377 alc663_two_hp_m7_speaker_automute(codec);
18378 break;
18379 case ALC880_MIC_EVENT:
18380 alc_mic_automute(codec);
18381 break;
18382 }
18383}
18384
18385#define alc663_mode7_setup alc663_mode1_setup
18386
18387static void alc663_mode7_inithook(struct hda_codec *codec)
18388{
18389 alc663_two_hp_m7_speaker_automute(codec);
18390 alc_mic_automute(codec);
18391}
18392
18393/* ***************** Mode8 ******************************/
18394static void alc663_mode8_unsol_event(struct hda_codec *codec,
18395 unsigned int res)
18396{
18397 switch (res >> 26) {
18398 case ALC880_HP_EVENT:
18399 alc663_two_hp_m8_speaker_automute(codec);
18400 break;
18401 case ALC880_MIC_EVENT:
18402 alc_mic_automute(codec);
18403 break;
18404 }
18405}
18406
18407#define alc663_mode8_setup alc663_m51va_setup
18408
18409static void alc663_mode8_inithook(struct hda_codec *codec)
18410{
18411 alc663_two_hp_m8_speaker_automute(codec);
18412 alc_mic_automute(codec);
18413}
18414
Kailang Yang6dda9f42008-05-27 12:05:31 +020018415static void alc663_g71v_hp_automute(struct hda_codec *codec)
18416{
18417 unsigned int present;
18418 unsigned char bits;
18419
Wu Fengguang864f92b2009-11-18 12:38:02 +080018420 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018421 bits = present ? HDA_AMP_MUTE : 0;
18422 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18423 HDA_AMP_MUTE, bits);
18424 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18425 HDA_AMP_MUTE, bits);
18426}
18427
18428static void alc663_g71v_front_automute(struct hda_codec *codec)
18429{
18430 unsigned int present;
18431 unsigned char bits;
18432
Wu Fengguang864f92b2009-11-18 12:38:02 +080018433 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018434 bits = present ? HDA_AMP_MUTE : 0;
18435 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18436 HDA_AMP_MUTE, bits);
18437}
18438
18439static void alc663_g71v_unsol_event(struct hda_codec *codec,
18440 unsigned int res)
18441{
18442 switch (res >> 26) {
18443 case ALC880_HP_EVENT:
18444 alc663_g71v_hp_automute(codec);
18445 break;
18446 case ALC880_FRONT_EVENT:
18447 alc663_g71v_front_automute(codec);
18448 break;
18449 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018450 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018451 break;
18452 }
18453}
18454
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018455#define alc663_g71v_setup alc663_m51va_setup
18456
Kailang Yang6dda9f42008-05-27 12:05:31 +020018457static void alc663_g71v_inithook(struct hda_codec *codec)
18458{
18459 alc663_g71v_front_automute(codec);
18460 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018461 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018462}
18463
18464static void alc663_g50v_unsol_event(struct hda_codec *codec,
18465 unsigned int res)
18466{
18467 switch (res >> 26) {
18468 case ALC880_HP_EVENT:
18469 alc663_m51va_speaker_automute(codec);
18470 break;
18471 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018472 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018473 break;
18474 }
18475}
18476
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018477#define alc663_g50v_setup alc663_m51va_setup
18478
Kailang Yang6dda9f42008-05-27 12:05:31 +020018479static void alc663_g50v_inithook(struct hda_codec *codec)
18480{
18481 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018482 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018483}
18484
Kailang Yangf1d4e282008-08-26 14:03:29 +020018485static struct snd_kcontrol_new alc662_ecs_mixer[] = {
18486 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020018487 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018488
18489 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
18490 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
18491 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
18492
18493 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
18494 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18495 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18496 { } /* end */
18497};
18498
Chris Pockelé9541ba12009-05-12 08:08:53 +020018499static struct snd_kcontrol_new alc272_nc10_mixer[] = {
18500 /* Master Playback automatically created from Speaker and Headphone */
18501 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18502 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18503 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
18504 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
18505
18506 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
18507 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
18508 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
18509
18510 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18511 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18512 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
18513 { } /* end */
18514};
18515
Takashi Iwaicb53c622007-08-10 17:21:45 +020018516#ifdef CONFIG_SND_HDA_POWER_SAVE
18517#define alc662_loopbacks alc880_loopbacks
18518#endif
18519
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018520
Sasha Alexandrdef319f2009-06-16 16:00:15 -040018521/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018522#define alc662_pcm_analog_playback alc880_pcm_analog_playback
18523#define alc662_pcm_analog_capture alc880_pcm_analog_capture
18524#define alc662_pcm_digital_playback alc880_pcm_digital_playback
18525#define alc662_pcm_digital_capture alc880_pcm_digital_capture
18526
18527/*
18528 * configuration and preset
18529 */
18530static const char *alc662_models[ALC662_MODEL_LAST] = {
18531 [ALC662_3ST_2ch_DIG] = "3stack-dig",
18532 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
18533 [ALC662_3ST_6ch] = "3stack-6ch",
18534 [ALC662_5ST_DIG] = "6stack-dig",
18535 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020018536 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010018537 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018538 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020018539 [ALC663_ASUS_M51VA] = "m51va",
18540 [ALC663_ASUS_G71V] = "g71v",
18541 [ALC663_ASUS_H13] = "h13",
18542 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018543 [ALC663_ASUS_MODE1] = "asus-mode1",
18544 [ALC662_ASUS_MODE2] = "asus-mode2",
18545 [ALC663_ASUS_MODE3] = "asus-mode3",
18546 [ALC663_ASUS_MODE4] = "asus-mode4",
18547 [ALC663_ASUS_MODE5] = "asus-mode5",
18548 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010018549 [ALC663_ASUS_MODE7] = "asus-mode7",
18550 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020018551 [ALC272_DELL] = "dell",
18552 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020018553 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018554 [ALC662_AUTO] = "auto",
18555};
18556
18557static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010018558 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020018559 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18560 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018561 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
18562 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010018563 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018564 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
18565 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
18566 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
18567 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018568 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
18569 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018570 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018571 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
18572 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
18573 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
18574 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
18575 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018576 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018577 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
18578 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018579 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
18580 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
18581 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
18582 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018583 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018584 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
18585 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
18586 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018587 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
18588 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
18589 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
18590 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018591 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018592 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
18593 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020018594 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018595 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
18596 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
18597 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018598 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010018599 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018600 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
18601 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018602 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
18603 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
18604 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018605 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018606 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
18607 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018608 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018609 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018610 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018611 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18612 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18613 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018614 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018615 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18616 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018617 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018618 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018619 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018620 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018621 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18622 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018623 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018624 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030018625 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
18626 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018627 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018628 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018629 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018630 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018631 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018632 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018633 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18634 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018635 {}
18636};
18637
18638static struct alc_config_preset alc662_presets[] = {
18639 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018640 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018641 .init_verbs = { alc662_init_verbs },
18642 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18643 .dac_nids = alc662_dac_nids,
18644 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018645 .dig_in_nid = ALC662_DIGIN_NID,
18646 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18647 .channel_mode = alc662_3ST_2ch_modes,
18648 .input_mux = &alc662_capture_source,
18649 },
18650 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018651 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018652 .init_verbs = { alc662_init_verbs },
18653 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18654 .dac_nids = alc662_dac_nids,
18655 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018656 .dig_in_nid = ALC662_DIGIN_NID,
18657 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18658 .channel_mode = alc662_3ST_6ch_modes,
18659 .need_dac_fix = 1,
18660 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018661 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018662 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018663 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018664 .init_verbs = { alc662_init_verbs },
18665 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18666 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018667 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18668 .channel_mode = alc662_3ST_6ch_modes,
18669 .need_dac_fix = 1,
18670 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018671 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018672 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018673 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018674 .init_verbs = { alc662_init_verbs },
18675 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18676 .dac_nids = alc662_dac_nids,
18677 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018678 .dig_in_nid = ALC662_DIGIN_NID,
18679 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18680 .channel_mode = alc662_5stack_modes,
18681 .input_mux = &alc662_capture_source,
18682 },
18683 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018684 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018685 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
18686 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18687 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018688 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18689 .channel_mode = alc662_3ST_2ch_modes,
18690 .input_mux = &alc662_lenovo_101e_capture_source,
18691 .unsol_event = alc662_lenovo_101e_unsol_event,
18692 .init_hook = alc662_lenovo_101e_all_automute,
18693 },
Kailang Yang291702f2007-10-16 14:28:03 +020018694 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018695 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018696 .init_verbs = { alc662_init_verbs,
18697 alc662_eeepc_sue_init_verbs },
18698 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18699 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018700 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18701 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020018702 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018703 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020018704 .init_hook = alc662_eeepc_inithook,
18705 },
Kailang Yang8c427222008-01-10 13:03:59 +010018706 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018707 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018708 alc662_chmode_mixer },
18709 .init_verbs = { alc662_init_verbs,
18710 alc662_eeepc_ep20_sue_init_verbs },
18711 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18712 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018713 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18714 .channel_mode = alc662_3ST_6ch_modes,
18715 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020018716 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018717 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010018718 .init_hook = alc662_eeepc_ep20_inithook,
18719 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018720 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018721 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018722 .init_verbs = { alc662_init_verbs,
18723 alc662_ecs_init_verbs },
18724 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18725 .dac_nids = alc662_dac_nids,
18726 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18727 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018728 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018729 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018730 .init_hook = alc662_eeepc_inithook,
18731 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018732 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018733 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018734 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18735 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18736 .dac_nids = alc662_dac_nids,
18737 .dig_out_nid = ALC662_DIGOUT_NID,
18738 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18739 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018740 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018741 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018742 .init_hook = alc663_m51va_inithook,
18743 },
18744 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018745 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018746 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
18747 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18748 .dac_nids = alc662_dac_nids,
18749 .dig_out_nid = ALC662_DIGOUT_NID,
18750 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18751 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018752 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018753 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018754 .init_hook = alc663_g71v_inithook,
18755 },
18756 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018757 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018758 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18759 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18760 .dac_nids = alc662_dac_nids,
18761 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18762 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018763 .unsol_event = alc663_m51va_unsol_event,
18764 .init_hook = alc663_m51va_inithook,
18765 },
18766 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018767 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018768 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
18769 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18770 .dac_nids = alc662_dac_nids,
18771 .dig_out_nid = ALC662_DIGOUT_NID,
18772 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18773 .channel_mode = alc662_3ST_6ch_modes,
18774 .input_mux = &alc663_capture_source,
18775 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018776 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018777 .init_hook = alc663_g50v_inithook,
18778 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018779 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018780 .mixers = { alc663_m51va_mixer },
18781 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018782 .init_verbs = { alc662_init_verbs,
18783 alc663_21jd_amic_init_verbs },
18784 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18785 .hp_nid = 0x03,
18786 .dac_nids = alc662_dac_nids,
18787 .dig_out_nid = ALC662_DIGOUT_NID,
18788 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18789 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018790 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018791 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018792 .init_hook = alc663_mode1_inithook,
18793 },
18794 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018795 .mixers = { alc662_1bjd_mixer },
18796 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018797 .init_verbs = { alc662_init_verbs,
18798 alc662_1bjd_amic_init_verbs },
18799 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18800 .dac_nids = alc662_dac_nids,
18801 .dig_out_nid = ALC662_DIGOUT_NID,
18802 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18803 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018804 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018805 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018806 .init_hook = alc662_mode2_inithook,
18807 },
18808 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018809 .mixers = { alc663_two_hp_m1_mixer },
18810 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018811 .init_verbs = { alc662_init_verbs,
18812 alc663_two_hp_amic_m1_init_verbs },
18813 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18814 .hp_nid = 0x03,
18815 .dac_nids = alc662_dac_nids,
18816 .dig_out_nid = ALC662_DIGOUT_NID,
18817 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18818 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018819 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018820 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018821 .init_hook = alc663_mode3_inithook,
18822 },
18823 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018824 .mixers = { alc663_asus_21jd_clfe_mixer },
18825 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018826 .init_verbs = { alc662_init_verbs,
18827 alc663_21jd_amic_init_verbs},
18828 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18829 .hp_nid = 0x03,
18830 .dac_nids = alc662_dac_nids,
18831 .dig_out_nid = ALC662_DIGOUT_NID,
18832 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18833 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018834 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018835 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018836 .init_hook = alc663_mode4_inithook,
18837 },
18838 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018839 .mixers = { alc663_asus_15jd_clfe_mixer },
18840 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018841 .init_verbs = { alc662_init_verbs,
18842 alc663_15jd_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_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018850 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018851 .init_hook = alc663_mode5_inithook,
18852 },
18853 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018854 .mixers = { alc663_two_hp_m2_mixer },
18855 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018856 .init_verbs = { alc662_init_verbs,
18857 alc663_two_hp_amic_m2_init_verbs },
18858 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18859 .hp_nid = 0x03,
18860 .dac_nids = alc662_dac_nids,
18861 .dig_out_nid = ALC662_DIGOUT_NID,
18862 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18863 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018864 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018865 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018866 .init_hook = alc663_mode6_inithook,
18867 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018868 [ALC663_ASUS_MODE7] = {
18869 .mixers = { alc663_mode7_mixer },
18870 .cap_mixer = alc662_auto_capture_mixer,
18871 .init_verbs = { alc662_init_verbs,
18872 alc663_mode7_init_verbs },
18873 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18874 .hp_nid = 0x03,
18875 .dac_nids = alc662_dac_nids,
18876 .dig_out_nid = ALC662_DIGOUT_NID,
18877 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18878 .channel_mode = alc662_3ST_2ch_modes,
18879 .unsol_event = alc663_mode7_unsol_event,
18880 .setup = alc663_mode7_setup,
18881 .init_hook = alc663_mode7_inithook,
18882 },
18883 [ALC663_ASUS_MODE8] = {
18884 .mixers = { alc663_mode8_mixer },
18885 .cap_mixer = alc662_auto_capture_mixer,
18886 .init_verbs = { alc662_init_verbs,
18887 alc663_mode8_init_verbs },
18888 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18889 .hp_nid = 0x03,
18890 .dac_nids = alc662_dac_nids,
18891 .dig_out_nid = ALC662_DIGOUT_NID,
18892 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18893 .channel_mode = alc662_3ST_2ch_modes,
18894 .unsol_event = alc663_mode8_unsol_event,
18895 .setup = alc663_mode8_setup,
18896 .init_hook = alc663_mode8_inithook,
18897 },
Kailang Yang622e84c2009-04-21 07:39:04 +020018898 [ALC272_DELL] = {
18899 .mixers = { alc663_m51va_mixer },
18900 .cap_mixer = alc272_auto_capture_mixer,
18901 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
18902 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18903 .dac_nids = alc662_dac_nids,
18904 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18905 .adc_nids = alc272_adc_nids,
18906 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
18907 .capsrc_nids = alc272_capsrc_nids,
18908 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018909 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018910 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018911 .init_hook = alc663_m51va_inithook,
18912 },
18913 [ALC272_DELL_ZM1] = {
18914 .mixers = { alc663_m51va_mixer },
18915 .cap_mixer = alc662_auto_capture_mixer,
18916 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
18917 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18918 .dac_nids = alc662_dac_nids,
18919 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18920 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018921 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020018922 .capsrc_nids = alc662_capsrc_nids,
18923 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018924 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018925 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018926 .init_hook = alc663_m51va_inithook,
18927 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020018928 [ALC272_SAMSUNG_NC10] = {
18929 .mixers = { alc272_nc10_mixer },
18930 .init_verbs = { alc662_init_verbs,
18931 alc663_21jd_amic_init_verbs },
18932 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18933 .dac_nids = alc272_dac_nids,
18934 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18935 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018936 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020018937 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018938 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018939 .init_hook = alc663_mode4_inithook,
18940 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018941};
18942
18943
18944/*
18945 * BIOS auto configuration
18946 */
18947
Takashi Iwai7085ec12009-10-02 09:03:58 +020018948/* convert from MIX nid to DAC */
18949static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
18950{
18951 if (nid == 0x0f)
18952 return 0x02;
18953 else if (nid >= 0x0c && nid <= 0x0e)
18954 return nid - 0x0c + 0x02;
18955 else
18956 return 0;
18957}
18958
18959/* get MIX nid connected to the given pin targeted to DAC */
18960static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
18961 hda_nid_t dac)
18962{
18963 hda_nid_t mix[4];
18964 int i, num;
18965
18966 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
18967 for (i = 0; i < num; i++) {
18968 if (alc662_mix_to_dac(mix[i]) == dac)
18969 return mix[i];
18970 }
18971 return 0;
18972}
18973
18974/* look for an empty DAC slot */
18975static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
18976{
18977 struct alc_spec *spec = codec->spec;
18978 hda_nid_t srcs[5];
18979 int i, j, num;
18980
18981 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
18982 if (num < 0)
18983 return 0;
18984 for (i = 0; i < num; i++) {
18985 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
18986 if (!nid)
18987 continue;
18988 for (j = 0; j < spec->multiout.num_dacs; j++)
18989 if (spec->multiout.dac_nids[j] == nid)
18990 break;
18991 if (j >= spec->multiout.num_dacs)
18992 return nid;
18993 }
18994 return 0;
18995}
18996
18997/* fill in the dac_nids table from the parsed pin configuration */
18998static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
18999 const struct auto_pin_cfg *cfg)
19000{
19001 struct alc_spec *spec = codec->spec;
19002 int i;
19003 hda_nid_t dac;
19004
19005 spec->multiout.dac_nids = spec->private_dac_nids;
19006 for (i = 0; i < cfg->line_outs; i++) {
19007 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
19008 if (!dac)
19009 continue;
19010 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19011 }
19012 return 0;
19013}
19014
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019015static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019016 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019017{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019018 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019019 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
19020}
19021
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019022static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019023 hda_nid_t nid, unsigned int chs)
19024{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019025 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019026 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
19027}
19028
19029#define alc662_add_stereo_vol(spec, pfx, nid) \
19030 alc662_add_vol_ctl(spec, pfx, nid, 3)
19031#define alc662_add_stereo_sw(spec, pfx, nid) \
19032 alc662_add_sw_ctl(spec, pfx, nid, 3)
19033
19034/* add playback controls from the parsed DAC table */
19035static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
19036 const struct auto_pin_cfg *cfg)
19037{
19038 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019039 static const char *chname[4] = {
19040 "Front", "Surround", NULL /*CLFE*/, "Side"
19041 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020019042 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019043 int i, err;
19044
19045 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019046 nid = spec->multiout.dac_nids[i];
19047 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019048 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019049 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
19050 if (!mix)
19051 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019052 if (i == 2) {
19053 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019054 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019055 if (err < 0)
19056 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019057 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019058 if (err < 0)
19059 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019060 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019061 if (err < 0)
19062 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019063 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019064 if (err < 0)
19065 return err;
19066 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020019067 const char *pfx;
19068 if (cfg->line_outs == 1 &&
19069 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019070 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020019071 pfx = "Speaker";
19072 else
19073 pfx = "PCM";
19074 } else
19075 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019076 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019077 if (err < 0)
19078 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020019079 if (cfg->line_outs == 1 &&
19080 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19081 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020019082 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019083 if (err < 0)
19084 return err;
19085 }
19086 }
19087 return 0;
19088}
19089
19090/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019091/* return DAC nid if any new DAC is assigned */
19092static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019093 const char *pfx)
19094{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019095 struct alc_spec *spec = codec->spec;
19096 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019097 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019098
19099 if (!pin)
19100 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019101 nid = alc662_look_for_dac(codec, pin);
19102 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019103 /* the corresponding DAC is already occupied */
19104 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
19105 return 0; /* no way */
19106 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019107 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019108 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
19109 }
19110
19111 mix = alc662_dac_to_mix(codec, pin, nid);
19112 if (!mix)
19113 return 0;
19114 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
19115 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020019116 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019117 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
19118 if (err < 0)
19119 return err;
19120 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019121}
19122
19123/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020019124#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020019125 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019126
19127static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
19128 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019129 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019130{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019131 int i, num;
Takashi Iwaice503f32010-07-30 10:37:29 +020019132 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019133
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019134 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019135 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019136 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
19137 if (num <= 1)
19138 return;
19139 for (i = 0; i < num; i++) {
19140 if (alc662_mix_to_dac(srcs[i]) != dac)
19141 continue;
19142 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
19143 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019144 }
19145}
19146
19147static void alc662_auto_init_multi_out(struct hda_codec *codec)
19148{
19149 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019150 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019151 int i;
19152
19153 for (i = 0; i <= HDA_SIDE; i++) {
19154 hda_nid_t nid = spec->autocfg.line_out_pins[i];
19155 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020019156 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019157 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019158 }
19159}
19160
19161static void alc662_auto_init_hp_out(struct hda_codec *codec)
19162{
19163 struct alc_spec *spec = codec->spec;
19164 hda_nid_t pin;
19165
19166 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019167 if (pin)
19168 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
19169 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019170 pin = spec->autocfg.speaker_pins[0];
19171 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019172 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
19173 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019174}
19175
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019176#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
19177
19178static void alc662_auto_init_analog_input(struct hda_codec *codec)
19179{
19180 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019181 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019182 int i;
19183
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019184 for (i = 0; i < cfg->num_inputs; i++) {
19185 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019186 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020019187 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010019188 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010019189 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019190 snd_hda_codec_write(codec, nid, 0,
19191 AC_VERB_SET_AMP_GAIN_MUTE,
19192 AMP_OUT_MUTE);
19193 }
19194 }
19195}
19196
Takashi Iwaif511b012008-08-15 16:46:42 +020019197#define alc662_auto_init_input_src alc882_auto_init_input_src
19198
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019199static int alc662_parse_auto_config(struct hda_codec *codec)
19200{
19201 struct alc_spec *spec = codec->spec;
19202 int err;
19203 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
19204
19205 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19206 alc662_ignore);
19207 if (err < 0)
19208 return err;
19209 if (!spec->autocfg.line_outs)
19210 return 0; /* can't find valid BIOS pin config */
19211
Takashi Iwai7085ec12009-10-02 09:03:58 +020019212 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019213 if (err < 0)
19214 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019215 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019216 if (err < 0)
19217 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019218 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019219 spec->autocfg.speaker_pins[0],
19220 "Speaker");
19221 if (err < 0)
19222 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019223 if (err)
19224 spec->multiout.extra_out_nid[0] = err;
19225 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019226 "Headphone");
19227 if (err < 0)
19228 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019229 if (err)
19230 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019231 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019232 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019233 return err;
19234
19235 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
19236
Takashi Iwai757899a2010-07-30 10:48:14 +020019237 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019238
Takashi Iwai603c4012008-07-30 15:01:44 +020019239 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010019240 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019241
19242 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020019243 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020019244
Kailang Yangcec27c82010-02-04 14:18:18 +010019245 add_verb(spec, alc662_init_verbs);
19246 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019247 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
Kailang Yangcec27c82010-02-04 14:18:18 +010019248 add_verb(spec, alc663_init_verbs);
19249
19250 if (codec->vendor_id == 0x10ec0272)
19251 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020019252
19253 err = alc_auto_add_mic_boost(codec);
19254 if (err < 0)
19255 return err;
19256
Kailang Yang6227cdc2010-02-25 08:36:52 +010019257 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
19258 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
19259 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
19260 else
19261 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020019262
Takashi Iwai8c872862007-06-19 12:11:16 +020019263 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019264}
19265
19266/* additional initialization for auto-configuration model */
19267static void alc662_auto_init(struct hda_codec *codec)
19268{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019269 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019270 alc662_auto_init_multi_out(codec);
19271 alc662_auto_init_hp_out(codec);
19272 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020019273 alc662_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019274 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019275 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020019276 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019277}
19278
David Henningsson6cb3b702010-09-09 08:51:44 +020019279enum {
Daniel T Chen2df03512010-10-10 22:39:28 -040019280 ALC662_FIXUP_ASPIRE,
David Henningsson6cb3b702010-09-09 08:51:44 +020019281 ALC662_FIXUP_IDEAPAD,
19282};
19283
19284static const struct alc_fixup alc662_fixups[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -040019285 [ALC662_FIXUP_ASPIRE] = {
19286 .pins = (const struct alc_pincfg[]) {
19287 { 0x15, 0x99130112 }, /* subwoofer */
19288 { }
19289 }
19290 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019291 [ALC662_FIXUP_IDEAPAD] = {
19292 .pins = (const struct alc_pincfg[]) {
19293 { 0x17, 0x99130112 }, /* subwoofer */
19294 { }
19295 }
19296 },
19297};
19298
19299static struct snd_pci_quirk alc662_fixup_tbl[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -040019300 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
Daniel T Chena0e90ac2010-11-20 10:20:35 -050019301 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
Valentine Sinitsynd4118582010-10-01 22:24:08 +060019302 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
David Henningsson6cb3b702010-09-09 08:51:44 +020019303 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
19304 {}
19305};
19306
19307
19308
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019309static int patch_alc662(struct hda_codec *codec)
19310{
19311 struct alc_spec *spec;
19312 int err, board_config;
Kailang Yang693194f2010-10-21 08:51:48 +020019313 int coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019314
19315 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19316 if (!spec)
19317 return -ENOMEM;
19318
19319 codec->spec = spec;
19320
Kailang Yangda00c242010-03-19 11:23:45 +010019321 alc_auto_parse_customize_define(codec);
19322
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020019323 alc_fix_pll_init(codec, 0x20, 0x04, 15);
19324
Kailang Yang693194f2010-10-21 08:51:48 +020019325 coef = alc_read_coef_idx(codec, 0);
19326 if (coef == 0x8020 || coef == 0x8011)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019327 alc_codec_rename(codec, "ALC661");
Kailang Yang693194f2010-10-21 08:51:48 +020019328 else if (coef & (1 << 14) &&
19329 codec->bus->pci->subsystem_vendor == 0x1025 &&
19330 spec->cdefine.platform_type == 1)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019331 alc_codec_rename(codec, "ALC272X");
Kailang Yang693194f2010-10-21 08:51:48 +020019332 else if (coef == 0x4011)
19333 alc_codec_rename(codec, "ALC656");
Kailang Yang274693f2009-12-03 10:07:50 +010019334
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019335 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
19336 alc662_models,
19337 alc662_cfg_tbl);
19338 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020019339 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19340 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019341 board_config = ALC662_AUTO;
19342 }
19343
19344 if (board_config == ALC662_AUTO) {
David Henningsson6cb3b702010-09-09 08:51:44 +020019345 alc_pick_fixup(codec, alc662_fixup_tbl, alc662_fixups, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019346 /* automatic parse from the BIOS config */
19347 err = alc662_parse_auto_config(codec);
19348 if (err < 0) {
19349 alc_free(codec);
19350 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020019351 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019352 printk(KERN_INFO
19353 "hda_codec: Cannot set up configuration "
19354 "from BIOS. Using base mode...\n");
19355 board_config = ALC662_3ST_2ch_DIG;
19356 }
19357 }
19358
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019359 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020019360 err = snd_hda_attach_beep_device(codec, 0x1);
19361 if (err < 0) {
19362 alc_free(codec);
19363 return err;
19364 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090019365 }
19366
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019367 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020019368 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019369
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019370 spec->stream_analog_playback = &alc662_pcm_analog_playback;
19371 spec->stream_analog_capture = &alc662_pcm_analog_capture;
19372
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019373 spec->stream_digital_playback = &alc662_pcm_digital_playback;
19374 spec->stream_digital_capture = &alc662_pcm_digital_capture;
19375
Takashi Iwaidd704692009-08-11 08:45:11 +020019376 if (!spec->adc_nids) {
19377 spec->adc_nids = alc662_adc_nids;
19378 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
19379 }
19380 if (!spec->capsrc_nids)
19381 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019382
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019383 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019384 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019385
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019386 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010019387 switch (codec->vendor_id) {
19388 case 0x10ec0662:
19389 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
19390 break;
19391 case 0x10ec0272:
19392 case 0x10ec0663:
19393 case 0x10ec0665:
19394 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
19395 break;
19396 case 0x10ec0273:
19397 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
19398 break;
19399 }
Kailang Yangcec27c82010-02-04 14:18:18 +010019400 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010019401 spec->vmaster_nid = 0x02;
19402
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019403 codec->patch_ops = alc_patch_ops;
David Henningsson6cb3b702010-09-09 08:51:44 +020019404 if (board_config == ALC662_AUTO) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019405 spec->init_hook = alc662_auto_init;
David Henningsson6cb3b702010-09-09 08:51:44 +020019406 alc_pick_fixup(codec, alc662_fixup_tbl, alc662_fixups, 0);
19407 }
19408
Kailang Yangbf1b0222010-10-21 08:49:56 +020019409 alc_init_jacks(codec);
19410
Takashi Iwaicb53c622007-08-10 17:21:45 +020019411#ifdef CONFIG_SND_HDA_POWER_SAVE
19412 if (!spec->loopback.amplist)
19413 spec->loopback.amplist = alc662_loopbacks;
19414#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019415
19416 return 0;
19417}
19418
Kailang Yang274693f2009-12-03 10:07:50 +010019419static int patch_alc888(struct hda_codec *codec)
19420{
19421 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19422 kfree(codec->chip_name);
19423 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019424 if (!codec->chip_name) {
19425 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019426 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019427 }
19428 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019429 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019430 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019431}
19432
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019433/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019434 * ALC680 support
19435 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019436#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019437#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19438#define alc680_modes alc260_modes
19439
19440static hda_nid_t alc680_dac_nids[3] = {
19441 /* Lout1, Lout2, hp */
19442 0x02, 0x03, 0x04
19443};
19444
19445static hda_nid_t alc680_adc_nids[3] = {
19446 /* ADC0-2 */
19447 /* DMIC, MIC, Line-in*/
19448 0x07, 0x08, 0x09
19449};
19450
Kailang Yangc69aefa2010-08-17 10:39:22 +020019451/*
19452 * Analog capture ADC cgange
19453 */
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019454static void alc680_rec_autoswitch(struct hda_codec *codec)
19455{
19456 struct alc_spec *spec = codec->spec;
19457 struct auto_pin_cfg *cfg = &spec->autocfg;
19458 int pin_found = 0;
19459 int type_found = AUTO_PIN_LAST;
19460 hda_nid_t nid;
19461 int i;
19462
19463 for (i = 0; i < cfg->num_inputs; i++) {
19464 nid = cfg->inputs[i].pin;
19465 if (!(snd_hda_query_pin_caps(codec, nid) &
19466 AC_PINCAP_PRES_DETECT))
19467 continue;
19468 if (snd_hda_jack_detect(codec, nid)) {
19469 if (cfg->inputs[i].type < type_found) {
19470 type_found = cfg->inputs[i].type;
19471 pin_found = nid;
19472 }
19473 }
19474 }
19475
19476 nid = 0x07;
19477 if (pin_found)
19478 snd_hda_get_connections(codec, pin_found, &nid, 1);
19479
19480 if (nid != spec->cur_adc)
19481 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
19482 spec->cur_adc = nid;
19483 snd_hda_codec_setup_stream(codec, nid, spec->cur_adc_stream_tag, 0,
19484 spec->cur_adc_format);
19485}
19486
Kailang Yangc69aefa2010-08-17 10:39:22 +020019487static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19488 struct hda_codec *codec,
19489 unsigned int stream_tag,
19490 unsigned int format,
19491 struct snd_pcm_substream *substream)
19492{
19493 struct alc_spec *spec = codec->spec;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019494
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019495 spec->cur_adc = 0x07;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019496 spec->cur_adc_stream_tag = stream_tag;
19497 spec->cur_adc_format = format;
19498
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019499 alc680_rec_autoswitch(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019500 return 0;
19501}
19502
19503static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19504 struct hda_codec *codec,
19505 struct snd_pcm_substream *substream)
19506{
19507 snd_hda_codec_cleanup_stream(codec, 0x07);
19508 snd_hda_codec_cleanup_stream(codec, 0x08);
19509 snd_hda_codec_cleanup_stream(codec, 0x09);
19510 return 0;
19511}
19512
19513static struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
19514 .substreams = 1, /* can be overridden */
19515 .channels_min = 2,
19516 .channels_max = 2,
19517 /* NID is set in alc_build_pcms */
19518 .ops = {
19519 .prepare = alc680_capture_pcm_prepare,
19520 .cleanup = alc680_capture_pcm_cleanup
19521 },
19522};
19523
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019524static struct snd_kcontrol_new alc680_base_mixer[] = {
19525 /* output mixer control */
19526 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19527 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19528 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19529 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019530 HDA_CODEC_VOLUME("Int Mic Boost", 0x12, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019531 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019532 HDA_CODEC_VOLUME("Line In Boost", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019533 { }
19534};
19535
Kailang Yangc69aefa2010-08-17 10:39:22 +020019536static struct hda_bind_ctls alc680_bind_cap_vol = {
19537 .ops = &snd_hda_bind_vol,
19538 .values = {
19539 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19540 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19541 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19542 0
19543 },
19544};
19545
19546static struct hda_bind_ctls alc680_bind_cap_switch = {
19547 .ops = &snd_hda_bind_sw,
19548 .values = {
19549 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19550 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19551 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19552 0
19553 },
19554};
19555
19556static struct snd_kcontrol_new alc680_master_capture_mixer[] = {
19557 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19558 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019559 { } /* end */
19560};
19561
19562/*
19563 * generic initialization of ADC, input mixers and output mixers
19564 */
19565static struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019566 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19567 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19568 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019569
Kailang Yangc69aefa2010-08-17 10:39:22 +020019570 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19571 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19572 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19573 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19574 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19575 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019576
19577 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19578 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19579 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19580 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19581 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019582
19583 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19584 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019585 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019586
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019587 { }
19588};
19589
Kailang Yangc69aefa2010-08-17 10:39:22 +020019590/* toggle speaker-output according to the hp-jack state */
19591static void alc680_base_setup(struct hda_codec *codec)
19592{
19593 struct alc_spec *spec = codec->spec;
19594
19595 spec->autocfg.hp_pins[0] = 0x16;
19596 spec->autocfg.speaker_pins[0] = 0x14;
19597 spec->autocfg.speaker_pins[1] = 0x15;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019598 spec->autocfg.num_inputs = 2;
19599 spec->autocfg.inputs[0].pin = 0x18;
19600 spec->autocfg.inputs[0].type = AUTO_PIN_MIC;
19601 spec->autocfg.inputs[1].pin = 0x19;
Takashi Iwai86e29592010-09-09 14:50:17 +020019602 spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019603}
19604
19605static void alc680_unsol_event(struct hda_codec *codec,
19606 unsigned int res)
19607{
19608 if ((res >> 26) == ALC880_HP_EVENT)
19609 alc_automute_amp(codec);
19610 if ((res >> 26) == ALC880_MIC_EVENT)
19611 alc680_rec_autoswitch(codec);
19612}
19613
19614static void alc680_inithook(struct hda_codec *codec)
19615{
19616 alc_automute_amp(codec);
19617 alc680_rec_autoswitch(codec);
19618}
19619
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019620/* create input playback/capture controls for the given pin */
19621static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19622 const char *ctlname, int idx)
19623{
19624 hda_nid_t dac;
19625 int err;
19626
19627 switch (nid) {
19628 case 0x14:
19629 dac = 0x02;
19630 break;
19631 case 0x15:
19632 dac = 0x03;
19633 break;
19634 case 0x16:
19635 dac = 0x04;
19636 break;
19637 default:
19638 return 0;
19639 }
19640 if (spec->multiout.dac_nids[0] != dac &&
19641 spec->multiout.dac_nids[1] != dac) {
19642 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19643 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19644 HDA_OUTPUT));
19645 if (err < 0)
19646 return err;
19647
19648 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19649 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19650
19651 if (err < 0)
19652 return err;
19653 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19654 }
19655
19656 return 0;
19657}
19658
19659/* add playback controls from the parsed DAC table */
19660static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19661 const struct auto_pin_cfg *cfg)
19662{
19663 hda_nid_t nid;
19664 int err;
19665
19666 spec->multiout.dac_nids = spec->private_dac_nids;
19667
19668 nid = cfg->line_out_pins[0];
19669 if (nid) {
19670 const char *name;
19671 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19672 name = "Speaker";
19673 else
19674 name = "Front";
19675 err = alc680_new_analog_output(spec, nid, name, 0);
19676 if (err < 0)
19677 return err;
19678 }
19679
19680 nid = cfg->speaker_pins[0];
19681 if (nid) {
19682 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19683 if (err < 0)
19684 return err;
19685 }
19686 nid = cfg->hp_pins[0];
19687 if (nid) {
19688 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19689 if (err < 0)
19690 return err;
19691 }
19692
19693 return 0;
19694}
19695
19696static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19697 hda_nid_t nid, int pin_type)
19698{
19699 alc_set_pin_output(codec, nid, pin_type);
19700}
19701
19702static void alc680_auto_init_multi_out(struct hda_codec *codec)
19703{
19704 struct alc_spec *spec = codec->spec;
19705 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19706 if (nid) {
19707 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19708 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19709 }
19710}
19711
19712static void alc680_auto_init_hp_out(struct hda_codec *codec)
19713{
19714 struct alc_spec *spec = codec->spec;
19715 hda_nid_t pin;
19716
19717 pin = spec->autocfg.hp_pins[0];
19718 if (pin)
19719 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
19720 pin = spec->autocfg.speaker_pins[0];
19721 if (pin)
19722 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
19723}
19724
19725/* pcm configuration: identical with ALC880 */
19726#define alc680_pcm_analog_playback alc880_pcm_analog_playback
19727#define alc680_pcm_analog_capture alc880_pcm_analog_capture
19728#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
19729#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020019730#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019731
19732/*
19733 * BIOS auto configuration
19734 */
19735static int alc680_parse_auto_config(struct hda_codec *codec)
19736{
19737 struct alc_spec *spec = codec->spec;
19738 int err;
19739 static hda_nid_t alc680_ignore[] = { 0 };
19740
19741 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19742 alc680_ignore);
19743 if (err < 0)
19744 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019745
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019746 if (!spec->autocfg.line_outs) {
19747 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
19748 spec->multiout.max_channels = 2;
19749 spec->no_analog = 1;
19750 goto dig_only;
19751 }
19752 return 0; /* can't find valid BIOS pin config */
19753 }
19754 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
19755 if (err < 0)
19756 return err;
19757
19758 spec->multiout.max_channels = 2;
19759
19760 dig_only:
19761 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020019762 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019763 if (spec->kctls.list)
19764 add_mixer(spec, spec->kctls.list);
19765
19766 add_verb(spec, alc680_init_verbs);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019767
19768 err = alc_auto_add_mic_boost(codec);
19769 if (err < 0)
19770 return err;
19771
19772 return 1;
19773}
19774
19775#define alc680_auto_init_analog_input alc882_auto_init_analog_input
19776
19777/* init callback for auto-configuration model -- overriding the default init */
19778static void alc680_auto_init(struct hda_codec *codec)
19779{
19780 struct alc_spec *spec = codec->spec;
19781 alc680_auto_init_multi_out(codec);
19782 alc680_auto_init_hp_out(codec);
19783 alc680_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019784 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019785 if (spec->unsol_event)
19786 alc_inithook(codec);
19787}
19788
19789/*
19790 * configuration and preset
19791 */
19792static const char *alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020019793 [ALC680_BASE] = "base",
19794 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019795};
19796
19797static struct snd_pci_quirk alc680_cfg_tbl[] = {
19798 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
19799 {}
19800};
19801
19802static struct alc_config_preset alc680_presets[] = {
19803 [ALC680_BASE] = {
19804 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020019805 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019806 .init_verbs = { alc680_init_verbs },
19807 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
19808 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019809 .dig_out_nid = ALC680_DIGOUT_NID,
19810 .num_channel_mode = ARRAY_SIZE(alc680_modes),
19811 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020019812 .unsol_event = alc680_unsol_event,
19813 .setup = alc680_base_setup,
19814 .init_hook = alc680_inithook,
19815
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019816 },
19817};
19818
19819static int patch_alc680(struct hda_codec *codec)
19820{
19821 struct alc_spec *spec;
19822 int board_config;
19823 int err;
19824
19825 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19826 if (spec == NULL)
19827 return -ENOMEM;
19828
19829 codec->spec = spec;
19830
19831 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
19832 alc680_models,
19833 alc680_cfg_tbl);
19834
19835 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
19836 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19837 codec->chip_name);
19838 board_config = ALC680_AUTO;
19839 }
19840
19841 if (board_config == ALC680_AUTO) {
19842 /* automatic parse from the BIOS config */
19843 err = alc680_parse_auto_config(codec);
19844 if (err < 0) {
19845 alc_free(codec);
19846 return err;
19847 } else if (!err) {
19848 printk(KERN_INFO
19849 "hda_codec: Cannot set up configuration "
19850 "from BIOS. Using base mode...\n");
19851 board_config = ALC680_BASE;
19852 }
19853 }
19854
19855 if (board_config != ALC680_AUTO)
19856 setup_preset(codec, &alc680_presets[board_config]);
19857
19858 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019859 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019860 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019861 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019862
19863 if (!spec->adc_nids) {
19864 spec->adc_nids = alc680_adc_nids;
19865 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids);
19866 }
19867
19868 if (!spec->cap_mixer)
19869 set_capture_mixer(codec);
19870
19871 spec->vmaster_nid = 0x02;
19872
19873 codec->patch_ops = alc_patch_ops;
19874 if (board_config == ALC680_AUTO)
19875 spec->init_hook = alc680_auto_init;
19876
19877 return 0;
19878}
19879
19880/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070019881 * patch entries
19882 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019883static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070019884 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019885 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019886 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020019887 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019888 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019889 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020019890 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019891 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019892 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019893 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019894 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
19895 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
19896 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019897 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019898 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019899 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
19900 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020019901 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010019902 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010019903 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019904 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019905 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019906 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019907 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020019908 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019909 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020019910 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019911 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019912 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019913 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020019914 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019915 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019916 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019917 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019918 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019919 {} /* terminator */
19920};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019921
19922MODULE_ALIAS("snd-hda-codec-id:10ec*");
19923
19924MODULE_LICENSE("GPL");
19925MODULE_DESCRIPTION("Realtek HD-audio codec");
19926
19927static struct hda_codec_preset_list realtek_list = {
19928 .preset = snd_hda_preset_realtek,
19929 .owner = THIS_MODULE,
19930};
19931
19932static int __init patch_realtek_init(void)
19933{
19934 return snd_hda_add_codec_preset(&realtek_list);
19935}
19936
19937static void __exit patch_realtek_exit(void)
19938{
19939 snd_hda_delete_codec_preset(&realtek_list);
19940}
19941
19942module_init(patch_realtek_init)
19943module_exit(patch_realtek_exit)