blob: 3e41d563776426b5c6ed9aa9c54ac984d2bedaf4 [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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Davis2880a862007-08-07 11:50:26 +0200228 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800229 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100230 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200231 ALC888_ACER_ASPIRE_8930G,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200232 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200233 ALC883_MEDION,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +0200234 ALC883_MEDION_WIM2160,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100235 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200236 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200237 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200238 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200239 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200240 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200241 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100242 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100243 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430244 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100245 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100246 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800247 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200248 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200249 ALC889A_INTEL,
250 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200251 ALC888_ASUS_M90V,
252 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200253 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100254 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200255 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200256 ALC882_AUTO,
257 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200258};
259
Takashi Iwaid4a86d82010-06-23 17:51:26 +0200260/* ALC680 models */
261enum {
262 ALC680_BASE,
263 ALC680_AUTO,
264 ALC680_MODEL_LAST,
265};
266
Kailang Yangdf694da2005-12-05 19:42:22 +0100267/* for GPIO Poll */
268#define GPIO_MASK 0x03
269
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200270/* extra amp-initialization sequence types */
271enum {
272 ALC_INIT_NONE,
273 ALC_INIT_DEFAULT,
274 ALC_INIT_GPIO1,
275 ALC_INIT_GPIO2,
276 ALC_INIT_GPIO3,
277};
278
Takashi Iwai6c819492009-08-10 18:47:44 +0200279struct alc_mic_route {
280 hda_nid_t pin;
281 unsigned char mux_idx;
282 unsigned char amix_idx;
283};
284
285#define MUX_IDX_UNDEF ((unsigned char)-1)
286
Kailang Yangda00c242010-03-19 11:23:45 +0100287struct alc_customize_define {
288 unsigned int sku_cfg;
289 unsigned char port_connectivity;
290 unsigned char check_sum;
291 unsigned char customization;
292 unsigned char external_amp;
293 unsigned int enable_pcbeep:1;
294 unsigned int platform_type:1;
295 unsigned int swap:1;
296 unsigned int override:1;
David Henningsson90622912010-10-14 14:50:18 +0200297 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
Kailang Yangda00c242010-03-19 11:23:45 +0100298};
299
Takashi Iwaib5bfbc62011-01-13 14:22:32 +0100300struct alc_fixup;
301
Takashi Iwaice764ab2011-04-27 16:35:23 +0200302struct alc_multi_io {
303 hda_nid_t pin; /* multi-io widget pin NID */
304 hda_nid_t dac; /* DAC to be connected */
305 unsigned int ctl_in; /* cached input-pin control value */
306};
307
Takashi Iwaid922b512011-04-28 12:18:53 +0200308enum {
Takashi Iwai3b8510c2011-04-28 14:03:24 +0200309 ALC_AUTOMUTE_PIN, /* change the pin control */
310 ALC_AUTOMUTE_AMP, /* mute/unmute the pin AMP */
311 ALC_AUTOMUTE_MIXER, /* mute/unmute mixer widget AMP */
Takashi Iwaid922b512011-04-28 12:18:53 +0200312};
313
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314struct alc_spec {
315 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100316 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100318 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100319 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320
Takashi Iwai2d9c6482009-10-13 08:06:55 +0200321 const struct hda_verb *init_verbs[10]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200322 * don't forget NULL
323 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200324 */
325 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200327 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328 struct hda_pcm_stream *stream_analog_playback;
329 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100330 struct hda_pcm_stream *stream_analog_alt_playback;
331 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200333 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334 struct hda_pcm_stream *stream_digital_playback;
335 struct hda_pcm_stream *stream_digital_capture;
336
337 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200338 struct hda_multi_out multiout; /* playback set-up
339 * max_channels, dacs must be set
340 * dig_out_nid and hp_nid are optional
341 */
Takashi Iwai63300792008-01-24 15:31:36 +0100342 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100343 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100344 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345
346 /* capture */
347 unsigned int num_adc_nids;
348 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100349 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200350 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351
Takashi Iwai840b64c2010-07-13 22:49:01 +0200352 /* capture setup for dynamic dual-adc switch */
353 unsigned int cur_adc_idx;
354 hda_nid_t cur_adc;
355 unsigned int cur_adc_stream_tag;
356 unsigned int cur_adc_format;
357
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200359 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360 const struct hda_input_mux *input_mux;
361 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200362 struct alc_mic_route ext_mic;
363 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364
365 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100366 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200368 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200369 int const_channel_count;
370 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371
372 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100373 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200374
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200375 /* dynamic controls, init_verbs and input_mux */
376 struct auto_pin_cfg autocfg;
Kailang Yangda00c242010-03-19 11:23:45 +0100377 struct alc_customize_define cdefine;
Takashi Iwai603c4012008-07-30 15:01:44 +0200378 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200379 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200380 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200381 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
382 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100383
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100384 /* hooks */
385 void (*init_hook)(struct hda_codec *codec);
386 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
Hector Martinf5de24b2009-12-20 22:51:31 +0100387#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -0500388 void (*power_hook)(struct hda_codec *codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100389#endif
Takashi Iwai1c716152011-04-07 10:37:16 +0200390 void (*shutup)(struct hda_codec *codec);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100391
Takashi Iwai834be882006-03-01 14:16:17 +0100392 /* for pin sensing */
Takashi Iwai834be882006-03-01 14:16:17 +0100393 unsigned int jack_present: 1;
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +0200394 unsigned int line_jack_present:1;
Takashi Iwaie9427962011-04-28 15:46:07 +0200395 unsigned int master_mute:1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200396 unsigned int auto_mic:1;
Takashi Iwaid922b512011-04-28 12:18:53 +0200397 unsigned int automute:1; /* HP automute enabled */
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +0200398 unsigned int detect_line:1; /* Line-out detection enabled */
399 unsigned int automute_lines:1; /* automute line-out as well */
Takashi Iwaicb53c622007-08-10 17:21:45 +0200400
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100401 /* other flags */
402 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai840b64c2010-07-13 22:49:01 +0200403 unsigned int dual_adc_switch:1; /* switch ADCs (for ALC275) */
Takashi Iwai584c0c42011-03-10 12:51:11 +0100404 unsigned int single_input_src:1;
Takashi Iwaid922b512011-04-28 12:18:53 +0200405
406 /* auto-mute control */
407 int automute_mode;
Takashi Iwai3b8510c2011-04-28 14:03:24 +0200408 hda_nid_t automute_mixer_nid[AUTO_CFG_MAX_OUTS];
Takashi Iwaid922b512011-04-28 12:18:53 +0200409
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200410 int init_amp;
Takashi Iwaid433a672010-09-20 15:11:54 +0200411 int codec_variant; /* flag for other variants */
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100412
Takashi Iwai2134ea42008-01-10 16:53:55 +0100413 /* for virtual master */
414 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200415#ifdef CONFIG_SND_HDA_POWER_SAVE
416 struct hda_loopback_check loopback;
417#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200418
419 /* for PLL fix */
420 hda_nid_t pll_nid;
421 unsigned int pll_coef_idx, pll_coef_bit;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +0100422
423 /* fix-up list */
424 int fixup_id;
425 const struct alc_fixup *fixup_list;
426 const char *fixup_name;
Takashi Iwaice764ab2011-04-27 16:35:23 +0200427
428 /* multi-io */
429 int multi_ios;
430 struct alc_multi_io multi_io[4];
Kailang Yangdf694da2005-12-05 19:42:22 +0100431};
432
433/*
434 * configuration template - to be copied to the spec instance
435 */
436struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200437 struct snd_kcontrol_new *mixers[5]; /* should be identical size
438 * with spec
439 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100440 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100441 const struct hda_verb *init_verbs[5];
442 unsigned int num_dacs;
443 hda_nid_t *dac_nids;
444 hda_nid_t dig_out_nid; /* optional */
445 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800446 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100447 unsigned int num_adc_nids;
448 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100449 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100450 hda_nid_t dig_in_nid;
451 unsigned int num_channel_mode;
452 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200453 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200454 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200455 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100456 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100457 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200458 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100459 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200460#ifdef CONFIG_SND_HDA_POWER_SAVE
461 struct hda_amp_list *loopbacks;
Daniel T Chenc97259d2009-12-27 18:52:08 -0500462 void (*power_hook)(struct hda_codec *codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200463#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464};
465
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466
467/*
468 * input MUX handling
469 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200470static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
471 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472{
473 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
474 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200475 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
476 if (mux_idx >= spec->num_mux_defs)
477 mux_idx = 0;
Takashi Iwai53111142010-03-08 12:13:07 +0100478 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
479 mux_idx = 0;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200480 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481}
482
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200483static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
484 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485{
486 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
487 struct alc_spec *spec = codec->spec;
488 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
489
490 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
491 return 0;
492}
493
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200494static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
495 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496{
497 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
498 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100499 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100501 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100502 hda_nid_t nid = spec->capsrc_nids ?
503 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200504 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505
Takashi Iwaicd896c32008-11-18 12:36:33 +0100506 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
507 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +0100508 if (!imux->num_items && mux_idx > 0)
509 imux = &spec->input_mux[0];
Takashi Iwaicd896c32008-11-18 12:36:33 +0100510
Takashi Iwaia22d5432009-07-27 12:54:26 +0200511 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200512 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100513 /* Matrix-mixer style (e.g. ALC882) */
514 unsigned int *cur_val = &spec->cur_mux[adc_idx];
515 unsigned int i, idx;
516
517 idx = ucontrol->value.enumerated.item[0];
518 if (idx >= imux->num_items)
519 idx = imux->num_items - 1;
520 if (*cur_val == idx)
521 return 0;
522 for (i = 0; i < imux->num_items; i++) {
523 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
524 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
525 imux->items[i].index,
526 HDA_AMP_MUTE, v);
527 }
528 *cur_val = idx;
529 return 1;
530 } else {
531 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100532 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100533 &spec->cur_mux[adc_idx]);
534 }
535}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200536
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537/*
538 * channel mode setting
539 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200540static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
541 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542{
543 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
544 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100545 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
546 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547}
548
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200549static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
550 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551{
552 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
553 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100554 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200555 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200556 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557}
558
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200559static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
560 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561{
562 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
563 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200564 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
565 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200566 &spec->ext_channel_count);
567 if (err >= 0 && !spec->const_channel_count) {
568 spec->multiout.max_channels = spec->ext_channel_count;
569 if (spec->need_dac_fix)
570 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
571 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200572 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573}
574
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100576 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200577 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100578 * being part of a format specifier. Maximum allowed length of a value is
579 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100580 *
581 * Note: some retasking pin complexes seem to ignore requests for input
582 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
583 * are requested. Therefore order this list so that this behaviour will not
584 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200585 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
586 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200587 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100588static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100589 "Mic 50pc bias", "Mic 80pc bias",
590 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100591};
592static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100593 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100594};
595/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200596 * in the pin being assumed to be exclusively an input or an output pin. In
597 * addition, "input" pins may or may not process the mic bias option
598 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
599 * accept requests for bias as of chip versions up to March 2006) and/or
600 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100601 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200602#define ALC_PIN_DIR_IN 0x00
603#define ALC_PIN_DIR_OUT 0x01
604#define ALC_PIN_DIR_INOUT 0x02
605#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
606#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100607
Kailang Yangea1fb292008-08-26 12:58:38 +0200608/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100609 * For each direction the minimum and maximum values are given.
610 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200611static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100612 { 0, 2 }, /* ALC_PIN_DIR_IN */
613 { 3, 4 }, /* ALC_PIN_DIR_OUT */
614 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200615 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
616 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100617};
618#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
619#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
620#define alc_pin_mode_n_items(_dir) \
621 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
622
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200623static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
624 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200625{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100626 unsigned int item_num = uinfo->value.enumerated.item;
627 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
628
629 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200630 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100631 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
632
633 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
634 item_num = alc_pin_mode_min(dir);
635 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200636 return 0;
637}
638
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200639static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
640 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200641{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100642 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200643 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
644 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100645 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200646 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200647 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
648 AC_VERB_GET_PIN_WIDGET_CONTROL,
649 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200650
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100651 /* Find enumerated value for current pinctl setting */
652 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200653 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100654 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200655 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100656 return 0;
657}
658
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200659static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
660 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100661{
662 signed int change;
663 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
664 hda_nid_t nid = kcontrol->private_value & 0xffff;
665 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
666 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200667 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
668 AC_VERB_GET_PIN_WIDGET_CONTROL,
669 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100670
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200671 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100672 val = alc_pin_mode_min(dir);
673
674 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100675 if (change) {
676 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200677 snd_hda_codec_write_cache(codec, nid, 0,
678 AC_VERB_SET_PIN_WIDGET_CONTROL,
679 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100680
Kailang Yangea1fb292008-08-26 12:58:38 +0200681 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100682 * for the requested pin mode. Enum values of 2 or less are
683 * input modes.
684 *
685 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200686 * reduces noise slightly (particularly on input) so we'll
687 * do it. However, having both input and output buffers
688 * enabled simultaneously doesn't seem to be problematic if
689 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100690 */
691 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200692 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
693 HDA_AMP_MUTE, HDA_AMP_MUTE);
694 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
695 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100696 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200697 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
698 HDA_AMP_MUTE, HDA_AMP_MUTE);
699 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
700 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100701 }
702 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200703 return change;
704}
705
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100706#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200707 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100708 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100709 .info = alc_pin_mode_info, \
710 .get = alc_pin_mode_get, \
711 .put = alc_pin_mode_put, \
712 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100713
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100714/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
715 * together using a mask with more than one bit set. This control is
716 * currently used only by the ALC260 test model. At this stage they are not
717 * needed for any "production" models.
718 */
719#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200720#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200721
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200722static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
723 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100724{
725 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
726 hda_nid_t nid = kcontrol->private_value & 0xffff;
727 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
728 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200729 unsigned int val = snd_hda_codec_read(codec, nid, 0,
730 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100731
732 *valp = (val & mask) != 0;
733 return 0;
734}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200735static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
736 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100737{
738 signed int change;
739 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
740 hda_nid_t nid = kcontrol->private_value & 0xffff;
741 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
742 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200743 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
744 AC_VERB_GET_GPIO_DATA,
745 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100746
747 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200748 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
749 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100750 gpio_data &= ~mask;
751 else
752 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200753 snd_hda_codec_write_cache(codec, nid, 0,
754 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100755
756 return change;
757}
758#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
759 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100760 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100761 .info = alc_gpio_data_info, \
762 .get = alc_gpio_data_get, \
763 .put = alc_gpio_data_put, \
764 .private_value = nid | (mask<<16) }
765#endif /* CONFIG_SND_DEBUG */
766
Jonathan Woithe92621f12006-02-28 11:47:47 +0100767/* A switch control to allow the enabling of the digital IO pins on the
768 * ALC260. This is incredibly simplistic; the intention of this control is
769 * to provide something in the test model allowing digital outputs to be
770 * identified if present. If models are found which can utilise these
771 * outputs a more complete mixer control can be devised for those models if
772 * necessary.
773 */
774#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200775#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200776
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200777static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
778 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100779{
780 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
781 hda_nid_t nid = kcontrol->private_value & 0xffff;
782 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
783 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200784 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100785 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100786
787 *valp = (val & mask) != 0;
788 return 0;
789}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200790static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
791 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100792{
793 signed int change;
794 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
795 hda_nid_t nid = kcontrol->private_value & 0xffff;
796 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
797 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200798 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100799 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200800 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100801
802 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200803 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100804 if (val==0)
805 ctrl_data &= ~mask;
806 else
807 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200808 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
809 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100810
811 return change;
812}
813#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
814 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100815 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100816 .info = alc_spdif_ctrl_info, \
817 .get = alc_spdif_ctrl_get, \
818 .put = alc_spdif_ctrl_put, \
819 .private_value = nid | (mask<<16) }
820#endif /* CONFIG_SND_DEBUG */
821
Jonathan Woithef8225f62008-01-08 12:16:54 +0100822/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
823 * Again, this is only used in the ALC26x test models to help identify when
824 * the EAPD line must be asserted for features to work.
825 */
826#ifdef CONFIG_SND_DEBUG
827#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
828
829static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
830 struct snd_ctl_elem_value *ucontrol)
831{
832 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
833 hda_nid_t nid = kcontrol->private_value & 0xffff;
834 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
835 long *valp = ucontrol->value.integer.value;
836 unsigned int val = snd_hda_codec_read(codec, nid, 0,
837 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
838
839 *valp = (val & mask) != 0;
840 return 0;
841}
842
843static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
844 struct snd_ctl_elem_value *ucontrol)
845{
846 int change;
847 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
848 hda_nid_t nid = kcontrol->private_value & 0xffff;
849 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
850 long val = *ucontrol->value.integer.value;
851 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
852 AC_VERB_GET_EAPD_BTLENABLE,
853 0x00);
854
855 /* Set/unset the masked control bit(s) as needed */
856 change = (!val ? 0 : mask) != (ctrl_data & mask);
857 if (!val)
858 ctrl_data &= ~mask;
859 else
860 ctrl_data |= mask;
861 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
862 ctrl_data);
863
864 return change;
865}
866
867#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
868 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100869 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100870 .info = alc_eapd_ctrl_info, \
871 .get = alc_eapd_ctrl_get, \
872 .put = alc_eapd_ctrl_put, \
873 .private_value = nid | (mask<<16) }
874#endif /* CONFIG_SND_DEBUG */
875
Kailang Yangdf694da2005-12-05 19:42:22 +0100876/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100877 * set up the input pin config (depending on the given auto-pin type)
878 */
879static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
880 int auto_pin_type)
881{
882 unsigned int val = PIN_IN;
883
Takashi Iwai86e29592010-09-09 14:50:17 +0200884 if (auto_pin_type == AUTO_PIN_MIC) {
Takashi Iwai23f0c042009-02-26 13:03:58 +0100885 unsigned int pincap;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200886 unsigned int oldval;
887 oldval = snd_hda_codec_read(codec, nid, 0,
888 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Takashi Iwai1327a322009-03-23 13:07:47 +0100889 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100890 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200891 /* if the default pin setup is vref50, we give it priority */
892 if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50)
Takashi Iwai23f0c042009-02-26 13:03:58 +0100893 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200894 else if (pincap & AC_PINCAP_VREF_50)
895 val = PIN_VREF50;
896 else if (pincap & AC_PINCAP_VREF_100)
897 val = PIN_VREF100;
898 else if (pincap & AC_PINCAP_VREF_GRD)
899 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100900 }
901 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
902}
903
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200904static void alc_fixup_autocfg_pin_nums(struct hda_codec *codec)
905{
906 struct alc_spec *spec = codec->spec;
907 struct auto_pin_cfg *cfg = &spec->autocfg;
908
909 if (!cfg->line_outs) {
910 while (cfg->line_outs < AUTO_CFG_MAX_OUTS &&
911 cfg->line_out_pins[cfg->line_outs])
912 cfg->line_outs++;
913 }
914 if (!cfg->speaker_outs) {
915 while (cfg->speaker_outs < AUTO_CFG_MAX_OUTS &&
916 cfg->speaker_pins[cfg->speaker_outs])
917 cfg->speaker_outs++;
918 }
919 if (!cfg->hp_outs) {
920 while (cfg->hp_outs < AUTO_CFG_MAX_OUTS &&
921 cfg->hp_pins[cfg->hp_outs])
922 cfg->hp_outs++;
923 }
924}
925
Takashi Iwai23f0c042009-02-26 13:03:58 +0100926/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100927 */
928static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
929{
930 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
931 return;
932 spec->mixers[spec->num_mixers++] = mix;
933}
934
935static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
936{
937 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
938 return;
939 spec->init_verbs[spec->num_init_verbs++] = verb;
940}
941
942/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100943 * set up from the preset table
944 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200945static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200946 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100947{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200948 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100949 int i;
950
951 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100952 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100953 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200954 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
955 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100956 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200957
Kailang Yangdf694da2005-12-05 19:42:22 +0100958 spec->channel_mode = preset->channel_mode;
959 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200960 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200961 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100962
Hector Martin3b315d72009-06-02 10:54:19 +0200963 if (preset->const_channel_count)
964 spec->multiout.max_channels = preset->const_channel_count;
965 else
966 spec->multiout.max_channels = spec->channel_mode[0].channels;
967 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100968
969 spec->multiout.num_dacs = preset->num_dacs;
970 spec->multiout.dac_nids = preset->dac_nids;
971 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800972 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100973 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200974
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200975 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200976 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200977 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100978 spec->input_mux = preset->input_mux;
979
980 spec->num_adc_nids = preset->num_adc_nids;
981 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100982 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100983 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100984
985 spec->unsol_event = preset->unsol_event;
986 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200987#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100988 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200989 spec->loopback.amplist = preset->loopbacks;
990#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200991
992 if (preset->setup)
993 preset->setup(codec);
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200994
995 alc_fixup_autocfg_pin_nums(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100996}
997
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200998/* Enable GPIO mask and set output */
999static struct hda_verb alc_gpio1_init_verbs[] = {
1000 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
1001 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1002 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
1003 { }
1004};
1005
1006static struct hda_verb alc_gpio2_init_verbs[] = {
1007 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1008 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1009 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
1010 { }
1011};
1012
Kailang Yangbdd148a2007-05-08 15:19:08 +02001013static struct hda_verb alc_gpio3_init_verbs[] = {
1014 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
1015 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
1016 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
1017 { }
1018};
1019
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02001020/*
1021 * Fix hardware PLL issue
1022 * On some codecs, the analog PLL gating control must be off while
1023 * the default value is 1.
1024 */
1025static void alc_fix_pll(struct hda_codec *codec)
1026{
1027 struct alc_spec *spec = codec->spec;
1028 unsigned int val;
1029
1030 if (!spec->pll_nid)
1031 return;
1032 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1033 spec->pll_coef_idx);
1034 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
1035 AC_VERB_GET_PROC_COEF, 0);
1036 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1037 spec->pll_coef_idx);
1038 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
1039 val & ~(1 << spec->pll_coef_bit));
1040}
1041
1042static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
1043 unsigned int coef_idx, unsigned int coef_bit)
1044{
1045 struct alc_spec *spec = codec->spec;
1046 spec->pll_nid = nid;
1047 spec->pll_coef_idx = coef_idx;
1048 spec->pll_coef_bit = coef_bit;
1049 alc_fix_pll(codec);
1050}
1051
Kailang Yang9ad0e492010-09-14 23:22:00 +02001052static int alc_init_jacks(struct hda_codec *codec)
1053{
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001054#ifdef CONFIG_SND_HDA_INPUT_JACK
Kailang Yang9ad0e492010-09-14 23:22:00 +02001055 struct alc_spec *spec = codec->spec;
1056 int err;
1057 unsigned int hp_nid = spec->autocfg.hp_pins[0];
1058 unsigned int mic_nid = spec->ext_mic.pin;
1059
Takashi Iwai265a0242010-09-21 11:26:21 +02001060 if (hp_nid) {
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001061 err = snd_hda_input_jack_add(codec, hp_nid,
1062 SND_JACK_HEADPHONE, NULL);
Takashi Iwai265a0242010-09-21 11:26:21 +02001063 if (err < 0)
1064 return err;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001065 snd_hda_input_jack_report(codec, hp_nid);
Takashi Iwai265a0242010-09-21 11:26:21 +02001066 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001067
Takashi Iwai265a0242010-09-21 11:26:21 +02001068 if (mic_nid) {
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001069 err = snd_hda_input_jack_add(codec, mic_nid,
1070 SND_JACK_MICROPHONE, NULL);
Takashi Iwai265a0242010-09-21 11:26:21 +02001071 if (err < 0)
1072 return err;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001073 snd_hda_input_jack_report(codec, mic_nid);
Takashi Iwai265a0242010-09-21 11:26:21 +02001074 }
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001075#endif /* CONFIG_SND_HDA_INPUT_JACK */
Kailang Yang9ad0e492010-09-14 23:22:00 +02001076 return 0;
1077}
Kailang Yang9ad0e492010-09-14 23:22:00 +02001078
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001079static int detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins)
Kailang Yangc9b58002007-10-16 14:30:01 +02001080{
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001081 int i, present = 0;
Kailang Yangc9b58002007-10-16 14:30:01 +02001082
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001083 for (i = 0; i < num_pins; i++) {
1084 hda_nid_t nid = pins[i];
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001085 if (!nid)
1086 break;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001087 snd_hda_input_jack_report(codec, nid);
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001088 present |= snd_hda_jack_detect(codec, nid);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001089 }
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001090 return present;
1091}
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001092
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001093static void do_automute(struct hda_codec *codec, int num_pins, hda_nid_t *pins,
Takashi Iwaie9427962011-04-28 15:46:07 +02001094 bool mute, bool hp_out)
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001095{
1096 struct alc_spec *spec = codec->spec;
1097 unsigned int mute_bits = mute ? HDA_AMP_MUTE : 0;
Takashi Iwaie9427962011-04-28 15:46:07 +02001098 unsigned int pin_bits = mute ? 0 : (hp_out ? PIN_HP : PIN_OUT);
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001099 int i;
1100
1101 for (i = 0; i < num_pins; i++) {
1102 hda_nid_t nid = pins[i];
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001103 if (!nid)
1104 break;
Takashi Iwai3b8510c2011-04-28 14:03:24 +02001105 switch (spec->automute_mode) {
1106 case ALC_AUTOMUTE_PIN:
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001107 snd_hda_codec_write(codec, nid, 0,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001108 AC_VERB_SET_PIN_WIDGET_CONTROL,
1109 pin_bits);
Takashi Iwai3b8510c2011-04-28 14:03:24 +02001110 break;
1111 case ALC_AUTOMUTE_AMP:
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001112 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001113 HDA_AMP_MUTE, mute_bits);
Takashi Iwai3b8510c2011-04-28 14:03:24 +02001114 break;
1115 case ALC_AUTOMUTE_MIXER:
1116 nid = spec->automute_mixer_nid[i];
1117 if (!nid)
1118 break;
1119 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001120 HDA_AMP_MUTE, mute_bits);
Takashi Iwai3b8510c2011-04-28 14:03:24 +02001121 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 1,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001122 HDA_AMP_MUTE, mute_bits);
Takashi Iwai3b8510c2011-04-28 14:03:24 +02001123 break;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001124 }
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001125 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001126}
1127
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001128/* Toggle internal speakers muting */
1129static void update_speakers(struct hda_codec *codec)
1130{
1131 struct alc_spec *spec = codec->spec;
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001132 int on;
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001133
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001134 if (!spec->automute)
1135 on = 0;
1136 else
1137 on = spec->jack_present | spec->line_jack_present;
1138 on |= spec->master_mute;
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001139 do_automute(codec, ARRAY_SIZE(spec->autocfg.speaker_pins),
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001140 spec->autocfg.speaker_pins, on, false);
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001141
1142 /* toggle line-out mutes if needed, too */
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001143 /* if LO is a copy of either HP or Speaker, don't need to handle it */
1144 if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0] ||
1145 spec->autocfg.line_out_pins[0] == spec->autocfg.speaker_pins[0])
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001146 return;
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001147 if (!spec->automute_lines || !spec->automute)
1148 on = 0;
1149 else
1150 on = spec->jack_present;
1151 on |= spec->master_mute;
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001152 do_automute(codec, ARRAY_SIZE(spec->autocfg.line_out_pins),
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001153 spec->autocfg.line_out_pins, on, false);
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001154}
1155
1156static void alc_hp_automute(struct hda_codec *codec)
1157{
1158 struct alc_spec *spec = codec->spec;
1159
1160 if (!spec->automute)
1161 return;
1162 spec->jack_present =
1163 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.hp_pins),
1164 spec->autocfg.hp_pins);
1165 update_speakers(codec);
1166}
1167
1168static void alc_line_automute(struct hda_codec *codec)
1169{
1170 struct alc_spec *spec = codec->spec;
1171
1172 if (!spec->automute || !spec->detect_line)
1173 return;
1174 spec->line_jack_present =
1175 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.line_out_pins),
1176 spec->autocfg.line_out_pins);
1177 update_speakers(codec);
1178}
1179
Takashi Iwai6c819492009-08-10 18:47:44 +02001180static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1181 hda_nid_t nid)
1182{
1183 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1184 int i, nums;
1185
1186 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1187 for (i = 0; i < nums; i++)
1188 if (conn[i] == nid)
1189 return i;
1190 return -1;
1191}
1192
Takashi Iwai840b64c2010-07-13 22:49:01 +02001193/* switch the current ADC according to the jack state */
1194static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1195{
1196 struct alc_spec *spec = codec->spec;
1197 unsigned int present;
1198 hda_nid_t new_adc;
1199
1200 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1201 if (present)
1202 spec->cur_adc_idx = 1;
1203 else
1204 spec->cur_adc_idx = 0;
1205 new_adc = spec->adc_nids[spec->cur_adc_idx];
1206 if (spec->cur_adc && spec->cur_adc != new_adc) {
1207 /* stream is running, let's swap the current ADC */
Takashi Iwaif0cea792010-08-13 11:56:53 +02001208 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
Takashi Iwai840b64c2010-07-13 22:49:01 +02001209 spec->cur_adc = new_adc;
1210 snd_hda_codec_setup_stream(codec, new_adc,
1211 spec->cur_adc_stream_tag, 0,
1212 spec->cur_adc_format);
1213 }
1214}
1215
Kailang Yang7fb0d782008-10-15 11:12:35 +02001216static void alc_mic_automute(struct hda_codec *codec)
1217{
1218 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001219 struct alc_mic_route *dead, *alive;
1220 unsigned int present, type;
1221 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001222
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001223 if (!spec->auto_mic)
1224 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001225 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1226 return;
1227 if (snd_BUG_ON(!spec->adc_nids))
1228 return;
1229
Takashi Iwai840b64c2010-07-13 22:49:01 +02001230 if (spec->dual_adc_switch) {
1231 alc_dual_mic_adc_auto_switch(codec);
1232 return;
1233 }
1234
Takashi Iwai6c819492009-08-10 18:47:44 +02001235 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1236
Wu Fengguang864f92b2009-11-18 12:38:02 +08001237 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001238 if (present) {
1239 alive = &spec->ext_mic;
1240 dead = &spec->int_mic;
1241 } else {
1242 alive = &spec->int_mic;
1243 dead = &spec->ext_mic;
1244 }
1245
Takashi Iwai6c819492009-08-10 18:47:44 +02001246 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1247 if (type == AC_WID_AUD_MIX) {
1248 /* Matrix-mixer style (e.g. ALC882) */
1249 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1250 alive->mux_idx,
1251 HDA_AMP_MUTE, 0);
1252 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1253 dead->mux_idx,
1254 HDA_AMP_MUTE, HDA_AMP_MUTE);
1255 } else {
1256 /* MUX style (e.g. ALC880) */
1257 snd_hda_codec_write_cache(codec, cap_nid, 0,
1258 AC_VERB_SET_CONNECT_SEL,
1259 alive->mux_idx);
1260 }
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001261 snd_hda_input_jack_report(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001262
1263 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001264}
1265
Kailang Yangc9b58002007-10-16 14:30:01 +02001266/* unsolicited event for HP jack sensing */
1267static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1268{
1269 if (codec->vendor_id == 0x10ec0880)
1270 res >>= 28;
1271 else
1272 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001273 switch (res) {
1274 case ALC880_HP_EVENT:
Takashi Iwaid922b512011-04-28 12:18:53 +02001275 alc_hp_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001276 break;
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001277 case ALC880_FRONT_EVENT:
1278 alc_line_automute(codec);
1279 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001280 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001281 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001282 break;
1283 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001284}
1285
1286static void alc_inithook(struct hda_codec *codec)
1287{
Takashi Iwaid922b512011-04-28 12:18:53 +02001288 alc_hp_automute(codec);
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001289 alc_line_automute(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001290 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001291}
1292
Kailang Yangf9423e72008-05-27 12:32:25 +02001293/* additional initialization for ALC888 variants */
1294static void alc888_coef_init(struct hda_codec *codec)
1295{
1296 unsigned int tmp;
1297
1298 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1299 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1300 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001301 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001302 /* alc888S-VC */
1303 snd_hda_codec_read(codec, 0x20, 0,
1304 AC_VERB_SET_PROC_COEF, 0x830);
1305 else
1306 /* alc888-VB */
1307 snd_hda_codec_read(codec, 0x20, 0,
1308 AC_VERB_SET_PROC_COEF, 0x3030);
1309}
1310
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001311static void alc889_coef_init(struct hda_codec *codec)
1312{
1313 unsigned int tmp;
1314
1315 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1316 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1317 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1318 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1319}
1320
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001321/* turn on/off EAPD control (only if available) */
1322static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1323{
1324 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1325 return;
1326 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1327 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1328 on ? 2 : 0);
1329}
1330
Takashi Iwai691f1fc2011-04-07 10:31:43 +02001331/* turn on/off EAPD controls of the codec */
1332static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
1333{
1334 /* We currently only handle front, HP */
1335 switch (codec->vendor_id) {
1336 case 0x10ec0260:
1337 set_eapd(codec, 0x0f, on);
1338 set_eapd(codec, 0x10, on);
1339 break;
1340 case 0x10ec0262:
1341 case 0x10ec0267:
1342 case 0x10ec0268:
1343 case 0x10ec0269:
1344 case 0x10ec0270:
1345 case 0x10ec0272:
1346 case 0x10ec0660:
1347 case 0x10ec0662:
1348 case 0x10ec0663:
1349 case 0x10ec0665:
1350 case 0x10ec0862:
1351 case 0x10ec0889:
1352 case 0x10ec0892:
1353 set_eapd(codec, 0x14, on);
1354 set_eapd(codec, 0x15, on);
1355 break;
1356 }
1357}
1358
Takashi Iwai1c716152011-04-07 10:37:16 +02001359/* generic shutup callback;
1360 * just turning off EPAD and a little pause for avoiding pop-noise
1361 */
1362static void alc_eapd_shutup(struct hda_codec *codec)
1363{
1364 alc_auto_setup_eapd(codec, false);
1365 msleep(200);
1366}
1367
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001368static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001369{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001370 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001371
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001372 switch (type) {
1373 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001374 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1375 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001376 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001377 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1378 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001379 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001380 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1381 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001382 case ALC_INIT_DEFAULT:
Takashi Iwai691f1fc2011-04-07 10:31:43 +02001383 alc_auto_setup_eapd(codec, true);
Kailang Yangc9b58002007-10-16 14:30:01 +02001384 switch (codec->vendor_id) {
1385 case 0x10ec0260:
1386 snd_hda_codec_write(codec, 0x1a, 0,
1387 AC_VERB_SET_COEF_INDEX, 7);
1388 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1389 AC_VERB_GET_PROC_COEF, 0);
1390 snd_hda_codec_write(codec, 0x1a, 0,
1391 AC_VERB_SET_COEF_INDEX, 7);
1392 snd_hda_codec_write(codec, 0x1a, 0,
1393 AC_VERB_SET_PROC_COEF,
1394 tmp | 0x2010);
1395 break;
1396 case 0x10ec0262:
1397 case 0x10ec0880:
1398 case 0x10ec0882:
1399 case 0x10ec0883:
1400 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001401 case 0x10ec0887:
Takashi Iwai20b67dd2011-03-23 22:54:32 +01001402 /*case 0x10ec0889:*/ /* this causes an SPDIF problem */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001403 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001404 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001405 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001406 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001407 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001408#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001409 case 0x10ec0267:
1410 case 0x10ec0268:
1411 snd_hda_codec_write(codec, 0x20, 0,
1412 AC_VERB_SET_COEF_INDEX, 7);
1413 tmp = snd_hda_codec_read(codec, 0x20, 0,
1414 AC_VERB_GET_PROC_COEF, 0);
1415 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001416 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001417 snd_hda_codec_write(codec, 0x20, 0,
1418 AC_VERB_SET_PROC_COEF,
1419 tmp | 0x3000);
1420 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001421#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001422 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001423 break;
1424 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001425}
Kailang Yangea1fb292008-08-26 12:58:38 +02001426
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001427static int alc_automute_mode_info(struct snd_kcontrol *kcontrol,
1428 struct snd_ctl_elem_info *uinfo)
1429{
1430 static const char * const texts[] = {
1431 "Disabled", "Speaker Only", "Line-Out+Speaker"
1432 };
1433
1434 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1435 uinfo->count = 1;
1436 uinfo->value.enumerated.items = 3;
1437 if (uinfo->value.enumerated.item >= 3)
1438 uinfo->value.enumerated.item = 2;
1439 strcpy(uinfo->value.enumerated.name,
1440 texts[uinfo->value.enumerated.item]);
1441 return 0;
1442}
1443
1444static int alc_automute_mode_get(struct snd_kcontrol *kcontrol,
1445 struct snd_ctl_elem_value *ucontrol)
1446{
1447 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1448 struct alc_spec *spec = codec->spec;
1449 unsigned int val;
1450 if (!spec->automute)
1451 val = 0;
1452 else if (!spec->automute_lines)
1453 val = 1;
1454 else
1455 val = 2;
1456 ucontrol->value.enumerated.item[0] = val;
1457 return 0;
1458}
1459
1460static int alc_automute_mode_put(struct snd_kcontrol *kcontrol,
1461 struct snd_ctl_elem_value *ucontrol)
1462{
1463 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1464 struct alc_spec *spec = codec->spec;
1465
1466 switch (ucontrol->value.enumerated.item[0]) {
1467 case 0:
1468 if (!spec->automute)
1469 return 0;
1470 spec->automute = 0;
1471 break;
1472 case 1:
1473 if (spec->automute && !spec->automute_lines)
1474 return 0;
1475 spec->automute = 1;
1476 spec->automute_lines = 0;
1477 break;
1478 case 2:
1479 if (spec->automute && spec->automute_lines)
1480 return 0;
1481 spec->automute = 1;
1482 spec->automute_lines = 1;
1483 break;
1484 default:
1485 return -EINVAL;
1486 }
1487 update_speakers(codec);
1488 return 1;
1489}
1490
1491static struct snd_kcontrol_new alc_automute_mode_enum = {
1492 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1493 .name = "Auto-Mute Mode",
1494 .info = alc_automute_mode_info,
1495 .get = alc_automute_mode_get,
1496 .put = alc_automute_mode_put,
1497};
1498
1499static struct snd_kcontrol_new *alc_kcontrol_new(struct alc_spec *spec);
1500
1501static int alc_add_automute_mode_enum(struct hda_codec *codec)
1502{
1503 struct alc_spec *spec = codec->spec;
1504 struct snd_kcontrol_new *knew;
1505
1506 knew = alc_kcontrol_new(spec);
1507 if (!knew)
1508 return -ENOMEM;
1509 *knew = alc_automute_mode_enum;
1510 knew->name = kstrdup("Auto-Mute Mode", GFP_KERNEL);
1511 if (!knew->name)
1512 return -ENOMEM;
1513 return 0;
1514}
1515
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001516static void alc_init_auto_hp(struct hda_codec *codec)
1517{
1518 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001519 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai1daf5f42011-04-28 17:57:46 +02001520 int present = 0;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001521 int i;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001522
Takashi Iwai1daf5f42011-04-28 17:57:46 +02001523 if (cfg->hp_pins[0])
1524 present++;
1525 if (cfg->line_out_pins[0])
1526 present++;
1527 if (cfg->speaker_pins[0])
1528 present++;
1529 if (present < 2) /* need two different output types */
1530 return;
Kailang Yangc9b58002007-10-16 14:30:01 +02001531
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001532 if (!cfg->speaker_pins[0]) {
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001533 memcpy(cfg->speaker_pins, cfg->line_out_pins,
1534 sizeof(cfg->speaker_pins));
1535 cfg->speaker_outs = cfg->line_outs;
1536 }
1537
1538 if (!cfg->hp_pins[0]) {
1539 memcpy(cfg->hp_pins, cfg->line_out_pins,
1540 sizeof(cfg->hp_pins));
1541 cfg->hp_outs = cfg->line_outs;
1542 }
1543
1544 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001545 hda_nid_t nid = cfg->hp_pins[i];
1546 if (!(snd_hda_query_pin_caps(codec, nid) &
1547 AC_PINCAP_PRES_DETECT))
1548 continue;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001549 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001550 nid);
1551 snd_hda_codec_write_cache(codec, nid, 0,
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001552 AC_VERB_SET_UNSOLICITED_ENABLE,
1553 AC_USRSP_EN | ALC880_HP_EVENT);
Takashi Iwaid922b512011-04-28 12:18:53 +02001554 spec->automute = 1;
1555 spec->automute_mode = ALC_AUTOMUTE_PIN;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001556 }
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001557 if (spec->automute && cfg->line_out_pins[0] &&
1558 cfg->line_out_pins[0] != cfg->hp_pins[0] &&
1559 cfg->line_out_pins[0] != cfg->speaker_pins[0]) {
1560 for (i = 0; i < cfg->line_outs; i++) {
1561 hda_nid_t nid = cfg->line_out_pins[i];
1562 if (!(snd_hda_query_pin_caps(codec, nid) &
1563 AC_PINCAP_PRES_DETECT))
1564 continue;
1565 snd_printdd("realtek: Enable Line-Out auto-muting "
1566 "on NID 0x%x\n", nid);
1567 snd_hda_codec_write_cache(codec, nid, 0,
1568 AC_VERB_SET_UNSOLICITED_ENABLE,
1569 AC_USRSP_EN | ALC880_FRONT_EVENT);
1570 spec->detect_line = 1;
1571 }
1572 /* create a control for automute mode */
1573 alc_add_automute_mode_enum(codec);
1574 spec->automute_lines = 1;
1575 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001576 spec->unsol_event = alc_sku_unsol_event;
1577}
1578
Takashi Iwai6c819492009-08-10 18:47:44 +02001579static void alc_init_auto_mic(struct hda_codec *codec)
1580{
1581 struct alc_spec *spec = codec->spec;
1582 struct auto_pin_cfg *cfg = &spec->autocfg;
1583 hda_nid_t fixed, ext;
1584 int i;
1585
1586 /* there must be only two mic inputs exclusively */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001587 for (i = 0; i < cfg->num_inputs; i++)
Takashi Iwai86e29592010-09-09 14:50:17 +02001588 if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN)
Takashi Iwai6c819492009-08-10 18:47:44 +02001589 return;
1590
1591 fixed = ext = 0;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001592 for (i = 0; i < cfg->num_inputs; i++) {
1593 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai6c819492009-08-10 18:47:44 +02001594 unsigned int defcfg;
Takashi Iwai6c819492009-08-10 18:47:44 +02001595 defcfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001596 switch (snd_hda_get_input_pin_attr(defcfg)) {
1597 case INPUT_PIN_ATTR_INT:
Takashi Iwai6c819492009-08-10 18:47:44 +02001598 if (fixed)
1599 return; /* already occupied */
1600 fixed = nid;
1601 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001602 case INPUT_PIN_ATTR_UNUSED:
1603 return; /* invalid entry */
1604 default:
Takashi Iwai6c819492009-08-10 18:47:44 +02001605 if (ext)
1606 return; /* already occupied */
1607 ext = nid;
1608 break;
Takashi Iwai6c819492009-08-10 18:47:44 +02001609 }
1610 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001611 if (!ext || !fixed)
1612 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001613 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1614 return; /* no unsol support */
1615 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1616 ext, fixed);
1617 spec->ext_mic.pin = ext;
1618 spec->int_mic.pin = fixed;
1619 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1620 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1621 spec->auto_mic = 1;
1622 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1623 AC_VERB_SET_UNSOLICITED_ENABLE,
1624 AC_USRSP_EN | ALC880_MIC_EVENT);
1625 spec->unsol_event = alc_sku_unsol_event;
1626}
1627
David Henningsson90622912010-10-14 14:50:18 +02001628/* Could be any non-zero and even value. When used as fixup, tells
1629 * the driver to ignore any present sku defines.
1630 */
1631#define ALC_FIXUP_SKU_IGNORE (2)
1632
Kailang Yangda00c242010-03-19 11:23:45 +01001633static int alc_auto_parse_customize_define(struct hda_codec *codec)
1634{
1635 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +01001636 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +01001637 struct alc_spec *spec = codec->spec;
1638
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001639 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1640
David Henningsson90622912010-10-14 14:50:18 +02001641 if (spec->cdefine.fixup) {
1642 ass = spec->cdefine.sku_cfg;
1643 if (ass == ALC_FIXUP_SKU_IGNORE)
1644 return -1;
1645 goto do_sku;
1646 }
1647
Kailang Yangda00c242010-03-19 11:23:45 +01001648 ass = codec->subsystem_id & 0xffff;
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001649 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
Kailang Yangda00c242010-03-19 11:23:45 +01001650 goto do_sku;
1651
1652 nid = 0x1d;
1653 if (codec->vendor_id == 0x10ec0260)
1654 nid = 0x17;
1655 ass = snd_hda_codec_get_pincfg(codec, nid);
1656
1657 if (!(ass & 1)) {
1658 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1659 codec->chip_name, ass);
1660 return -1;
1661 }
1662
1663 /* check sum */
1664 tmp = 0;
1665 for (i = 1; i < 16; i++) {
1666 if ((ass >> i) & 1)
1667 tmp++;
1668 }
1669 if (((ass >> 16) & 0xf) != tmp)
1670 return -1;
1671
1672 spec->cdefine.port_connectivity = ass >> 30;
1673 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1674 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1675 spec->cdefine.customization = ass >> 8;
1676do_sku:
1677 spec->cdefine.sku_cfg = ass;
1678 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1679 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1680 spec->cdefine.swap = (ass & 0x2) >> 1;
1681 spec->cdefine.override = ass & 0x1;
1682
1683 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1684 nid, spec->cdefine.sku_cfg);
1685 snd_printd("SKU: port_connectivity=0x%x\n",
1686 spec->cdefine.port_connectivity);
1687 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1688 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1689 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1690 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1691 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1692 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1693 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1694
1695 return 0;
1696}
1697
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001698/* check subsystem ID and set up device-specific initialization;
1699 * return 1 if initialized, 0 if invalid SSID
1700 */
1701/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1702 * 31 ~ 16 : Manufacture ID
1703 * 15 ~ 8 : SKU ID
1704 * 7 ~ 0 : Assembly ID
1705 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1706 */
1707static int alc_subsystem_id(struct hda_codec *codec,
1708 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001709 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001710{
1711 unsigned int ass, tmp, i;
1712 unsigned nid;
1713 struct alc_spec *spec = codec->spec;
1714
David Henningsson90622912010-10-14 14:50:18 +02001715 if (spec->cdefine.fixup) {
1716 ass = spec->cdefine.sku_cfg;
1717 if (ass == ALC_FIXUP_SKU_IGNORE)
1718 return 0;
1719 goto do_sku;
1720 }
1721
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001722 ass = codec->subsystem_id & 0xffff;
1723 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1724 goto do_sku;
1725
1726 /* invalid SSID, check the special NID pin defcfg instead */
1727 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001728 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001729 * 29~21 : reserve
1730 * 20 : PCBEEP input
1731 * 19~16 : Check sum (15:1)
1732 * 15~1 : Custom
1733 * 0 : override
1734 */
1735 nid = 0x1d;
1736 if (codec->vendor_id == 0x10ec0260)
1737 nid = 0x17;
1738 ass = snd_hda_codec_get_pincfg(codec, nid);
1739 snd_printd("realtek: No valid SSID, "
1740 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001741 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001742 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001743 return 0;
1744 if ((ass >> 30) != 1) /* no physical connection */
1745 return 0;
1746
1747 /* check sum */
1748 tmp = 0;
1749 for (i = 1; i < 16; i++) {
1750 if ((ass >> i) & 1)
1751 tmp++;
1752 }
1753 if (((ass >> 16) & 0xf) != tmp)
1754 return 0;
1755do_sku:
1756 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1757 ass & 0xffff, codec->vendor_id);
1758 /*
1759 * 0 : override
1760 * 1 : Swap Jack
1761 * 2 : 0 --> Desktop, 1 --> Laptop
1762 * 3~5 : External Amplifier control
1763 * 7~6 : Reserved
1764 */
1765 tmp = (ass & 0x38) >> 3; /* external Amp control */
1766 switch (tmp) {
1767 case 1:
1768 spec->init_amp = ALC_INIT_GPIO1;
1769 break;
1770 case 3:
1771 spec->init_amp = ALC_INIT_GPIO2;
1772 break;
1773 case 7:
1774 spec->init_amp = ALC_INIT_GPIO3;
1775 break;
1776 case 5:
Takashi Iwai5a8cfb42010-11-26 17:11:18 +01001777 default:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001778 spec->init_amp = ALC_INIT_DEFAULT;
1779 break;
1780 }
1781
1782 /* is laptop or Desktop and enable the function "Mute internal speaker
1783 * when the external headphone out jack is plugged"
1784 */
1785 if (!(ass & 0x8000))
1786 return 1;
1787 /*
1788 * 10~8 : Jack location
1789 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1790 * 14~13: Resvered
1791 * 15 : 1 --> enable the function "Mute internal speaker
1792 * when the external headphone out jack is plugged"
1793 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001794 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001795 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001796 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1797 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001798 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001799 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001800 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001801 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001802 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001803 else if (tmp == 3)
1804 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001805 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001806 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001807 for (i = 0; i < spec->autocfg.line_outs; i++)
1808 if (spec->autocfg.line_out_pins[i] == nid)
1809 return 1;
1810 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001811 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001812 return 1;
1813}
Kailang Yangea1fb292008-08-26 12:58:38 +02001814
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001815static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001816 hda_nid_t porta, hda_nid_t porte,
1817 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001818{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001819 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001820 struct alc_spec *spec = codec->spec;
1821 snd_printd("realtek: "
1822 "Enable default setup for auto mode as fallback\n");
1823 spec->init_amp = ALC_INIT_DEFAULT;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001824 }
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001825
1826 alc_init_auto_hp(codec);
1827 alc_init_auto_mic(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001828}
1829
Takashi Iwai41e41f12005-06-08 14:48:49 +02001830/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001831 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001832 */
1833
1834struct alc_pincfg {
1835 hda_nid_t nid;
1836 u32 val;
1837};
1838
Todd Broche1eb5f12010-12-06 11:19:51 -08001839struct alc_model_fixup {
1840 const int id;
1841 const char *name;
1842};
1843
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001844struct alc_fixup {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001845 int type;
Takashi Iwai361fe6e2011-01-14 09:55:32 +01001846 bool chained;
1847 int chain_id;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001848 union {
1849 unsigned int sku;
1850 const struct alc_pincfg *pins;
1851 const struct hda_verb *verbs;
1852 void (*func)(struct hda_codec *codec,
1853 const struct alc_fixup *fix,
1854 int action);
1855 } v;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001856};
1857
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001858enum {
1859 ALC_FIXUP_INVALID,
1860 ALC_FIXUP_SKU,
1861 ALC_FIXUP_PINS,
1862 ALC_FIXUP_VERBS,
1863 ALC_FIXUP_FUNC,
1864};
Takashi Iwaif95474e2007-07-10 00:47:43 +02001865
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001866enum {
1867 ALC_FIXUP_ACT_PRE_PROBE,
1868 ALC_FIXUP_ACT_PROBE,
Takashi Iwai58701122011-01-13 15:41:45 +01001869 ALC_FIXUP_ACT_INIT,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001870};
1871
1872static void alc_apply_fixup(struct hda_codec *codec, int action)
1873{
1874 struct alc_spec *spec = codec->spec;
1875 int id = spec->fixup_id;
Takashi Iwaiaa1d0c52011-01-19 17:27:58 +01001876#ifdef CONFIG_SND_DEBUG_VERBOSE
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001877 const char *modelname = spec->fixup_name;
Takashi Iwaiaa1d0c52011-01-19 17:27:58 +01001878#endif
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001879 int depth = 0;
1880
1881 if (!spec->fixup_list)
1882 return;
1883
1884 while (id >= 0) {
1885 const struct alc_fixup *fix = spec->fixup_list + id;
1886 const struct alc_pincfg *cfg;
1887
1888 switch (fix->type) {
1889 case ALC_FIXUP_SKU:
1890 if (action != ALC_FIXUP_ACT_PRE_PROBE || !fix->v.sku)
1891 break;;
1892 snd_printdd(KERN_INFO "hda_codec: %s: "
1893 "Apply sku override for %s\n",
1894 codec->chip_name, modelname);
1895 spec->cdefine.sku_cfg = fix->v.sku;
1896 spec->cdefine.fixup = 1;
1897 break;
1898 case ALC_FIXUP_PINS:
1899 cfg = fix->v.pins;
1900 if (action != ALC_FIXUP_ACT_PRE_PROBE || !cfg)
1901 break;
1902 snd_printdd(KERN_INFO "hda_codec: %s: "
1903 "Apply pincfg for %s\n",
1904 codec->chip_name, modelname);
1905 for (; cfg->nid; cfg++)
1906 snd_hda_codec_set_pincfg(codec, cfg->nid,
1907 cfg->val);
1908 break;
1909 case ALC_FIXUP_VERBS:
1910 if (action != ALC_FIXUP_ACT_PROBE || !fix->v.verbs)
1911 break;
1912 snd_printdd(KERN_INFO "hda_codec: %s: "
1913 "Apply fix-verbs for %s\n",
1914 codec->chip_name, modelname);
1915 add_verb(codec->spec, fix->v.verbs);
1916 break;
1917 case ALC_FIXUP_FUNC:
1918 if (!fix->v.func)
1919 break;
1920 snd_printdd(KERN_INFO "hda_codec: %s: "
1921 "Apply fix-func for %s\n",
1922 codec->chip_name, modelname);
1923 fix->v.func(codec, fix, action);
1924 break;
1925 default:
1926 snd_printk(KERN_ERR "hda_codec: %s: "
1927 "Invalid fixup type %d\n",
1928 codec->chip_name, fix->type);
1929 break;
1930 }
1931 if (!fix[id].chained)
1932 break;
1933 if (++depth > 10)
1934 break;
1935 id = fix[id].chain_id;
Takashi Iwai9d578832010-11-22 13:29:19 +01001936 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001937}
1938
Todd Broche1eb5f12010-12-06 11:19:51 -08001939static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001940 const struct alc_model_fixup *models,
1941 const struct snd_pci_quirk *quirk,
1942 const struct alc_fixup *fixlist)
Todd Broche1eb5f12010-12-06 11:19:51 -08001943{
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001944 struct alc_spec *spec = codec->spec;
1945 int id = -1;
1946 const char *name = NULL;
Todd Broche1eb5f12010-12-06 11:19:51 -08001947
Todd Broche1eb5f12010-12-06 11:19:51 -08001948 if (codec->modelname && models) {
1949 while (models->name) {
1950 if (!strcmp(codec->modelname, models->name)) {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001951 id = models->id;
1952 name = models->name;
Todd Broche1eb5f12010-12-06 11:19:51 -08001953 break;
1954 }
1955 models++;
1956 }
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001957 }
1958 if (id < 0) {
1959 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1960 if (quirk) {
1961 id = quirk->value;
1962#ifdef CONFIG_SND_DEBUG_VERBOSE
1963 name = quirk->name;
1964#endif
1965 }
1966 }
1967
1968 spec->fixup_id = id;
1969 if (id >= 0) {
1970 spec->fixup_list = fixlist;
1971 spec->fixup_name = name;
Todd Broche1eb5f12010-12-06 11:19:51 -08001972 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001973}
1974
Kailang Yang274693f2009-12-03 10:07:50 +01001975static int alc_read_coef_idx(struct hda_codec *codec,
1976 unsigned int coef_idx)
1977{
1978 unsigned int val;
1979 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1980 coef_idx);
1981 val = snd_hda_codec_read(codec, 0x20, 0,
1982 AC_VERB_GET_PROC_COEF, 0);
1983 return val;
1984}
1985
Kailang Yang977ddd62010-09-15 10:02:29 +02001986static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1987 unsigned int coef_val)
1988{
1989 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1990 coef_idx);
1991 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
1992 coef_val);
1993}
1994
Takashi Iwai757899a2010-07-30 10:48:14 +02001995/* set right pin controls for digital I/O */
1996static void alc_auto_init_digital(struct hda_codec *codec)
1997{
1998 struct alc_spec *spec = codec->spec;
1999 int i;
2000 hda_nid_t pin;
2001
2002 for (i = 0; i < spec->autocfg.dig_outs; i++) {
2003 pin = spec->autocfg.dig_out_pins[i];
2004 if (pin) {
2005 snd_hda_codec_write(codec, pin, 0,
2006 AC_VERB_SET_PIN_WIDGET_CONTROL,
2007 PIN_OUT);
2008 }
2009 }
2010 pin = spec->autocfg.dig_in_pin;
2011 if (pin)
2012 snd_hda_codec_write(codec, pin, 0,
2013 AC_VERB_SET_PIN_WIDGET_CONTROL,
2014 PIN_IN);
2015}
2016
2017/* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
2018static void alc_auto_parse_digital(struct hda_codec *codec)
2019{
2020 struct alc_spec *spec = codec->spec;
2021 int i, err;
2022 hda_nid_t dig_nid;
2023
2024 /* support multiple SPDIFs; the secondary is set up as a slave */
2025 for (i = 0; i < spec->autocfg.dig_outs; i++) {
2026 err = snd_hda_get_connections(codec,
2027 spec->autocfg.dig_out_pins[i],
2028 &dig_nid, 1);
2029 if (err < 0)
2030 continue;
2031 if (!i) {
2032 spec->multiout.dig_out_nid = dig_nid;
2033 spec->dig_out_type = spec->autocfg.dig_out_type[0];
2034 } else {
2035 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
2036 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
2037 break;
2038 spec->slave_dig_outs[i - 1] = dig_nid;
2039 }
2040 }
2041
2042 if (spec->autocfg.dig_in_pin) {
Takashi Iwai01fdf182010-09-24 09:09:42 +02002043 dig_nid = codec->start_nid;
2044 for (i = 0; i < codec->num_nodes; i++, dig_nid++) {
2045 unsigned int wcaps = get_wcaps(codec, dig_nid);
2046 if (get_wcaps_type(wcaps) != AC_WID_AUD_IN)
2047 continue;
2048 if (!(wcaps & AC_WCAP_DIGITAL))
2049 continue;
2050 if (!(wcaps & AC_WCAP_CONN_LIST))
2051 continue;
2052 err = get_connection_index(codec, dig_nid,
2053 spec->autocfg.dig_in_pin);
2054 if (err >= 0) {
2055 spec->dig_in_nid = dig_nid;
2056 break;
2057 }
2058 }
Takashi Iwai757899a2010-07-30 10:48:14 +02002059 }
2060}
2061
Takashi Iwaif95474e2007-07-10 00:47:43 +02002062/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002063 * ALC888
2064 */
2065
2066/*
2067 * 2ch mode
2068 */
2069static struct hda_verb alc888_4ST_ch2_intel_init[] = {
2070/* Mic-in jack as mic in */
2071 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2072 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2073/* Line-in jack as Line in */
2074 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2075 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2076/* Line-Out as Front */
2077 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
2078 { } /* end */
2079};
2080
2081/*
2082 * 4ch mode
2083 */
2084static struct hda_verb alc888_4ST_ch4_intel_init[] = {
2085/* Mic-in jack as mic in */
2086 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2087 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2088/* Line-in jack as Surround */
2089 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2090 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2091/* Line-Out as Front */
2092 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
2093 { } /* end */
2094};
2095
2096/*
2097 * 6ch mode
2098 */
2099static struct hda_verb alc888_4ST_ch6_intel_init[] = {
2100/* Mic-in jack as CLFE */
2101 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2102 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2103/* Line-in jack as Surround */
2104 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2105 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2106/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
2107 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
2108 { } /* end */
2109};
2110
2111/*
2112 * 8ch mode
2113 */
2114static struct hda_verb alc888_4ST_ch8_intel_init[] = {
2115/* Mic-in jack as CLFE */
2116 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2117 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2118/* Line-in jack as Surround */
2119 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2120 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2121/* Line-Out as Side */
2122 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
2123 { } /* end */
2124};
2125
2126static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
2127 { 2, alc888_4ST_ch2_intel_init },
2128 { 4, alc888_4ST_ch4_intel_init },
2129 { 6, alc888_4ST_ch6_intel_init },
2130 { 8, alc888_4ST_ch8_intel_init },
2131};
2132
2133/*
2134 * ALC888 Fujitsu Siemens Amillo xa3530
2135 */
2136
2137static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
2138/* Front Mic: set to PIN_IN (empty by default) */
2139 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2140/* Connect Internal HP to Front */
2141 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2142 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2143 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2144/* Connect Bass HP to Front */
2145 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2146 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2147 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2148/* Connect Line-Out side jack (SPDIF) to Side */
2149 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2150 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2151 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
2152/* Connect Mic jack to CLFE */
2153 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2154 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2155 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
2156/* Connect Line-in jack to Surround */
2157 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2158 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2159 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
2160/* Connect HP out jack to Front */
2161 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2162 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2163 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2164/* Enable unsolicited event for HP jack and Line-out jack */
2165 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2166 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2167 {}
2168};
2169
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002170static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02002171{
2172 struct alc_spec *spec = codec->spec;
2173
2174 spec->autocfg.hp_pins[0] = 0x15;
2175 spec->autocfg.speaker_pins[0] = 0x14;
2176 spec->autocfg.speaker_pins[1] = 0x16;
2177 spec->autocfg.speaker_pins[2] = 0x17;
2178 spec->autocfg.speaker_pins[3] = 0x19;
2179 spec->autocfg.speaker_pins[4] = 0x1a;
Takashi Iwaid922b512011-04-28 12:18:53 +02002180 spec->automute = 1;
2181 spec->automute_mode = ALC_AUTOMUTE_AMP;
Wu Fengguang6732bd02009-07-30 09:19:14 +02002182}
2183
2184static void alc889_intel_init_hook(struct hda_codec *codec)
2185{
2186 alc889_coef_init(codec);
Takashi Iwaid922b512011-04-28 12:18:53 +02002187 alc_hp_automute(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02002188}
2189
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002190static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002191{
2192 struct alc_spec *spec = codec->spec;
2193
2194 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
2195 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
2196 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
2197 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaid922b512011-04-28 12:18:53 +02002198 spec->automute = 1;
2199 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002200}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002201
2202/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002203 * ALC888 Acer Aspire 4930G model
2204 */
2205
2206static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
2207/* Front Mic: set to PIN_IN (empty by default) */
2208 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2209/* Unselect Front Mic by default in input mixer 3 */
2210 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002211/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002212 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2213/* Connect Internal HP to front */
2214 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2215 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2216 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2217/* Connect HP out to front */
2218 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2219 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2220 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie2e93292011-01-12 08:03:39 +01002221 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002222 { }
2223};
2224
Hector Martin3b315d72009-06-02 10:54:19 +02002225/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01002226 * ALC888 Acer Aspire 6530G model
2227 */
2228
2229static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
Tony Vroond1284182010-04-05 16:30:43 +01002230/* Route to built-in subwoofer as well as speakers */
2231 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2232 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2233 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2234 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002235/* Bias voltage on for external mic port */
2236 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02002237/* Front Mic: set to PIN_IN (empty by default) */
2238 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2239/* Unselect Front Mic by default in input mixer 3 */
2240 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002241/* Enable unsolicited event for HP jack */
2242 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2243/* Enable speaker output */
2244 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2245 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tony Vroond1284182010-04-05 16:30:43 +01002246 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002247/* Enable headphone output */
2248 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2249 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2250 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Tony Vroond1284182010-04-05 16:30:43 +01002251 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002252 { }
2253};
2254
2255/*
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002256 *ALC888 Acer Aspire 7730G model
2257 */
2258
2259static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
2260/* Bias voltage on for external mic port */
2261 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
2262/* Front Mic: set to PIN_IN (empty by default) */
2263 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2264/* Unselect Front Mic by default in input mixer 3 */
2265 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2266/* Enable unsolicited event for HP jack */
2267 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2268/* Enable speaker output */
2269 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2270 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2271 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
2272/* Enable headphone output */
2273 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2274 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2275 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2276 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
2277/*Enable internal subwoofer */
2278 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2279 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2280 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
2281 {0x17, AC_VERB_SET_EAPD_BTLENABLE, 2},
2282 { }
2283};
2284
2285/*
Hector Martin018df412009-06-04 00:13:40 +02002286 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02002287 */
2288
Hector Martin018df412009-06-04 00:13:40 +02002289static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02002290/* Front Mic: set to PIN_IN (empty by default) */
2291 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2292/* Unselect Front Mic by default in input mixer 3 */
2293 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2294/* Enable unsolicited event for HP jack */
2295 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2296/* Connect Internal Front to Front */
2297 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2298 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2299 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2300/* Connect Internal Rear to Rear */
2301 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2302 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2303 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
2304/* Connect Internal CLFE to CLFE */
2305 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2306 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2307 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
2308/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02002309 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02002310 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2311 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2312/* Enable all DACs */
2313/* DAC DISABLE/MUTE 1? */
2314/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
2315 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
2316 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
2317/* DAC DISABLE/MUTE 2? */
2318/* some bit here disables the other DACs. Init=0x4900 */
2319 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
2320 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02002321/* DMIC fix
2322 * This laptop has a stereo digital microphone. The mics are only 1cm apart
2323 * which makes the stereo useless. However, either the mic or the ALC889
2324 * makes the signal become a difference/sum signal instead of standard
2325 * stereo, which is annoying. So instead we flip this bit which makes the
2326 * codec replicate the sum signal to both channels, turning it into a
2327 * normal mono mic.
2328 */
2329/* DMIC_CONTROL? Init value = 0x0001 */
2330 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
2331 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02002332 { }
2333};
2334
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002335static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002336 /* Front mic only available on one ADC */
2337 {
2338 .num_items = 4,
2339 .items = {
2340 { "Mic", 0x0 },
2341 { "Line", 0x2 },
2342 { "CD", 0x4 },
2343 { "Front Mic", 0xb },
2344 },
2345 },
2346 {
2347 .num_items = 3,
2348 .items = {
2349 { "Mic", 0x0 },
2350 { "Line", 0x2 },
2351 { "CD", 0x4 },
2352 },
2353 }
2354};
2355
Tony Vroond2fd4b02009-06-21 00:40:10 +01002356static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
2357 /* Interal mic only available on one ADC */
2358 {
Tony Vroon684a8842009-06-26 09:27:50 +01002359 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002360 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +01002361 { "Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002362 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002363 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002364 { "Input Mix", 0xa },
David Henningsson28c4edb2010-12-20 14:24:29 +01002365 { "Internal Mic", 0xb },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002366 },
2367 },
2368 {
Tony Vroon684a8842009-06-26 09:27:50 +01002369 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002370 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +01002371 { "Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002372 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002373 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002374 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002375 },
2376 }
2377};
2378
Hector Martin018df412009-06-04 00:13:40 +02002379static struct hda_input_mux alc889_capture_sources[3] = {
2380 /* Digital mic only available on first "ADC" */
2381 {
2382 .num_items = 5,
2383 .items = {
2384 { "Mic", 0x0 },
2385 { "Line", 0x2 },
2386 { "CD", 0x4 },
2387 { "Front Mic", 0xb },
2388 { "Input Mix", 0xa },
2389 },
2390 },
2391 {
2392 .num_items = 4,
2393 .items = {
2394 { "Mic", 0x0 },
2395 { "Line", 0x2 },
2396 { "CD", 0x4 },
2397 { "Input Mix", 0xa },
2398 },
2399 },
2400 {
2401 .num_items = 4,
2402 .items = {
2403 { "Mic", 0x0 },
2404 { "Line", 0x2 },
2405 { "CD", 0x4 },
2406 { "Input Mix", 0xa },
2407 },
2408 }
2409};
2410
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002411static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002412 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2413 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2414 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2415 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2416 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2417 HDA_OUTPUT),
2418 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2419 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2420 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2421 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2422 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2423 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2424 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2425 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2426 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2427 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01002428 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002429 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002430 { } /* end */
2431};
2432
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +01002433static struct snd_kcontrol_new alc888_acer_aspire_4930g_mixer[] = {
2434 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2435 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2436 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2437 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Łukasz Wojniłowicz786c51f2011-02-24 10:03:31 +01002438 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +01002439 HDA_OUTPUT),
Łukasz Wojniłowicz786c51f2011-02-24 10:03:31 +01002440 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2441 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2442 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2443 HDA_CODEC_VOLUME_MONO("Internal LFE Playback Volume", 0x0f, 1, 0x0, HDA_OUTPUT),
2444 HDA_BIND_MUTE_MONO("Internal LFE Playback Switch", 0x0f, 1, 2, HDA_INPUT),
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +01002445 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2446 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2447 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2448 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2449 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2450 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
2451 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2452 { } /* end */
2453};
2454
Hector Martin556eea92009-12-20 22:51:23 +01002455static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
2456 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2457 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2458 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2459 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2460 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2461 HDA_OUTPUT),
2462 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2463 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2464 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2465 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2466 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2467 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01002468 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Hector Martin556eea92009-12-20 22:51:23 +01002469 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2470 { } /* end */
2471};
2472
2473
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002474static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002475{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002476 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002477
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002478 spec->autocfg.hp_pins[0] = 0x15;
2479 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01002480 spec->autocfg.speaker_pins[1] = 0x16;
2481 spec->autocfg.speaker_pins[2] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02002482 spec->automute = 1;
2483 spec->automute_mode = ALC_AUTOMUTE_AMP;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002484}
2485
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002486static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02002487{
2488 struct alc_spec *spec = codec->spec;
2489
2490 spec->autocfg.hp_pins[0] = 0x15;
2491 spec->autocfg.speaker_pins[0] = 0x14;
2492 spec->autocfg.speaker_pins[1] = 0x16;
2493 spec->autocfg.speaker_pins[2] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02002494 spec->automute = 1;
2495 spec->automute_mode = ALC_AUTOMUTE_AMP;
Emilio López320d5922009-06-25 08:18:44 +02002496}
2497
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002498static void alc888_acer_aspire_7730g_setup(struct hda_codec *codec)
2499{
2500 struct alc_spec *spec = codec->spec;
2501
2502 spec->autocfg.hp_pins[0] = 0x15;
2503 spec->autocfg.speaker_pins[0] = 0x14;
2504 spec->autocfg.speaker_pins[1] = 0x16;
2505 spec->autocfg.speaker_pins[2] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02002506 spec->automute = 1;
2507 spec->automute_mode = ALC_AUTOMUTE_AMP;
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002508}
2509
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002510static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02002511{
2512 struct alc_spec *spec = codec->spec;
2513
2514 spec->autocfg.hp_pins[0] = 0x15;
2515 spec->autocfg.speaker_pins[0] = 0x14;
2516 spec->autocfg.speaker_pins[1] = 0x16;
2517 spec->autocfg.speaker_pins[2] = 0x1b;
Takashi Iwaid922b512011-04-28 12:18:53 +02002518 spec->automute = 1;
2519 spec->automute_mode = ALC_AUTOMUTE_AMP;
Hector Martin3b315d72009-06-02 10:54:19 +02002520}
2521
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002522/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002523 * ALC880 3-stack model
2524 *
2525 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002526 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2527 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07002528 */
2529
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002530static hda_nid_t alc880_dac_nids[4] = {
2531 /* front, rear, clfe, rear_surr */
2532 0x02, 0x05, 0x04, 0x03
2533};
2534
2535static hda_nid_t alc880_adc_nids[3] = {
2536 /* ADC0-2 */
2537 0x07, 0x08, 0x09,
2538};
2539
2540/* The datasheet says the node 0x07 is connected from inputs,
2541 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01002542 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07002543 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002544static hda_nid_t alc880_adc_nids_alt[2] = {
2545 /* ADC1-2 */
2546 0x08, 0x09,
2547};
2548
2549#define ALC880_DIGOUT_NID 0x06
2550#define ALC880_DIGIN_NID 0x0a
2551
2552static struct hda_input_mux alc880_capture_source = {
2553 .num_items = 4,
2554 .items = {
2555 { "Mic", 0x0 },
2556 { "Front Mic", 0x3 },
2557 { "Line", 0x2 },
2558 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002559 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002560};
2561
2562/* channel source setting (2/6 channel selection for 3-stack) */
2563/* 2ch mode */
2564static struct hda_verb alc880_threestack_ch2_init[] = {
2565 /* set line-in to input, mute it */
2566 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2567 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2568 /* set mic-in to input vref 80%, mute it */
2569 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2570 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002571 { } /* end */
2572};
2573
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002574/* 6ch mode */
2575static struct hda_verb alc880_threestack_ch6_init[] = {
2576 /* set line-in to output, unmute it */
2577 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2578 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2579 /* set mic-in to output, unmute it */
2580 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2581 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2582 { } /* end */
2583};
2584
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002585static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002586 { 2, alc880_threestack_ch2_init },
2587 { 6, alc880_threestack_ch6_init },
2588};
2589
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002590static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002591 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002592 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002593 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002594 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002595 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2596 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002597 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2598 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002599 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2600 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2601 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2602 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2603 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2604 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2605 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2606 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002607 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002608 {
2609 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2610 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002611 .info = alc_ch_mode_info,
2612 .get = alc_ch_mode_get,
2613 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002614 },
2615 { } /* end */
2616};
2617
2618/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002619static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2620 struct snd_ctl_elem_info *uinfo)
2621{
2622 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2623 struct alc_spec *spec = codec->spec;
2624 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002625
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002626 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002627 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2628 HDA_INPUT);
2629 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002630 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002631 return err;
2632}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002633
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002634static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2635 unsigned int size, unsigned int __user *tlv)
2636{
2637 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2638 struct alc_spec *spec = codec->spec;
2639 int err;
2640
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002641 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002642 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2643 HDA_INPUT);
2644 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002645 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002646 return err;
2647}
2648
2649typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2650 struct snd_ctl_elem_value *ucontrol);
2651
2652static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2653 struct snd_ctl_elem_value *ucontrol,
2654 getput_call_t func)
2655{
2656 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2657 struct alc_spec *spec = codec->spec;
2658 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2659 int err;
2660
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002661 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002662 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2663 3, 0, HDA_INPUT);
2664 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002665 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002666 return err;
2667}
2668
2669static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2670 struct snd_ctl_elem_value *ucontrol)
2671{
2672 return alc_cap_getput_caller(kcontrol, ucontrol,
2673 snd_hda_mixer_amp_volume_get);
2674}
2675
2676static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2677 struct snd_ctl_elem_value *ucontrol)
2678{
2679 return alc_cap_getput_caller(kcontrol, ucontrol,
2680 snd_hda_mixer_amp_volume_put);
2681}
2682
2683/* capture mixer elements */
2684#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2685
2686static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2687 struct snd_ctl_elem_value *ucontrol)
2688{
2689 return alc_cap_getput_caller(kcontrol, ucontrol,
2690 snd_hda_mixer_amp_switch_get);
2691}
2692
2693static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2694 struct snd_ctl_elem_value *ucontrol)
2695{
2696 return alc_cap_getput_caller(kcontrol, ucontrol,
2697 snd_hda_mixer_amp_switch_put);
2698}
2699
Takashi Iwaia23b6882009-03-23 15:21:36 +01002700#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002701 { \
2702 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2703 .name = "Capture Switch", \
2704 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2705 .count = num, \
2706 .info = alc_cap_sw_info, \
2707 .get = alc_cap_sw_get, \
2708 .put = alc_cap_sw_put, \
2709 }, \
2710 { \
2711 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2712 .name = "Capture Volume", \
2713 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2714 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2715 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2716 .count = num, \
2717 .info = alc_cap_vol_info, \
2718 .get = alc_cap_vol_get, \
2719 .put = alc_cap_vol_put, \
2720 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002721 }
2722
2723#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002724 { \
2725 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2726 /* .name = "Capture Source", */ \
2727 .name = "Input Source", \
2728 .count = num, \
2729 .info = alc_mux_enum_info, \
2730 .get = alc_mux_enum_get, \
2731 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002732 }
2733
2734#define DEFINE_CAPMIX(num) \
2735static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2736 _DEFINE_CAPMIX(num), \
2737 _DEFINE_CAPSRC(num), \
2738 { } /* end */ \
2739}
2740
2741#define DEFINE_CAPMIX_NOSRC(num) \
2742static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2743 _DEFINE_CAPMIX(num), \
2744 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002745}
2746
2747/* up to three ADCs */
2748DEFINE_CAPMIX(1);
2749DEFINE_CAPMIX(2);
2750DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002751DEFINE_CAPMIX_NOSRC(1);
2752DEFINE_CAPMIX_NOSRC(2);
2753DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002754
2755/*
2756 * ALC880 5-stack model
2757 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002758 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2759 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002760 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2761 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2762 */
2763
2764/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002765static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002766 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002767 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002768 { } /* end */
2769};
2770
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002771/* channel source setting (6/8 channel selection for 5-stack) */
2772/* 6ch mode */
2773static struct hda_verb alc880_fivestack_ch6_init[] = {
2774 /* set line-in to input, mute it */
2775 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2776 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002777 { } /* end */
2778};
2779
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002780/* 8ch mode */
2781static struct hda_verb alc880_fivestack_ch8_init[] = {
2782 /* set line-in to output, unmute it */
2783 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2784 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2785 { } /* end */
2786};
2787
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002788static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002789 { 6, alc880_fivestack_ch6_init },
2790 { 8, alc880_fivestack_ch8_init },
2791};
2792
2793
2794/*
2795 * ALC880 6-stack model
2796 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002797 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2798 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002799 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2800 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2801 */
2802
2803static hda_nid_t alc880_6st_dac_nids[4] = {
2804 /* front, rear, clfe, rear_surr */
2805 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002806};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002807
2808static struct hda_input_mux alc880_6stack_capture_source = {
2809 .num_items = 4,
2810 .items = {
2811 { "Mic", 0x0 },
2812 { "Front Mic", 0x1 },
2813 { "Line", 0x2 },
2814 { "CD", 0x4 },
2815 },
2816};
2817
2818/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002819static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002820 { 8, NULL },
2821};
2822
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002823static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002824 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002825 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002826 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002827 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002828 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2829 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002830 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2831 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002832 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002833 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002834 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2835 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2836 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2837 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2838 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2839 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2840 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2841 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002842 {
2843 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2844 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002845 .info = alc_ch_mode_info,
2846 .get = alc_ch_mode_get,
2847 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002848 },
2849 { } /* end */
2850};
2851
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002852
2853/*
2854 * ALC880 W810 model
2855 *
2856 * W810 has rear IO for:
2857 * Front (DAC 02)
2858 * Surround (DAC 03)
2859 * Center/LFE (DAC 04)
2860 * Digital out (06)
2861 *
2862 * The system also has a pair of internal speakers, and a headphone jack.
2863 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002864 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002865 * There is a variable resistor to control the speaker or headphone
2866 * volume. This is a hardware-only device without a software API.
2867 *
2868 * Plugging headphones in will disable the internal speakers. This is
2869 * implemented in hardware, not via the driver using jack sense. In
2870 * a similar fashion, plugging into the rear socket marked "front" will
2871 * disable both the speakers and headphones.
2872 *
2873 * For input, there's a microphone jack, and an "audio in" jack.
2874 * These may not do anything useful with this driver yet, because I
2875 * haven't setup any initialization verbs for these yet...
2876 */
2877
2878static hda_nid_t alc880_w810_dac_nids[3] = {
2879 /* front, rear/surround, clfe */
2880 0x02, 0x03, 0x04
2881};
2882
2883/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002884static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002885 { 6, NULL }
2886};
2887
2888/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002889static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002890 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002891 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002892 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002893 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002894 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2895 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002896 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2897 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002898 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2899 { } /* end */
2900};
2901
2902
2903/*
2904 * Z710V model
2905 *
2906 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002907 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2908 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002909 */
2910
2911static hda_nid_t alc880_z71v_dac_nids[1] = {
2912 0x02
2913};
2914#define ALC880_Z71V_HP_DAC 0x03
2915
2916/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002917static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002918 { 2, NULL }
2919};
2920
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002921static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002922 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002923 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002924 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002925 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002926 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2927 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2928 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2929 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2930 { } /* end */
2931};
2932
2933
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002934/*
2935 * ALC880 F1734 model
2936 *
2937 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2938 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2939 */
2940
2941static hda_nid_t alc880_f1734_dac_nids[1] = {
2942 0x03
2943};
2944#define ALC880_F1734_HP_DAC 0x02
2945
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002946static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002947 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002948 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002949 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2950 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002951 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2952 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002953 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2954 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002955 { } /* end */
2956};
2957
Takashi Iwai937b4162008-02-11 14:52:36 +01002958static struct hda_input_mux alc880_f1734_capture_source = {
2959 .num_items = 2,
2960 .items = {
2961 { "Mic", 0x1 },
2962 { "CD", 0x4 },
2963 },
2964};
2965
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002966
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002967/*
2968 * ALC880 ASUS model
2969 *
2970 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2971 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2972 * Mic = 0x18, Line = 0x1a
2973 */
2974
2975#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2976#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2977
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002978static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002979 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002980 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002981 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002982 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002983 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2984 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002985 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2986 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002987 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2988 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2989 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2990 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2991 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2992 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002993 {
2994 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2995 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002996 .info = alc_ch_mode_info,
2997 .get = alc_ch_mode_get,
2998 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002999 },
3000 { } /* end */
3001};
3002
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003003/*
3004 * ALC880 ASUS W1V model
3005 *
3006 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
3007 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
3008 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
3009 */
3010
3011/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003012static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02003013 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
3014 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003015 { } /* end */
3016};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003017
Kailang Yangdf694da2005-12-05 19:42:22 +01003018/* TCL S700 */
3019static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
3020 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3021 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
3022 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
3023 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
3024 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
3025 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
3026 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
3027 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
3028 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003029 { } /* end */
3030};
3031
Kailang Yangccc656c2006-10-17 12:32:26 +02003032/* Uniwill */
3033static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003034 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3035 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
3036 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3037 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02003038 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3039 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3040 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3041 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3042 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
3043 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
3044 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3045 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
3046 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3047 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3048 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3049 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02003050 {
3051 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3052 .name = "Channel Mode",
3053 .info = alc_ch_mode_info,
3054 .get = alc_ch_mode_get,
3055 .put = alc_ch_mode_put,
3056 },
3057 { } /* end */
3058};
3059
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003060static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
3061 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3062 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
3063 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3064 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
3065 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
3066 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson8607f7c2010-12-20 14:43:54 +01003067 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3068 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01003069 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3070 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003071 { } /* end */
3072};
3073
Kailang Yangccc656c2006-10-17 12:32:26 +02003074static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003075 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3076 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
3077 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3078 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02003079 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3080 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3081 { } /* end */
3082};
3083
Linus Torvalds1da177e2005-04-16 15:20:36 -07003084/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01003085 * virtual master controls
3086 */
3087
3088/*
3089 * slave controls for virtual master
3090 */
Takashi Iwaiea734962011-01-17 11:29:34 +01003091static const char * const alc_slave_vols[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003092 "Front Playback Volume",
3093 "Surround Playback Volume",
3094 "Center Playback Volume",
3095 "LFE Playback Volume",
3096 "Side Playback Volume",
3097 "Headphone Playback Volume",
3098 "Speaker Playback Volume",
3099 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01003100 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01003101 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01003102 NULL,
3103};
3104
Takashi Iwaiea734962011-01-17 11:29:34 +01003105static const char * const alc_slave_sws[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003106 "Front Playback Switch",
3107 "Surround Playback Switch",
3108 "Center Playback Switch",
3109 "LFE Playback Switch",
3110 "Side Playback Switch",
3111 "Headphone Playback Switch",
3112 "Speaker Playback Switch",
3113 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01003114 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01003115 "Line-Out Playback Switch",
3116 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01003117 NULL,
3118};
3119
3120/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003121 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07003122 */
Takashi Iwai603c4012008-07-30 15:01:44 +02003123
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003124#define NID_MAPPING (-1)
3125
3126#define SUBDEV_SPEAKER_ (0 << 6)
3127#define SUBDEV_HP_ (1 << 6)
3128#define SUBDEV_LINE_ (2 << 6)
3129#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
3130#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
3131#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
3132
Takashi Iwai603c4012008-07-30 15:01:44 +02003133static void alc_free_kctls(struct hda_codec *codec);
3134
Takashi Iwai67d634c2009-11-16 15:35:59 +01003135#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003136/* additional beep mixers; the actual parameters are overwritten at build */
3137static struct snd_kcontrol_new alc_beep_mixer[] = {
3138 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003139 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003140 { } /* end */
3141};
Takashi Iwai67d634c2009-11-16 15:35:59 +01003142#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003143
Linus Torvalds1da177e2005-04-16 15:20:36 -07003144static int alc_build_controls(struct hda_codec *codec)
3145{
3146 struct alc_spec *spec = codec->spec;
Takashi Iwai2f44f842010-06-22 11:12:32 +02003147 struct snd_kcontrol *kctl = NULL;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003148 struct snd_kcontrol_new *knew;
3149 int i, j, err;
3150 unsigned int u;
3151 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003152
3153 for (i = 0; i < spec->num_mixers; i++) {
3154 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
3155 if (err < 0)
3156 return err;
3157 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003158 if (spec->cap_mixer) {
3159 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
3160 if (err < 0)
3161 return err;
3162 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003163 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003164 err = snd_hda_create_spdif_out_ctls(codec,
3165 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003166 if (err < 0)
3167 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003168 if (!spec->no_analog) {
3169 err = snd_hda_create_spdif_share_sw(codec,
3170 &spec->multiout);
3171 if (err < 0)
3172 return err;
3173 spec->multiout.share_spdif = 1;
3174 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003175 }
3176 if (spec->dig_in_nid) {
3177 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
3178 if (err < 0)
3179 return err;
3180 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01003181
Takashi Iwai67d634c2009-11-16 15:35:59 +01003182#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003183 /* create beep controls if needed */
3184 if (spec->beep_amp) {
3185 struct snd_kcontrol_new *knew;
3186 for (knew = alc_beep_mixer; knew->name; knew++) {
3187 struct snd_kcontrol *kctl;
3188 kctl = snd_ctl_new1(knew, codec);
3189 if (!kctl)
3190 return -ENOMEM;
3191 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01003192 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003193 if (err < 0)
3194 return err;
3195 }
3196 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01003197#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003198
Takashi Iwai2134ea42008-01-10 16:53:55 +01003199 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003200 if (!spec->no_analog &&
3201 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01003202 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01003203 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01003204 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01003205 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01003206 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01003207 if (err < 0)
3208 return err;
3209 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003210 if (!spec->no_analog &&
3211 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003212 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
3213 NULL, alc_slave_sws);
3214 if (err < 0)
3215 return err;
3216 }
3217
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003218 /* assign Capture Source enums to NID */
Takashi Iwaifbe618f2010-06-11 11:24:58 +02003219 if (spec->capsrc_nids || spec->adc_nids) {
3220 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
3221 if (!kctl)
3222 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
3223 for (i = 0; kctl && i < kctl->count; i++) {
3224 hda_nid_t *nids = spec->capsrc_nids;
3225 if (!nids)
3226 nids = spec->adc_nids;
3227 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
3228 if (err < 0)
3229 return err;
3230 }
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003231 }
3232 if (spec->cap_mixer) {
3233 const char *kname = kctl ? kctl->id.name : NULL;
3234 for (knew = spec->cap_mixer; knew->name; knew++) {
3235 if (kname && strcmp(knew->name, kname) == 0)
3236 continue;
3237 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3238 for (i = 0; kctl && i < kctl->count; i++) {
3239 err = snd_hda_add_nid(codec, kctl, i,
3240 spec->adc_nids[i]);
3241 if (err < 0)
3242 return err;
3243 }
3244 }
3245 }
3246
3247 /* other nid->control mapping */
3248 for (i = 0; i < spec->num_mixers; i++) {
3249 for (knew = spec->mixers[i]; knew->name; knew++) {
3250 if (knew->iface != NID_MAPPING)
3251 continue;
3252 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3253 if (kctl == NULL)
3254 continue;
3255 u = knew->subdevice;
3256 for (j = 0; j < 4; j++, u >>= 8) {
3257 nid = u & 0x3f;
3258 if (nid == 0)
3259 continue;
3260 switch (u & 0xc0) {
3261 case SUBDEV_SPEAKER_:
3262 nid = spec->autocfg.speaker_pins[nid];
3263 break;
3264 case SUBDEV_LINE_:
3265 nid = spec->autocfg.line_out_pins[nid];
3266 break;
3267 case SUBDEV_HP_:
3268 nid = spec->autocfg.hp_pins[nid];
3269 break;
3270 default:
3271 continue;
3272 }
3273 err = snd_hda_add_nid(codec, kctl, 0, nid);
3274 if (err < 0)
3275 return err;
3276 }
3277 u = knew->private_value;
3278 for (j = 0; j < 4; j++, u >>= 8) {
3279 nid = u & 0xff;
3280 if (nid == 0)
3281 continue;
3282 err = snd_hda_add_nid(codec, kctl, 0, nid);
3283 if (err < 0)
3284 return err;
3285 }
3286 }
3287 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01003288
3289 alc_free_kctls(codec); /* no longer needed */
3290
Linus Torvalds1da177e2005-04-16 15:20:36 -07003291 return 0;
3292}
3293
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003294
Linus Torvalds1da177e2005-04-16 15:20:36 -07003295/*
3296 * initialize the codec volumes, etc
3297 */
3298
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003299/*
3300 * generic initialization of ADC, input mixers and output mixers
3301 */
3302static struct hda_verb alc880_volume_init_verbs[] = {
3303 /*
3304 * Unmute ADC0-2 and set the default input to mic-in
3305 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003306 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003307 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003308 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003309 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003310 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003311 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003312
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003313 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3314 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003315 * Note: PASD motherboards uses the Line In 2 as the input for front
3316 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003317 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003318 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003319 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3320 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3321 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3322 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3323 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3324 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3325 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003326
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003327 /*
3328 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003329 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003330 /* set vol=0 to output mixers */
3331 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3332 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3333 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3334 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3335 /* set up input amps for analog loopback */
3336 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003337 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3338 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003339 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3340 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003341 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3342 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003343 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3344 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003345
3346 { }
3347};
3348
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003349/*
3350 * 3-stack pin configuration:
3351 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
3352 */
3353static struct hda_verb alc880_pin_3stack_init_verbs[] = {
3354 /*
3355 * preset connection lists of input pins
3356 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3357 */
3358 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3359 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3360 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3361
3362 /*
3363 * Set pin mode and muting
3364 */
3365 /* set front pin widgets 0x14 for output */
3366 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3367 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3368 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3369 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3370 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3371 /* Mic2 (as headphone out) for HP output */
3372 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3373 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3374 /* Line In pin widget for input */
3375 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3376 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3377 /* Line2 (as front mic) pin widget for input and vref at 80% */
3378 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3379 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3380 /* CD pin widget for input */
3381 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3382
3383 { }
3384};
3385
3386/*
3387 * 5-stack pin configuration:
3388 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
3389 * line-in/side = 0x1a, f-mic = 0x1b
3390 */
3391static struct hda_verb alc880_pin_5stack_init_verbs[] = {
3392 /*
3393 * preset connection lists of input pins
3394 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3395 */
3396 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3397 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
3398
3399 /*
3400 * Set pin mode and muting
3401 */
3402 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02003403 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3404 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3405 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3406 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003407 /* unmute pins for output (no gain on this amp) */
3408 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3409 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3410 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3411 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3412
Linus Torvalds1da177e2005-04-16 15:20:36 -07003413 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003414 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003415 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3416 /* Mic2 (as headphone out) for HP output */
3417 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003418 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003419 /* Line In pin widget for input */
3420 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3421 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3422 /* Line2 (as front mic) pin widget for input and vref at 80% */
3423 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3424 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3425 /* CD pin widget for input */
3426 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003427
3428 { }
3429};
3430
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003431/*
3432 * W810 pin configuration:
3433 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
3434 */
3435static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003436 /* hphone/speaker input selector: front DAC */
3437 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
3438
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003439 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3440 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3441 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3442 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3443 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3444 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3445
3446 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003447 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003448
Linus Torvalds1da177e2005-04-16 15:20:36 -07003449 { }
3450};
3451
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003452/*
3453 * Z71V pin configuration:
3454 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
3455 */
3456static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003457 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003458 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02003459 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003460 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003461
Takashi Iwai16ded522005-06-10 19:58:24 +02003462 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003463 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003464 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003465 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003466
3467 { }
3468};
3469
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003470/*
3471 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003472 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
3473 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003474 */
3475static struct hda_verb alc880_pin_6stack_init_verbs[] = {
3476 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3477
Takashi Iwai16ded522005-06-10 19:58:24 +02003478 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003479 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003480 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003481 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003482 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003483 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003484 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003485 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3486
Takashi Iwai16ded522005-06-10 19:58:24 +02003487 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003488 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003489 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003490 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003491 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003492 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003493 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02003494 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003495 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003496
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003497 { }
3498};
Takashi Iwai16ded522005-06-10 19:58:24 +02003499
Kailang Yangccc656c2006-10-17 12:32:26 +02003500/*
3501 * Uniwill pin configuration:
3502 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3503 * line = 0x1a
3504 */
3505static struct hda_verb alc880_uniwill_init_verbs[] = {
3506 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3507
3508 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3509 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3510 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3511 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3512 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3513 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3514 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3515 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3516 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3517 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3518 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3519 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3520 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3521 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3522
3523 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3524 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3525 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3526 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3527 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3528 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3529 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3530 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3531 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3532
3533 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3534 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3535
3536 { }
3537};
3538
3539/*
3540* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02003541* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02003542 */
3543static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3544 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3545
3546 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3547 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3548 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3549 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3550 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3551 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3552 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3553 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3554 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3555 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3556 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3557 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3558
3559 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3560 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3561 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3562 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3563 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3564 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3565
3566 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3567 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3568
3569 { }
3570};
3571
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003572static struct hda_verb alc880_beep_init_verbs[] = {
3573 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3574 { }
3575};
3576
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003577/* auto-toggle front mic */
Anisse Astiereeb43382010-12-16 12:19:47 +01003578static void alc88x_simple_mic_automute(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003579{
3580 unsigned int present;
3581 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02003582
Wu Fengguang864f92b2009-11-18 12:38:02 +08003583 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003584 bits = present ? HDA_AMP_MUTE : 0;
3585 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003586}
3587
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003588static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003589{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003590 struct alc_spec *spec = codec->spec;
3591
3592 spec->autocfg.hp_pins[0] = 0x14;
3593 spec->autocfg.speaker_pins[0] = 0x15;
3594 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwaid922b512011-04-28 12:18:53 +02003595 spec->automute = 1;
3596 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003597}
3598
3599static void alc880_uniwill_init_hook(struct hda_codec *codec)
3600{
Takashi Iwaid922b512011-04-28 12:18:53 +02003601 alc_hp_automute(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +01003602 alc88x_simple_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02003603}
3604
3605static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3606 unsigned int res)
3607{
3608 /* Looks like the unsol event is incompatible with the standard
3609 * definition. 4bit tag is placed at 28 bit!
3610 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003611 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003612 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +01003613 alc88x_simple_mic_automute(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003614 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003615 default:
Takashi Iwaid922b512011-04-28 12:18:53 +02003616 alc_sku_unsol_event(codec, res);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003617 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003618 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003619}
3620
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003621static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003622{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003623 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003624
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003625 spec->autocfg.hp_pins[0] = 0x14;
3626 spec->autocfg.speaker_pins[0] = 0x15;
Takashi Iwaid922b512011-04-28 12:18:53 +02003627 spec->automute = 1;
3628 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yangccc656c2006-10-17 12:32:26 +02003629}
3630
3631static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3632{
3633 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003634
Kailang Yangccc656c2006-10-17 12:32:26 +02003635 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003636 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3637 present &= HDA_AMP_VOLMASK;
3638 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3639 HDA_AMP_VOLMASK, present);
3640 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3641 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003642}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003643
Kailang Yangccc656c2006-10-17 12:32:26 +02003644static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3645 unsigned int res)
3646{
3647 /* Looks like the unsol event is incompatible with the standard
3648 * definition. 4bit tag is placed at 28 bit!
3649 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003650 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003651 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003652 else
Takashi Iwaid922b512011-04-28 12:18:53 +02003653 alc_sku_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003654}
3655
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003656/*
3657 * F1734 pin configuration:
3658 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3659 */
3660static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003661 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003662 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3663 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3664 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3665 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3666
3667 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3668 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3669 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3670 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3671
3672 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3673 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003674 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003675 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3676 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3677 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3678 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3679 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3680 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003681
Takashi Iwai937b4162008-02-11 14:52:36 +01003682 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3683 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3684
Takashi Iwai16ded522005-06-10 19:58:24 +02003685 { }
3686};
3687
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003688/*
3689 * ASUS pin configuration:
3690 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3691 */
3692static struct hda_verb alc880_pin_asus_init_verbs[] = {
3693 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3694 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3695 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3696 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3697
3698 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3699 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3700 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3701 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3702 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3703 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3704 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3705 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3706
3707 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3708 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3709 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3710 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3711 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3712 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3713 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3714 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3715 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003716
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003717 { }
3718};
3719
3720/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003721#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3722#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003723#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003724
Kailang Yangdf694da2005-12-05 19:42:22 +01003725/* Clevo m520g init */
3726static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3727 /* headphone output */
3728 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3729 /* line-out */
3730 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3731 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3732 /* Line-in */
3733 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3734 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3735 /* CD */
3736 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3737 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3738 /* Mic1 (rear panel) */
3739 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3740 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3741 /* Mic2 (front panel) */
3742 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3743 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3744 /* headphone */
3745 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3746 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3747 /* change to EAPD mode */
3748 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3749 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3750
3751 { }
3752};
3753
3754static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003755 /* change to EAPD mode */
3756 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3757 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3758
Kailang Yangdf694da2005-12-05 19:42:22 +01003759 /* Headphone output */
3760 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3761 /* Front output*/
3762 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3763 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3764
3765 /* Line In pin widget for input */
3766 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3767 /* CD pin widget for input */
3768 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3769 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3770 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3771
3772 /* change to EAPD mode */
3773 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3774 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3775
3776 { }
3777};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003778
3779/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003780 * LG m1 express dual
3781 *
3782 * Pin assignment:
3783 * Rear Line-In/Out (blue): 0x14
3784 * Build-in Mic-In: 0x15
3785 * Speaker-out: 0x17
3786 * HP-Out (green): 0x1b
3787 * Mic-In/Out (red): 0x19
3788 * SPDIF-Out: 0x1e
3789 */
3790
3791/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3792static hda_nid_t alc880_lg_dac_nids[3] = {
3793 0x05, 0x02, 0x03
3794};
3795
3796/* seems analog CD is not working */
3797static struct hda_input_mux alc880_lg_capture_source = {
3798 .num_items = 3,
3799 .items = {
3800 { "Mic", 0x1 },
3801 { "Line", 0x5 },
3802 { "Internal Mic", 0x6 },
3803 },
3804};
3805
3806/* 2,4,6 channel modes */
3807static struct hda_verb alc880_lg_ch2_init[] = {
3808 /* set line-in and mic-in to input */
3809 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3810 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3811 { }
3812};
3813
3814static struct hda_verb alc880_lg_ch4_init[] = {
3815 /* set line-in to out and mic-in to input */
3816 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3817 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3818 { }
3819};
3820
3821static struct hda_verb alc880_lg_ch6_init[] = {
3822 /* set line-in and mic-in to output */
3823 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3824 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3825 { }
3826};
3827
3828static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3829 { 2, alc880_lg_ch2_init },
3830 { 4, alc880_lg_ch4_init },
3831 { 6, alc880_lg_ch6_init },
3832};
3833
3834static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003835 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3836 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003837 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3838 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3839 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3840 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3841 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3842 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3843 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3844 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3845 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3846 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3847 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3848 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3849 {
3850 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3851 .name = "Channel Mode",
3852 .info = alc_ch_mode_info,
3853 .get = alc_ch_mode_get,
3854 .put = alc_ch_mode_put,
3855 },
3856 { } /* end */
3857};
3858
3859static struct hda_verb alc880_lg_init_verbs[] = {
3860 /* set capture source to mic-in */
3861 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3862 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3863 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3864 /* mute all amp mixer inputs */
3865 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003866 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3867 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003868 /* line-in to input */
3869 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3870 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3871 /* built-in mic */
3872 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3873 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3874 /* speaker-out */
3875 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3876 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3877 /* mic-in to input */
3878 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3879 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3880 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3881 /* HP-out */
3882 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3883 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3884 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3885 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003886 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003887 { }
3888};
3889
3890/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003891static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003892{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003893 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003894
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003895 spec->autocfg.hp_pins[0] = 0x1b;
3896 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02003897 spec->automute = 1;
3898 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003899}
3900
3901/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003902 * LG LW20
3903 *
3904 * Pin assignment:
3905 * Speaker-out: 0x14
3906 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003907 * Built-in Mic-In: 0x19
3908 * Line-In: 0x1b
3909 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003910 * SPDIF-Out: 0x1e
3911 */
3912
Takashi Iwaid6815182006-03-23 16:06:23 +01003913static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003914 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003915 .items = {
3916 { "Mic", 0x0 },
3917 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003918 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003919 },
3920};
3921
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003922#define alc880_lg_lw_modes alc880_threestack_modes
3923
Takashi Iwaid6815182006-03-23 16:06:23 +01003924static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003925 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3926 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3927 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3928 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3929 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3930 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3931 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3932 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3933 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3934 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003935 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3936 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3937 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3938 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003939 {
3940 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3941 .name = "Channel Mode",
3942 .info = alc_ch_mode_info,
3943 .get = alc_ch_mode_get,
3944 .put = alc_ch_mode_put,
3945 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003946 { } /* end */
3947};
3948
3949static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003950 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3951 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3952 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3953
Takashi Iwaid6815182006-03-23 16:06:23 +01003954 /* set capture source to mic-in */
3955 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3956 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3957 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003958 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003959 /* speaker-out */
3960 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3961 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3962 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003963 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3964 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3965 /* mic-in to input */
3966 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3967 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3968 /* built-in mic */
3969 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3970 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3971 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003972 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003973 { }
3974};
3975
3976/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003977static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003978{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003979 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003980
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003981 spec->autocfg.hp_pins[0] = 0x1b;
3982 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +02003983 spec->automute = 1;
3984 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwaid6815182006-03-23 16:06:23 +01003985}
3986
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003987static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3988 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3989 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3990 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3991 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3992 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3993 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3994 { } /* end */
3995};
3996
3997static struct hda_input_mux alc880_medion_rim_capture_source = {
3998 .num_items = 2,
3999 .items = {
4000 { "Mic", 0x0 },
4001 { "Internal Mic", 0x1 },
4002 },
4003};
4004
4005static struct hda_verb alc880_medion_rim_init_verbs[] = {
4006 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
4007
4008 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4009 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4010
4011 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4012 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4013 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4014 /* Mic2 (as headphone out) for HP output */
4015 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4016 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4017 /* Internal Speaker */
4018 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4019 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4020
4021 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
4022 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
4023
4024 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4025 { }
4026};
4027
4028/* toggle speaker-output according to the hp-jack state */
4029static void alc880_medion_rim_automute(struct hda_codec *codec)
4030{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004031 struct alc_spec *spec = codec->spec;
Takashi Iwaid922b512011-04-28 12:18:53 +02004032 alc_hp_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004033 /* toggle EAPD */
4034 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004035 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
4036 else
4037 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
4038}
4039
4040static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
4041 unsigned int res)
4042{
4043 /* Looks like the unsol event is incompatible with the standard
4044 * definition. 4bit tag is placed at 28 bit!
4045 */
4046 if ((res >> 28) == ALC880_HP_EVENT)
4047 alc880_medion_rim_automute(codec);
4048}
4049
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004050static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004051{
4052 struct alc_spec *spec = codec->spec;
4053
4054 spec->autocfg.hp_pins[0] = 0x14;
4055 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaid922b512011-04-28 12:18:53 +02004056 spec->automute = 1;
4057 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004058}
4059
Takashi Iwaicb53c622007-08-10 17:21:45 +02004060#ifdef CONFIG_SND_HDA_POWER_SAVE
4061static struct hda_amp_list alc880_loopbacks[] = {
4062 { 0x0b, HDA_INPUT, 0 },
4063 { 0x0b, HDA_INPUT, 1 },
4064 { 0x0b, HDA_INPUT, 2 },
4065 { 0x0b, HDA_INPUT, 3 },
4066 { 0x0b, HDA_INPUT, 4 },
4067 { } /* end */
4068};
4069
4070static struct hda_amp_list alc880_lg_loopbacks[] = {
4071 { 0x0b, HDA_INPUT, 1 },
4072 { 0x0b, HDA_INPUT, 6 },
4073 { 0x0b, HDA_INPUT, 7 },
4074 { } /* end */
4075};
4076#endif
4077
Takashi Iwaid6815182006-03-23 16:06:23 +01004078/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004079 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004080 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004081
Takashi Iwai584c0c42011-03-10 12:51:11 +01004082static void alc_init_special_input_src(struct hda_codec *codec);
4083
Linus Torvalds1da177e2005-04-16 15:20:36 -07004084static int alc_init(struct hda_codec *codec)
4085{
4086 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004087 unsigned int i;
4088
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02004089 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004090 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02004091
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004092 for (i = 0; i < spec->num_init_verbs; i++)
4093 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwai584c0c42011-03-10 12:51:11 +01004094 alc_init_special_input_src(codec);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004095
4096 if (spec->init_hook)
4097 spec->init_hook(codec);
4098
Takashi Iwai58701122011-01-13 15:41:45 +01004099 alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT);
4100
Takashi Iwai9e5341b2010-09-21 09:57:06 +02004101 hda_call_check_power_status(codec, 0x01);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004102 return 0;
4103}
4104
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004105static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
4106{
4107 struct alc_spec *spec = codec->spec;
4108
4109 if (spec->unsol_event)
4110 spec->unsol_event(codec, res);
4111}
4112
Takashi Iwaicb53c622007-08-10 17:21:45 +02004113#ifdef CONFIG_SND_HDA_POWER_SAVE
4114static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
4115{
4116 struct alc_spec *spec = codec->spec;
4117 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
4118}
4119#endif
4120
Linus Torvalds1da177e2005-04-16 15:20:36 -07004121/*
4122 * Analog playback callbacks
4123 */
4124static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
4125 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004126 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004127{
4128 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01004129 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
4130 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004131}
4132
4133static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
4134 struct hda_codec *codec,
4135 unsigned int stream_tag,
4136 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004137 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004138{
4139 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004140 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
4141 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004142}
4143
4144static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
4145 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004146 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004147{
4148 struct alc_spec *spec = codec->spec;
4149 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
4150}
4151
4152/*
4153 * Digital out
4154 */
4155static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
4156 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004157 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004158{
4159 struct alc_spec *spec = codec->spec;
4160 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
4161}
4162
Takashi Iwai6b97eb42007-04-05 14:51:48 +02004163static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
4164 struct hda_codec *codec,
4165 unsigned int stream_tag,
4166 unsigned int format,
4167 struct snd_pcm_substream *substream)
4168{
4169 struct alc_spec *spec = codec->spec;
4170 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
4171 stream_tag, format, substream);
4172}
4173
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01004174static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
4175 struct hda_codec *codec,
4176 struct snd_pcm_substream *substream)
4177{
4178 struct alc_spec *spec = codec->spec;
4179 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
4180}
4181
Linus Torvalds1da177e2005-04-16 15:20:36 -07004182static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
4183 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004184 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004185{
4186 struct alc_spec *spec = codec->spec;
4187 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
4188}
4189
4190/*
4191 * Analog capture
4192 */
Takashi Iwai63300792008-01-24 15:31:36 +01004193static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004194 struct hda_codec *codec,
4195 unsigned int stream_tag,
4196 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004197 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004198{
4199 struct alc_spec *spec = codec->spec;
4200
Takashi Iwai63300792008-01-24 15:31:36 +01004201 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07004202 stream_tag, 0, format);
4203 return 0;
4204}
4205
Takashi Iwai63300792008-01-24 15:31:36 +01004206static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004207 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004208 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004209{
4210 struct alc_spec *spec = codec->spec;
4211
Takashi Iwai888afa12008-03-18 09:57:50 +01004212 snd_hda_codec_cleanup_stream(codec,
4213 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004214 return 0;
4215}
4216
Takashi Iwai840b64c2010-07-13 22:49:01 +02004217/* analog capture with dynamic dual-adc changes */
4218static int dualmic_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
4219 struct hda_codec *codec,
4220 unsigned int stream_tag,
4221 unsigned int format,
4222 struct snd_pcm_substream *substream)
4223{
4224 struct alc_spec *spec = codec->spec;
4225 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
4226 spec->cur_adc_stream_tag = stream_tag;
4227 spec->cur_adc_format = format;
4228 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
4229 return 0;
4230}
4231
4232static int dualmic_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
4233 struct hda_codec *codec,
4234 struct snd_pcm_substream *substream)
4235{
4236 struct alc_spec *spec = codec->spec;
4237 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
4238 spec->cur_adc = 0;
4239 return 0;
4240}
4241
4242static struct hda_pcm_stream dualmic_pcm_analog_capture = {
4243 .substreams = 1,
4244 .channels_min = 2,
4245 .channels_max = 2,
4246 .nid = 0, /* fill later */
4247 .ops = {
4248 .prepare = dualmic_capture_pcm_prepare,
4249 .cleanup = dualmic_capture_pcm_cleanup
4250 },
4251};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004252
4253/*
4254 */
4255static struct hda_pcm_stream alc880_pcm_analog_playback = {
4256 .substreams = 1,
4257 .channels_min = 2,
4258 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004259 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004260 .ops = {
4261 .open = alc880_playback_pcm_open,
4262 .prepare = alc880_playback_pcm_prepare,
4263 .cleanup = alc880_playback_pcm_cleanup
4264 },
4265};
4266
4267static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01004268 .substreams = 1,
4269 .channels_min = 2,
4270 .channels_max = 2,
4271 /* NID is set in alc_build_pcms */
4272};
4273
4274static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
4275 .substreams = 1,
4276 .channels_min = 2,
4277 .channels_max = 2,
4278 /* NID is set in alc_build_pcms */
4279};
4280
4281static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
4282 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004283 .channels_min = 2,
4284 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004285 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004286 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01004287 .prepare = alc880_alt_capture_pcm_prepare,
4288 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004289 },
4290};
4291
4292static struct hda_pcm_stream alc880_pcm_digital_playback = {
4293 .substreams = 1,
4294 .channels_min = 2,
4295 .channels_max = 2,
4296 /* NID is set in alc_build_pcms */
4297 .ops = {
4298 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02004299 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01004300 .prepare = alc880_dig_playback_pcm_prepare,
4301 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004302 },
4303};
4304
4305static struct hda_pcm_stream alc880_pcm_digital_capture = {
4306 .substreams = 1,
4307 .channels_min = 2,
4308 .channels_max = 2,
4309 /* NID is set in alc_build_pcms */
4310};
4311
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004312/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01004313static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004314 .substreams = 0,
4315 .channels_min = 0,
4316 .channels_max = 0,
4317};
4318
Linus Torvalds1da177e2005-04-16 15:20:36 -07004319static int alc_build_pcms(struct hda_codec *codec)
4320{
4321 struct alc_spec *spec = codec->spec;
4322 struct hda_pcm *info = spec->pcm_rec;
4323 int i;
4324
4325 codec->num_pcms = 1;
4326 codec->pcm_info = info;
4327
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004328 if (spec->no_analog)
4329 goto skip_analog;
4330
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004331 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
4332 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004333 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01004334
Takashi Iwai4a471b72005-12-07 13:56:29 +01004335 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004336 if (snd_BUG_ON(!spec->multiout.dac_nids))
4337 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004338 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
4339 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
4340 }
4341 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004342 if (snd_BUG_ON(!spec->adc_nids))
4343 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004344 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
4345 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
4346 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004347
Takashi Iwai4a471b72005-12-07 13:56:29 +01004348 if (spec->channel_mode) {
4349 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
4350 for (i = 0; i < spec->num_channel_mode; i++) {
4351 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
4352 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
4353 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004354 }
4355 }
4356
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004357 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02004358 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004359 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004360 snprintf(spec->stream_name_digital,
4361 sizeof(spec->stream_name_digital),
4362 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02004363 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08004364 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004365 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004366 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01004367 if (spec->dig_out_type)
4368 info->pcm_type = spec->dig_out_type;
4369 else
4370 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004371 if (spec->multiout.dig_out_nid &&
4372 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004373 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
4374 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
4375 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004376 if (spec->dig_in_nid &&
4377 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004378 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
4379 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
4380 }
Takashi Iwai963f8032008-08-11 10:04:40 +02004381 /* FIXME: do we need this for all Realtek codec models? */
4382 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004383 }
4384
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004385 if (spec->no_analog)
4386 return 0;
4387
Takashi Iwaie08a0072006-09-07 17:52:14 +02004388 /* If the use of more than one ADC is requested for the current
4389 * model, configure a second analog capture-only PCM.
4390 */
4391 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01004392 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
4393 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02004394 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004395 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004396 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01004397 if (spec->alt_dac_nid) {
4398 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4399 *spec->stream_analog_alt_playback;
4400 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
4401 spec->alt_dac_nid;
4402 } else {
4403 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4404 alc_pcm_null_stream;
4405 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
4406 }
4407 if (spec->num_adc_nids > 1) {
4408 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4409 *spec->stream_analog_alt_capture;
4410 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
4411 spec->adc_nids[1];
4412 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
4413 spec->num_adc_nids - 1;
4414 } else {
4415 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4416 alc_pcm_null_stream;
4417 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004418 }
4419 }
4420
Linus Torvalds1da177e2005-04-16 15:20:36 -07004421 return 0;
4422}
4423
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004424static inline void alc_shutup(struct hda_codec *codec)
4425{
Takashi Iwai1c716152011-04-07 10:37:16 +02004426 struct alc_spec *spec = codec->spec;
4427
4428 if (spec && spec->shutup)
4429 spec->shutup(codec);
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004430 snd_hda_shutup_pins(codec);
4431}
4432
Takashi Iwai603c4012008-07-30 15:01:44 +02004433static void alc_free_kctls(struct hda_codec *codec)
4434{
4435 struct alc_spec *spec = codec->spec;
4436
4437 if (spec->kctls.list) {
4438 struct snd_kcontrol_new *kctl = spec->kctls.list;
4439 int i;
4440 for (i = 0; i < spec->kctls.used; i++)
4441 kfree(kctl[i].name);
4442 }
4443 snd_array_free(&spec->kctls);
4444}
4445
Linus Torvalds1da177e2005-04-16 15:20:36 -07004446static void alc_free(struct hda_codec *codec)
4447{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004448 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004449
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004450 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004451 return;
4452
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004453 alc_shutup(codec);
Takashi Iwaicd372fb2011-03-03 14:40:14 +01004454 snd_hda_input_jack_free(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02004455 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004456 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004457 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004458}
4459
Hector Martinf5de24b2009-12-20 22:51:31 +01004460#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05004461static void alc_power_eapd(struct hda_codec *codec)
4462{
Takashi Iwai691f1fc2011-04-07 10:31:43 +02004463 alc_auto_setup_eapd(codec, false);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004464}
4465
Hector Martinf5de24b2009-12-20 22:51:31 +01004466static int alc_suspend(struct hda_codec *codec, pm_message_t state)
4467{
4468 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004469 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004470 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05004471 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004472 return 0;
4473}
4474#endif
4475
Takashi Iwaie044c392008-10-27 16:56:24 +01004476#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01004477static int alc_resume(struct hda_codec *codec)
4478{
Takashi Iwai1c716152011-04-07 10:37:16 +02004479 msleep(150); /* to avoid pop noise */
Takashi Iwaie044c392008-10-27 16:56:24 +01004480 codec->patch_ops.init(codec);
4481 snd_hda_codec_resume_amp(codec);
4482 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +02004483 hda_call_check_power_status(codec, 0x01);
Takashi Iwaie044c392008-10-27 16:56:24 +01004484 return 0;
4485}
Takashi Iwaie044c392008-10-27 16:56:24 +01004486#endif
4487
Linus Torvalds1da177e2005-04-16 15:20:36 -07004488/*
4489 */
4490static struct hda_codec_ops alc_patch_ops = {
4491 .build_controls = alc_build_controls,
4492 .build_pcms = alc_build_pcms,
4493 .init = alc_init,
4494 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004495 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01004496#ifdef SND_HDA_NEEDS_RESUME
4497 .resume = alc_resume,
4498#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02004499#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01004500 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004501 .check_power_status = alc_check_power_status,
4502#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05004503 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004504};
4505
Kailang Yangc027ddc2010-03-19 11:33:06 +01004506/* replace the codec chip_name with the given string */
4507static int alc_codec_rename(struct hda_codec *codec, const char *name)
4508{
4509 kfree(codec->chip_name);
4510 codec->chip_name = kstrdup(name, GFP_KERNEL);
4511 if (!codec->chip_name) {
4512 alc_free(codec);
4513 return -ENOMEM;
4514 }
4515 return 0;
4516}
4517
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004518/*
4519 * Test configuration for debugging
4520 *
4521 * Almost all inputs/outputs are enabled. I/O pins can be configured via
4522 * enum controls.
4523 */
4524#ifdef CONFIG_SND_DEBUG
4525static hda_nid_t alc880_test_dac_nids[4] = {
4526 0x02, 0x03, 0x04, 0x05
4527};
4528
4529static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004530 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004531 .items = {
4532 { "In-1", 0x0 },
4533 { "In-2", 0x1 },
4534 { "In-3", 0x2 },
4535 { "In-4", 0x3 },
4536 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004537 { "Front", 0x5 },
4538 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004539 },
4540};
4541
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004542static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004543 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004544 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004545 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004546 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004547};
4548
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004549static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
4550 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004551{
4552 static char *texts[] = {
4553 "N/A", "Line Out", "HP Out",
4554 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
4555 };
4556 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4557 uinfo->count = 1;
4558 uinfo->value.enumerated.items = 8;
4559 if (uinfo->value.enumerated.item >= 8)
4560 uinfo->value.enumerated.item = 7;
4561 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4562 return 0;
4563}
4564
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004565static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
4566 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004567{
4568 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4569 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4570 unsigned int pin_ctl, item = 0;
4571
4572 pin_ctl = snd_hda_codec_read(codec, nid, 0,
4573 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4574 if (pin_ctl & AC_PINCTL_OUT_EN) {
4575 if (pin_ctl & AC_PINCTL_HP_EN)
4576 item = 2;
4577 else
4578 item = 1;
4579 } else if (pin_ctl & AC_PINCTL_IN_EN) {
4580 switch (pin_ctl & AC_PINCTL_VREFEN) {
4581 case AC_PINCTL_VREF_HIZ: item = 3; break;
4582 case AC_PINCTL_VREF_50: item = 4; break;
4583 case AC_PINCTL_VREF_GRD: item = 5; break;
4584 case AC_PINCTL_VREF_80: item = 6; break;
4585 case AC_PINCTL_VREF_100: item = 7; break;
4586 }
4587 }
4588 ucontrol->value.enumerated.item[0] = item;
4589 return 0;
4590}
4591
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004592static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
4593 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004594{
4595 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4596 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4597 static unsigned int ctls[] = {
4598 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
4599 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
4600 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
4601 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
4602 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
4603 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
4604 };
4605 unsigned int old_ctl, new_ctl;
4606
4607 old_ctl = snd_hda_codec_read(codec, nid, 0,
4608 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4609 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
4610 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004611 int val;
4612 snd_hda_codec_write_cache(codec, nid, 0,
4613 AC_VERB_SET_PIN_WIDGET_CONTROL,
4614 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02004615 val = ucontrol->value.enumerated.item[0] >= 3 ?
4616 HDA_AMP_MUTE : 0;
4617 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
4618 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004619 return 1;
4620 }
4621 return 0;
4622}
4623
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004624static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
4625 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004626{
4627 static char *texts[] = {
4628 "Front", "Surround", "CLFE", "Side"
4629 };
4630 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4631 uinfo->count = 1;
4632 uinfo->value.enumerated.items = 4;
4633 if (uinfo->value.enumerated.item >= 4)
4634 uinfo->value.enumerated.item = 3;
4635 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4636 return 0;
4637}
4638
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004639static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
4640 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004641{
4642 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4643 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4644 unsigned int sel;
4645
4646 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4647 ucontrol->value.enumerated.item[0] = sel & 3;
4648 return 0;
4649}
4650
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004651static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4652 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004653{
4654 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4655 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4656 unsigned int sel;
4657
4658 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4659 if (ucontrol->value.enumerated.item[0] != sel) {
4660 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004661 snd_hda_codec_write_cache(codec, nid, 0,
4662 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004663 return 1;
4664 }
4665 return 0;
4666}
4667
4668#define PIN_CTL_TEST(xname,nid) { \
4669 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4670 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004671 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004672 .info = alc_test_pin_ctl_info, \
4673 .get = alc_test_pin_ctl_get, \
4674 .put = alc_test_pin_ctl_put, \
4675 .private_value = nid \
4676 }
4677
4678#define PIN_SRC_TEST(xname,nid) { \
4679 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4680 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004681 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004682 .info = alc_test_pin_src_info, \
4683 .get = alc_test_pin_src_get, \
4684 .put = alc_test_pin_src_put, \
4685 .private_value = nid \
4686 }
4687
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004688static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004689 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4690 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4691 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4692 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004693 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4694 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4695 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4696 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004697 PIN_CTL_TEST("Front Pin Mode", 0x14),
4698 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4699 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4700 PIN_CTL_TEST("Side Pin Mode", 0x17),
4701 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4702 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4703 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4704 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4705 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4706 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4707 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4708 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4709 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4710 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4711 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4712 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4713 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4714 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4715 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4716 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4717 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4718 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004719 {
4720 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4721 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004722 .info = alc_ch_mode_info,
4723 .get = alc_ch_mode_get,
4724 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004725 },
4726 { } /* end */
4727};
4728
4729static struct hda_verb alc880_test_init_verbs[] = {
4730 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004731 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4732 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4733 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4734 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4735 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4736 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4737 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4738 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004739 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004740 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4741 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4742 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4743 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004744 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004745 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4746 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4747 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4748 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004749 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004750 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4751 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4752 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4753 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004754 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004755 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4756 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004757 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4758 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4759 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004760 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004761 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4762 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4763 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4764 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004765 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004766 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004767 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004768 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004769 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004770 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004771 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004772 /* Analog input/passthru */
4773 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4774 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4775 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4776 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4777 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004778 { }
4779};
4780#endif
4781
Linus Torvalds1da177e2005-04-16 15:20:36 -07004782/*
4783 */
4784
Takashi Iwaiea734962011-01-17 11:29:34 +01004785static const char * const alc880_models[ALC880_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004786 [ALC880_3ST] = "3stack",
4787 [ALC880_TCL_S700] = "tcl",
4788 [ALC880_3ST_DIG] = "3stack-digout",
4789 [ALC880_CLEVO] = "clevo",
4790 [ALC880_5ST] = "5stack",
4791 [ALC880_5ST_DIG] = "5stack-digout",
4792 [ALC880_W810] = "w810",
4793 [ALC880_Z71V] = "z71v",
4794 [ALC880_6ST] = "6stack",
4795 [ALC880_6ST_DIG] = "6stack-digout",
4796 [ALC880_ASUS] = "asus",
4797 [ALC880_ASUS_W1V] = "asus-w1v",
4798 [ALC880_ASUS_DIG] = "asus-dig",
4799 [ALC880_ASUS_DIG2] = "asus-dig2",
4800 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004801 [ALC880_UNIWILL_P53] = "uniwill-p53",
4802 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004803 [ALC880_F1734] = "F1734",
4804 [ALC880_LG] = "lg",
4805 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004806 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004807#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004808 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004809#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004810 [ALC880_AUTO] = "auto",
4811};
4812
4813static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004814 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004815 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4816 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4817 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4818 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4819 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4820 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4821 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4822 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004823 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4824 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004825 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4826 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4827 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4828 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4829 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4830 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4831 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4832 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4833 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4834 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004835 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004836 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4837 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4838 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004839 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004840 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004841 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4842 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004843 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4844 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004845 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4846 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4847 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4848 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004849 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4850 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004851 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004852 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004853 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Justin P. Mattocka2e2bc22011-02-24 22:16:02 -08004854 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004855 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4856 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004857 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004858 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004859 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004860 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004861 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004862 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Daniel T Chen33535412010-04-22 07:15:26 -04004863 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004864 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004865 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004866 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
Daniel T Chen77c4d5c2010-12-02 22:45:45 -05004867 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004868 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004869 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004870 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4871 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4872 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4873 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004874 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4875 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004876 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004877 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004878 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4879 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004880 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4881 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4882 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004883 /* default Intel */
4884 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004885 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4886 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004887 {}
4888};
4889
Takashi Iwai16ded522005-06-10 19:58:24 +02004890/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004891 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004892 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004893static struct alc_config_preset alc880_presets[] = {
4894 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004895 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004896 .init_verbs = { alc880_volume_init_verbs,
4897 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004898 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004899 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004900 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4901 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004902 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004903 .input_mux = &alc880_capture_source,
4904 },
4905 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004906 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004907 .init_verbs = { alc880_volume_init_verbs,
4908 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004909 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004910 .dac_nids = alc880_dac_nids,
4911 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004912 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4913 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004914 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004915 .input_mux = &alc880_capture_source,
4916 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004917 [ALC880_TCL_S700] = {
4918 .mixers = { alc880_tcl_s700_mixer },
4919 .init_verbs = { alc880_volume_init_verbs,
4920 alc880_pin_tcl_S700_init_verbs,
4921 alc880_gpio2_init_verbs },
4922 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4923 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004924 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4925 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004926 .hp_nid = 0x03,
4927 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4928 .channel_mode = alc880_2_jack_modes,
4929 .input_mux = &alc880_capture_source,
4930 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004931 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004932 .mixers = { alc880_three_stack_mixer,
4933 alc880_five_stack_mixer},
4934 .init_verbs = { alc880_volume_init_verbs,
4935 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004936 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4937 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004938 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4939 .channel_mode = alc880_fivestack_modes,
4940 .input_mux = &alc880_capture_source,
4941 },
4942 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004943 .mixers = { alc880_three_stack_mixer,
4944 alc880_five_stack_mixer },
4945 .init_verbs = { alc880_volume_init_verbs,
4946 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004947 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4948 .dac_nids = alc880_dac_nids,
4949 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004950 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4951 .channel_mode = alc880_fivestack_modes,
4952 .input_mux = &alc880_capture_source,
4953 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004954 [ALC880_6ST] = {
4955 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004956 .init_verbs = { alc880_volume_init_verbs,
4957 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004958 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4959 .dac_nids = alc880_6st_dac_nids,
4960 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4961 .channel_mode = alc880_sixstack_modes,
4962 .input_mux = &alc880_6stack_capture_source,
4963 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004964 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004965 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004966 .init_verbs = { alc880_volume_init_verbs,
4967 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004968 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4969 .dac_nids = alc880_6st_dac_nids,
4970 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004971 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4972 .channel_mode = alc880_sixstack_modes,
4973 .input_mux = &alc880_6stack_capture_source,
4974 },
4975 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004976 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004977 .init_verbs = { alc880_volume_init_verbs,
4978 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004979 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004980 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4981 .dac_nids = alc880_w810_dac_nids,
4982 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004983 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4984 .channel_mode = alc880_w810_modes,
4985 .input_mux = &alc880_capture_source,
4986 },
4987 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004988 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004989 .init_verbs = { alc880_volume_init_verbs,
4990 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004991 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4992 .dac_nids = alc880_z71v_dac_nids,
4993 .dig_out_nid = ALC880_DIGOUT_NID,
4994 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004995 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4996 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004997 .input_mux = &alc880_capture_source,
4998 },
4999 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005000 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005001 .init_verbs = { alc880_volume_init_verbs,
5002 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005003 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
5004 .dac_nids = alc880_f1734_dac_nids,
5005 .hp_nid = 0x02,
5006 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
5007 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01005008 .input_mux = &alc880_f1734_capture_source,
5009 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02005010 .setup = alc880_uniwill_p53_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +02005011 .init_hook = alc_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02005012 },
5013 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005014 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005015 .init_verbs = { alc880_volume_init_verbs,
5016 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005017 alc880_gpio1_init_verbs },
5018 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
5019 .dac_nids = alc880_asus_dac_nids,
5020 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
5021 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005022 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02005023 .input_mux = &alc880_capture_source,
5024 },
5025 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005026 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005027 .init_verbs = { alc880_volume_init_verbs,
5028 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005029 alc880_gpio1_init_verbs },
5030 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
5031 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02005032 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005033 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
5034 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005035 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02005036 .input_mux = &alc880_capture_source,
5037 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005038 [ALC880_ASUS_DIG2] = {
5039 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005040 .init_verbs = { alc880_volume_init_verbs,
5041 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01005042 alc880_gpio2_init_verbs }, /* use GPIO2 */
5043 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
5044 .dac_nids = alc880_asus_dac_nids,
5045 .dig_out_nid = ALC880_DIGOUT_NID,
5046 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
5047 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005048 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01005049 .input_mux = &alc880_capture_source,
5050 },
Takashi Iwai16ded522005-06-10 19:58:24 +02005051 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005052 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005053 .init_verbs = { alc880_volume_init_verbs,
5054 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005055 alc880_gpio1_init_verbs },
5056 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
5057 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02005058 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005059 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
5060 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005061 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02005062 .input_mux = &alc880_capture_source,
5063 },
5064 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005065 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02005066 .init_verbs = { alc880_volume_init_verbs,
5067 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005068 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
5069 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02005070 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005071 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
5072 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005073 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02005074 .input_mux = &alc880_capture_source,
5075 },
Kailang Yangccc656c2006-10-17 12:32:26 +02005076 [ALC880_UNIWILL] = {
5077 .mixers = { alc880_uniwill_mixer },
5078 .init_verbs = { alc880_volume_init_verbs,
5079 alc880_uniwill_init_verbs },
5080 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
5081 .dac_nids = alc880_asus_dac_nids,
5082 .dig_out_nid = ALC880_DIGOUT_NID,
5083 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5084 .channel_mode = alc880_threestack_modes,
5085 .need_dac_fix = 1,
5086 .input_mux = &alc880_capture_source,
5087 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02005088 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02005089 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02005090 },
5091 [ALC880_UNIWILL_P53] = {
5092 .mixers = { alc880_uniwill_p53_mixer },
5093 .init_verbs = { alc880_volume_init_verbs,
5094 alc880_uniwill_p53_init_verbs },
5095 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
5096 .dac_nids = alc880_asus_dac_nids,
5097 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01005098 .channel_mode = alc880_threestack_modes,
5099 .input_mux = &alc880_capture_source,
5100 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02005101 .setup = alc880_uniwill_p53_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +02005102 .init_hook = alc_hp_automute,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01005103 },
5104 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005105 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01005106 .init_verbs = { alc880_volume_init_verbs,
5107 alc880_uniwill_p53_init_verbs,
5108 alc880_beep_init_verbs },
5109 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
5110 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02005111 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01005112 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
5113 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02005114 .input_mux = &alc880_capture_source,
5115 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02005116 .setup = alc880_uniwill_p53_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +02005117 .init_hook = alc_hp_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02005118 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005119 [ALC880_CLEVO] = {
5120 .mixers = { alc880_three_stack_mixer },
5121 .init_verbs = { alc880_volume_init_verbs,
5122 alc880_pin_clevo_init_verbs },
5123 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
5124 .dac_nids = alc880_dac_nids,
5125 .hp_nid = 0x03,
5126 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5127 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005128 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01005129 .input_mux = &alc880_capture_source,
5130 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005131 [ALC880_LG] = {
5132 .mixers = { alc880_lg_mixer },
5133 .init_verbs = { alc880_volume_init_verbs,
5134 alc880_lg_init_verbs },
5135 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
5136 .dac_nids = alc880_lg_dac_nids,
5137 .dig_out_nid = ALC880_DIGOUT_NID,
5138 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
5139 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005140 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005141 .input_mux = &alc880_lg_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +02005142 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02005143 .setup = alc880_lg_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +02005144 .init_hook = alc_hp_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02005145#ifdef CONFIG_SND_HDA_POWER_SAVE
5146 .loopbacks = alc880_lg_loopbacks,
5147#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005148 },
Takashi Iwaid6815182006-03-23 16:06:23 +01005149 [ALC880_LG_LW] = {
5150 .mixers = { alc880_lg_lw_mixer },
5151 .init_verbs = { alc880_volume_init_verbs,
5152 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02005153 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01005154 .dac_nids = alc880_dac_nids,
5155 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02005156 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
5157 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01005158 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +02005159 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02005160 .setup = alc880_lg_lw_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +02005161 .init_hook = alc_hp_automute,
Takashi Iwaid6815182006-03-23 16:06:23 +01005162 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02005163 [ALC880_MEDION_RIM] = {
5164 .mixers = { alc880_medion_rim_mixer },
5165 .init_verbs = { alc880_volume_init_verbs,
5166 alc880_medion_rim_init_verbs,
5167 alc_gpio2_init_verbs },
5168 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
5169 .dac_nids = alc880_dac_nids,
5170 .dig_out_nid = ALC880_DIGOUT_NID,
5171 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
5172 .channel_mode = alc880_2_jack_modes,
5173 .input_mux = &alc880_medion_rim_capture_source,
5174 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02005175 .setup = alc880_medion_rim_setup,
5176 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02005177 },
Takashi Iwai16ded522005-06-10 19:58:24 +02005178#ifdef CONFIG_SND_DEBUG
5179 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005180 .mixers = { alc880_test_mixer },
5181 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02005182 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
5183 .dac_nids = alc880_test_dac_nids,
5184 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02005185 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
5186 .channel_mode = alc880_test_modes,
5187 .input_mux = &alc880_test_capture_source,
5188 },
5189#endif
5190};
5191
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005192/*
5193 * Automatic parse of I/O pins from the BIOS configuration
5194 */
5195
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005196enum {
5197 ALC_CTL_WIDGET_VOL,
5198 ALC_CTL_WIDGET_MUTE,
5199 ALC_CTL_BIND_MUTE,
5200};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005201static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005202 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
5203 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01005204 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005205};
5206
Takashi Iwaice764ab2011-04-27 16:35:23 +02005207static struct snd_kcontrol_new *alc_kcontrol_new(struct alc_spec *spec)
5208{
5209 snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32);
5210 return snd_array_new(&spec->kctls);
5211}
5212
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005213/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005214static int add_control(struct alc_spec *spec, int type, const char *name,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005215 int cidx, unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005216{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005217 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005218
Takashi Iwaice764ab2011-04-27 16:35:23 +02005219 knew = alc_kcontrol_new(spec);
Takashi Iwai603c4012008-07-30 15:01:44 +02005220 if (!knew)
5221 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005222 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07005223 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005224 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005225 return -ENOMEM;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005226 knew->index = cidx;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01005227 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01005228 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005229 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005230 return 0;
5231}
5232
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005233static int add_control_with_pfx(struct alc_spec *spec, int type,
5234 const char *pfx, const char *dir,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005235 const char *sfx, int cidx, unsigned long val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005236{
5237 char name[32];
5238 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005239 return add_control(spec, type, name, cidx, val);
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005240}
5241
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005242#define add_pb_vol_ctrl(spec, type, pfx, val) \
5243 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
5244#define add_pb_sw_ctrl(spec, type, pfx, val) \
5245 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
5246#define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
5247 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
5248#define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
5249 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005250
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005251#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
5252#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
5253#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
5254#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005255#define alc880_idx_to_dac(nid) ((nid) + 0x02)
5256#define alc880_dac_to_idx(nid) ((nid) - 0x02)
5257#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
5258#define alc880_idx_to_selector(nid) ((nid) + 0x10)
5259#define ALC880_PIN_CD_NID 0x1c
5260
5261/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005262static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
5263 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005264{
5265 hda_nid_t nid;
5266 int assigned[4];
5267 int i, j;
5268
5269 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02005270 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005271
5272 /* check the pins hardwired to audio widget */
5273 for (i = 0; i < cfg->line_outs; i++) {
5274 nid = cfg->line_out_pins[i];
5275 if (alc880_is_fixed_pin(nid)) {
5276 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01005277 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005278 assigned[idx] = 1;
5279 }
5280 }
5281 /* left pins can be connect to any audio widget */
5282 for (i = 0; i < cfg->line_outs; i++) {
5283 nid = cfg->line_out_pins[i];
5284 if (alc880_is_fixed_pin(nid))
5285 continue;
5286 /* search for an empty channel */
5287 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005288 if (!assigned[j]) {
5289 spec->multiout.dac_nids[i] =
5290 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005291 assigned[j] = 1;
5292 break;
5293 }
5294 }
5295 }
5296 spec->multiout.num_dacs = cfg->line_outs;
5297 return 0;
5298}
5299
Takashi Iwaice764ab2011-04-27 16:35:23 +02005300static const char *alc_get_line_out_pfx(struct alc_spec *spec,
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005301 bool can_be_master)
5302{
Takashi Iwaice764ab2011-04-27 16:35:23 +02005303 struct auto_pin_cfg *cfg = &spec->autocfg;
5304
5305 if (cfg->line_outs == 1 && !spec->multi_ios &&
5306 !cfg->hp_outs && !cfg->speaker_outs && can_be_master)
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005307 return "Master";
5308
5309 switch (cfg->line_out_type) {
5310 case AUTO_PIN_SPEAKER_OUT:
David Henningssonebbeb3d2011-03-04 14:08:30 +01005311 if (cfg->line_outs == 1)
5312 return "Speaker";
5313 break;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005314 case AUTO_PIN_HP_OUT:
5315 return "Headphone";
5316 default:
Takashi Iwaice764ab2011-04-27 16:35:23 +02005317 if (cfg->line_outs == 1 && !spec->multi_ios)
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005318 return "PCM";
5319 break;
5320 }
5321 return NULL;
5322}
5323
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005324/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01005325static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
5326 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005327{
Takashi Iwaiea734962011-01-17 11:29:34 +01005328 static const char * const chname[4] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005329 "Front", "Surround", NULL /*CLFE*/, "Side"
5330 };
Takashi Iwaice764ab2011-04-27 16:35:23 +02005331 const char *pfx = alc_get_line_out_pfx(spec, false);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005332 hda_nid_t nid;
Takashi Iwaice764ab2011-04-27 16:35:23 +02005333 int i, err, noutputs;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005334
Takashi Iwaice764ab2011-04-27 16:35:23 +02005335 noutputs = cfg->line_outs;
5336 if (spec->multi_ios > 0)
5337 noutputs += spec->multi_ios;
5338
5339 for (i = 0; i < noutputs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005340 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005341 continue;
5342 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005343 if (!pfx && i == 2) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005344 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005345 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5346 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005347 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
5348 HDA_OUTPUT));
5349 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005350 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005351 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5352 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005353 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
5354 HDA_OUTPUT));
5355 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005356 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005357 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5358 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005359 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
5360 HDA_INPUT));
5361 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005362 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005363 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5364 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005365 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
5366 HDA_INPUT));
5367 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005368 return err;
5369 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005370 const char *name = pfx;
David Henningsson7e59e092011-03-04 14:22:25 +01005371 int index = i;
5372 if (!name) {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005373 name = chname[i];
David Henningsson7e59e092011-03-04 14:22:25 +01005374 index = 0;
5375 }
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005376 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
David Henningsson7e59e092011-03-04 14:22:25 +01005377 name, index,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005378 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
5379 HDA_OUTPUT));
5380 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005381 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005382 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
David Henningsson7e59e092011-03-04 14:22:25 +01005383 name, index,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005384 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
5385 HDA_INPUT));
5386 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005387 return err;
5388 }
5389 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005390 return 0;
5391}
5392
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005393/* add playback controls for speaker and HP outputs */
5394static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
5395 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005396{
5397 hda_nid_t nid;
5398 int err;
5399
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005400 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005401 return 0;
5402
5403 if (alc880_is_fixed_pin(pin)) {
5404 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01005405 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005406 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005407 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005408 else
5409 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005410 /* control HP volume/switch on the output mixer amp */
5411 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005412 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005413 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
5414 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005415 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005416 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005417 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
5418 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005419 return err;
5420 } else if (alc880_is_multi_pin(pin)) {
5421 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005422 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005423 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005424 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
5425 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005426 return err;
5427 }
5428 return 0;
5429}
5430
5431/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005432static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005433 const char *ctlname, int ctlidx,
Kailang Yangdf694da2005-12-05 19:42:22 +01005434 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005435{
Kailang Yangdf694da2005-12-05 19:42:22 +01005436 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005437
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005438 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005439 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5440 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005441 return err;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005442 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005443 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5444 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005445 return err;
5446 return 0;
5447}
5448
Takashi Iwai05f5f472009-08-25 13:10:18 +02005449static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005450{
Takashi Iwai05f5f472009-08-25 13:10:18 +02005451 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
5452 return (pincap & AC_PINCAP_IN) != 0;
5453}
5454
5455/* create playback/capture controls for input pins */
5456static int alc_auto_create_input_ctls(struct hda_codec *codec,
5457 const struct auto_pin_cfg *cfg,
5458 hda_nid_t mixer,
5459 hda_nid_t cap1, hda_nid_t cap2)
5460{
5461 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005462 struct hda_input_mux *imux = &spec->private_imux[0];
David Henningsson5322bf22011-01-05 11:03:56 +01005463 int i, err, idx, type_idx = 0;
5464 const char *prev_label = NULL;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005465
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005466 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02005467 hda_nid_t pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005468 const char *label;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005469
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005470 pin = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005471 if (!alc_is_input_pin(codec, pin))
5472 continue;
5473
David Henningsson5322bf22011-01-05 11:03:56 +01005474 label = hda_get_autocfg_input_label(codec, cfg, i);
5475 if (prev_label && !strcmp(label, prev_label))
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005476 type_idx++;
5477 else
5478 type_idx = 0;
David Henningsson5322bf22011-01-05 11:03:56 +01005479 prev_label = label;
5480
Takashi Iwai05f5f472009-08-25 13:10:18 +02005481 if (mixer) {
5482 idx = get_connection_index(codec, mixer, pin);
5483 if (idx >= 0) {
5484 err = new_analog_input(spec, pin,
Takashi Iwai10a20af2010-09-09 16:28:02 +02005485 label, type_idx,
5486 idx, mixer);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005487 if (err < 0)
5488 return err;
5489 }
5490 }
5491
5492 if (!cap1)
5493 continue;
5494 idx = get_connection_index(codec, cap1, pin);
5495 if (idx < 0 && cap2)
5496 idx = get_connection_index(codec, cap2, pin);
Takashi Iwai10a20af2010-09-09 16:28:02 +02005497 if (idx >= 0)
5498 snd_hda_add_imux_item(imux, label, idx, NULL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005499 }
5500 return 0;
5501}
5502
Takashi Iwai05f5f472009-08-25 13:10:18 +02005503static int alc880_auto_create_input_ctls(struct hda_codec *codec,
5504 const struct auto_pin_cfg *cfg)
5505{
5506 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
5507}
5508
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005509static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
5510 unsigned int pin_type)
5511{
5512 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5513 pin_type);
5514 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01005515 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5516 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005517}
5518
Kailang Yangdf694da2005-12-05 19:42:22 +01005519static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
5520 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005521 int dac_idx)
5522{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005523 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005524 /* need the manual connection? */
5525 if (alc880_is_multi_pin(nid)) {
5526 struct alc_spec *spec = codec->spec;
5527 int idx = alc880_multi_pin_idx(nid);
5528 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
5529 AC_VERB_SET_CONNECT_SEL,
5530 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
5531 }
5532}
5533
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005534static int get_pin_type(int line_out_type)
5535{
5536 if (line_out_type == AUTO_PIN_HP_OUT)
5537 return PIN_HP;
5538 else
5539 return PIN_OUT;
5540}
5541
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005542static void alc880_auto_init_multi_out(struct hda_codec *codec)
5543{
5544 struct alc_spec *spec = codec->spec;
5545 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02005546
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005547 for (i = 0; i < spec->autocfg.line_outs; i++) {
5548 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005549 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5550 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005551 }
5552}
5553
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005554static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005555{
5556 struct alc_spec *spec = codec->spec;
5557 hda_nid_t pin;
5558
Takashi Iwai82bc9552006-03-21 11:24:42 +01005559 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005560 if (pin) /* connect to front */
5561 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005562 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005563 if (pin) /* connect to front */
5564 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5565}
5566
5567static void alc880_auto_init_analog_input(struct hda_codec *codec)
5568{
5569 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005570 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005571 int i;
5572
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005573 for (i = 0; i < cfg->num_inputs; i++) {
5574 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005575 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02005576 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005577 if (nid != ALC880_PIN_CD_NID &&
5578 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005579 snd_hda_codec_write(codec, nid, 0,
5580 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005581 AMP_OUT_MUTE);
5582 }
5583 }
5584}
5585
Takashi Iwai7f311a42010-04-09 17:32:23 +02005586static void alc880_auto_init_input_src(struct hda_codec *codec)
5587{
5588 struct alc_spec *spec = codec->spec;
5589 int c;
5590
5591 for (c = 0; c < spec->num_adc_nids; c++) {
5592 unsigned int mux_idx;
5593 const struct hda_input_mux *imux;
5594 mux_idx = c >= spec->num_mux_defs ? 0 : c;
5595 imux = &spec->input_mux[mux_idx];
5596 if (!imux->num_items && mux_idx > 0)
5597 imux = &spec->input_mux[0];
5598 if (imux)
5599 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
5600 AC_VERB_SET_CONNECT_SEL,
5601 imux->items[0].index);
5602 }
5603}
5604
Takashi Iwaice764ab2011-04-27 16:35:23 +02005605static int alc_auto_add_multi_channel_mode(struct hda_codec *codec);
5606
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005607/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005608/* return 1 if successful, 0 if the proper config is not found,
5609 * or a negative error code
5610 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005611static int alc880_parse_auto_config(struct hda_codec *codec)
5612{
5613 struct alc_spec *spec = codec->spec;
Takashi Iwai757899a2010-07-30 10:48:14 +02005614 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005615 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005616
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005617 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5618 alc880_ignore);
5619 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005620 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005621 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005622 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01005623
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005624 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
5625 if (err < 0)
5626 return err;
Takashi Iwaice764ab2011-04-27 16:35:23 +02005627 err = alc_auto_add_multi_channel_mode(codec);
5628 if (err < 0)
5629 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005630 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
5631 if (err < 0)
5632 return err;
5633 err = alc880_auto_create_extra_out(spec,
5634 spec->autocfg.speaker_pins[0],
5635 "Speaker");
5636 if (err < 0)
5637 return err;
5638 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
5639 "Headphone");
5640 if (err < 0)
5641 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005642 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005643 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005644 return err;
5645
5646 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5647
Takashi Iwai757899a2010-07-30 10:48:14 +02005648 alc_auto_parse_digital(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005649
Takashi Iwai603c4012008-07-30 15:01:44 +02005650 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005651 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005652
Takashi Iwaid88897e2008-10-31 15:01:37 +01005653 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005654
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005655 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005656 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005657
Kailang Yang6227cdc2010-02-25 08:36:52 +01005658 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005659
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005660 return 1;
5661}
5662
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005663/* additional initialization for auto-configuration model */
5664static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005665{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005666 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005667 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005668 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005669 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02005670 alc880_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02005671 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005672 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005673 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005674}
5675
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005676/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5677 * one of two digital mic pins, e.g. on ALC272
5678 */
5679static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005680{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005681 struct alc_spec *spec = codec->spec;
5682 int i;
5683
5684 for (i = 0; i < spec->num_adc_nids; i++) {
5685 hda_nid_t cap = spec->capsrc_nids ?
5686 spec->capsrc_nids[i] : spec->adc_nids[i];
5687 int iidx, eidx;
5688
5689 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5690 if (iidx < 0)
5691 continue;
5692 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5693 if (eidx < 0)
5694 continue;
5695 spec->int_mic.mux_idx = iidx;
5696 spec->ext_mic.mux_idx = eidx;
5697 if (spec->capsrc_nids)
5698 spec->capsrc_nids += i;
5699 spec->adc_nids += i;
5700 spec->num_adc_nids = 1;
5701 return;
5702 }
5703 snd_printd(KERN_INFO "hda_codec: %s: "
5704 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5705 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5706 spec->auto_mic = 0; /* disable auto-mic to be sure */
5707}
5708
Takashi Iwai748cce42010-08-04 07:37:39 +02005709/* select or unmute the given capsrc route */
5710static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
5711 int idx)
5712{
5713 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5714 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5715 HDA_AMP_MUTE, 0);
5716 } else {
5717 snd_hda_codec_write_cache(codec, cap, 0,
5718 AC_VERB_SET_CONNECT_SEL, idx);
5719 }
5720}
5721
Takashi Iwai840b64c2010-07-13 22:49:01 +02005722/* set the default connection to that pin */
5723static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
5724{
5725 struct alc_spec *spec = codec->spec;
5726 int i;
5727
5728 for (i = 0; i < spec->num_adc_nids; i++) {
5729 hda_nid_t cap = spec->capsrc_nids ?
5730 spec->capsrc_nids[i] : spec->adc_nids[i];
5731 int idx;
5732
5733 idx = get_connection_index(codec, cap, pin);
5734 if (idx < 0)
5735 continue;
Takashi Iwai748cce42010-08-04 07:37:39 +02005736 select_or_unmute_capsrc(codec, cap, idx);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005737 return i; /* return the found index */
5738 }
5739 return -1; /* not found */
5740}
5741
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005742/* choose the ADC/MUX containing the input pin and initialize the setup */
5743static void fixup_single_adc(struct hda_codec *codec)
5744{
5745 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005746 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005747 int i;
5748
5749 /* search for the input pin; there must be only one */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005750 if (cfg->num_inputs != 1)
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005751 return;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005752 i = init_capsrc_for_pin(codec, cfg->inputs[0].pin);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005753 if (i >= 0) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005754 /* use only this ADC */
5755 if (spec->capsrc_nids)
5756 spec->capsrc_nids += i;
5757 spec->adc_nids += i;
5758 spec->num_adc_nids = 1;
Takashi Iwai584c0c42011-03-10 12:51:11 +01005759 spec->single_input_src = 1;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005760 }
5761}
5762
Takashi Iwai840b64c2010-07-13 22:49:01 +02005763/* initialize dual adcs */
5764static void fixup_dual_adc_switch(struct hda_codec *codec)
5765{
5766 struct alc_spec *spec = codec->spec;
5767 init_capsrc_for_pin(codec, spec->ext_mic.pin);
5768 init_capsrc_for_pin(codec, spec->int_mic.pin);
5769}
5770
Takashi Iwai584c0c42011-03-10 12:51:11 +01005771/* initialize some special cases for input sources */
5772static void alc_init_special_input_src(struct hda_codec *codec)
5773{
5774 struct alc_spec *spec = codec->spec;
5775 if (spec->dual_adc_switch)
5776 fixup_dual_adc_switch(codec);
5777 else if (spec->single_input_src)
5778 init_capsrc_for_pin(codec, spec->autocfg.inputs[0].pin);
5779}
5780
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005781static void set_capture_mixer(struct hda_codec *codec)
5782{
5783 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005784 static struct snd_kcontrol_new *caps[2][3] = {
5785 { alc_capture_mixer_nosrc1,
5786 alc_capture_mixer_nosrc2,
5787 alc_capture_mixer_nosrc3 },
5788 { alc_capture_mixer1,
5789 alc_capture_mixer2,
5790 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005791 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005792 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005793 int mux = 0;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005794 int num_adcs = spec->num_adc_nids;
5795 if (spec->dual_adc_switch)
Takashi Iwai584c0c42011-03-10 12:51:11 +01005796 num_adcs = 1;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005797 else if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005798 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005799 else if (spec->input_mux) {
5800 if (spec->input_mux->num_items > 1)
5801 mux = 1;
5802 else if (spec->input_mux->num_items == 1)
5803 fixup_single_adc(codec);
5804 }
Takashi Iwai840b64c2010-07-13 22:49:01 +02005805 spec->cap_mixer = caps[mux][num_adcs - 1];
Takashi Iwaia23b6882009-03-23 15:21:36 +01005806 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005807}
5808
Takashi Iwai66946352010-03-29 17:21:45 +02005809/* fill adc_nids (and capsrc_nids) containing all active input pins */
5810static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5811 int num_nids)
5812{
5813 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005814 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai66946352010-03-29 17:21:45 +02005815 int n;
5816 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5817
5818 for (n = 0; n < num_nids; n++) {
5819 hda_nid_t adc, cap;
5820 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5821 int nconns, i, j;
5822
5823 adc = nids[n];
5824 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5825 continue;
5826 cap = adc;
5827 nconns = snd_hda_get_connections(codec, cap, conn,
5828 ARRAY_SIZE(conn));
5829 if (nconns == 1) {
5830 cap = conn[0];
5831 nconns = snd_hda_get_connections(codec, cap, conn,
5832 ARRAY_SIZE(conn));
5833 }
5834 if (nconns <= 0)
5835 continue;
5836 if (!fallback_adc) {
5837 fallback_adc = adc;
5838 fallback_cap = cap;
5839 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005840 for (i = 0; i < cfg->num_inputs; i++) {
5841 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai66946352010-03-29 17:21:45 +02005842 for (j = 0; j < nconns; j++) {
5843 if (conn[j] == nid)
5844 break;
5845 }
5846 if (j >= nconns)
5847 break;
5848 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005849 if (i >= cfg->num_inputs) {
Takashi Iwai66946352010-03-29 17:21:45 +02005850 int num_adcs = spec->num_adc_nids;
5851 spec->private_adc_nids[num_adcs] = adc;
5852 spec->private_capsrc_nids[num_adcs] = cap;
5853 spec->num_adc_nids++;
5854 spec->adc_nids = spec->private_adc_nids;
5855 if (adc != cap)
5856 spec->capsrc_nids = spec->private_capsrc_nids;
5857 }
5858 }
5859 if (!spec->num_adc_nids) {
5860 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005861 " using fallback 0x%x\n",
5862 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005863 spec->private_adc_nids[0] = fallback_adc;
5864 spec->adc_nids = spec->private_adc_nids;
5865 if (fallback_adc != fallback_cap) {
5866 spec->private_capsrc_nids[0] = fallback_cap;
5867 spec->capsrc_nids = spec->private_adc_nids;
5868 }
5869 }
5870}
5871
Takashi Iwai67d634c2009-11-16 15:35:59 +01005872#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005873#define set_beep_amp(spec, nid, idx, dir) \
5874 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005875
5876static struct snd_pci_quirk beep_white_list[] = {
5877 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai080dc7b2010-09-08 08:38:41 +02005878 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
Takashi Iwaie096c8e2010-08-03 17:20:35 +02005879 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005880 {}
5881};
5882
5883static inline int has_cdefine_beep(struct hda_codec *codec)
5884{
5885 struct alc_spec *spec = codec->spec;
5886 const struct snd_pci_quirk *q;
5887 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5888 if (q)
5889 return q->value;
5890 return spec->cdefine.enable_pcbeep;
5891}
Takashi Iwai67d634c2009-11-16 15:35:59 +01005892#else
5893#define set_beep_amp(spec, nid, idx, dir) /* NOP */
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005894#define has_cdefine_beep(codec) 0
Takashi Iwai67d634c2009-11-16 15:35:59 +01005895#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005896
5897/*
5898 * OK, here we have finally the patch for ALC880
5899 */
5900
Linus Torvalds1da177e2005-04-16 15:20:36 -07005901static int patch_alc880(struct hda_codec *codec)
5902{
5903 struct alc_spec *spec;
5904 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005905 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005906
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005907 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005908 if (spec == NULL)
5909 return -ENOMEM;
5910
5911 codec->spec = spec;
5912
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005913 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5914 alc880_models,
5915 alc880_cfg_tbl);
5916 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005917 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5918 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005919 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005920 }
5921
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005922 if (board_config == ALC880_AUTO) {
5923 /* automatic parse from the BIOS config */
5924 err = alc880_parse_auto_config(codec);
5925 if (err < 0) {
5926 alc_free(codec);
5927 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005928 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005929 printk(KERN_INFO
5930 "hda_codec: Cannot set up configuration "
5931 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005932 board_config = ALC880_3ST;
5933 }
5934 }
5935
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005936 err = snd_hda_attach_beep_device(codec, 0x1);
5937 if (err < 0) {
5938 alc_free(codec);
5939 return err;
5940 }
5941
Kailang Yangdf694da2005-12-05 19:42:22 +01005942 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005943 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005944
Linus Torvalds1da177e2005-04-16 15:20:36 -07005945 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5946 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005947 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005948
Linus Torvalds1da177e2005-04-16 15:20:36 -07005949 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5950 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5951
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005952 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005953 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005954 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005955 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005956 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005957 if (wcap != AC_WID_AUD_IN) {
5958 spec->adc_nids = alc880_adc_nids_alt;
5959 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005960 } else {
5961 spec->adc_nids = alc880_adc_nids;
5962 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005963 }
5964 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005965 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005966 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005967
Takashi Iwai2134ea42008-01-10 16:53:55 +01005968 spec->vmaster_nid = 0x0c;
5969
Linus Torvalds1da177e2005-04-16 15:20:36 -07005970 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005971 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005972 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005973#ifdef CONFIG_SND_HDA_POWER_SAVE
5974 if (!spec->loopback.amplist)
5975 spec->loopback.amplist = alc880_loopbacks;
5976#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005977
5978 return 0;
5979}
5980
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005981
Linus Torvalds1da177e2005-04-16 15:20:36 -07005982/*
5983 * ALC260 support
5984 */
5985
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005986static hda_nid_t alc260_dac_nids[1] = {
5987 /* front */
5988 0x02,
5989};
5990
5991static hda_nid_t alc260_adc_nids[1] = {
5992 /* ADC0 */
5993 0x04,
5994};
5995
Kailang Yangdf694da2005-12-05 19:42:22 +01005996static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005997 /* ADC1 */
5998 0x05,
5999};
6000
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006001/* NIDs used when simultaneous access to both ADCs makes sense. Note that
6002 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
6003 */
6004static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006005 /* ADC0, ADC1 */
6006 0x04, 0x05
6007};
6008
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006009#define ALC260_DIGOUT_NID 0x03
6010#define ALC260_DIGIN_NID 0x06
6011
6012static struct hda_input_mux alc260_capture_source = {
6013 .num_items = 4,
6014 .items = {
6015 { "Mic", 0x0 },
6016 { "Front Mic", 0x1 },
6017 { "Line", 0x2 },
6018 { "CD", 0x4 },
6019 },
6020};
6021
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006022/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006023 * headphone jack and the internal CD lines since these are the only pins at
6024 * which audio can appear. For flexibility, also allow the option of
6025 * recording the mixer output on the second ADC (ADC0 doesn't have a
6026 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006027 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006028static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
6029 {
6030 .num_items = 3,
6031 .items = {
6032 { "Mic/Line", 0x0 },
6033 { "CD", 0x4 },
6034 { "Headphone", 0x2 },
6035 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006036 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006037 {
6038 .num_items = 4,
6039 .items = {
6040 { "Mic/Line", 0x0 },
6041 { "CD", 0x4 },
6042 { "Headphone", 0x2 },
6043 { "Mixer", 0x5 },
6044 },
6045 },
6046
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006047};
6048
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006049/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
6050 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006051 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006052static struct hda_input_mux alc260_acer_capture_sources[2] = {
6053 {
6054 .num_items = 4,
6055 .items = {
6056 { "Mic", 0x0 },
6057 { "Line", 0x2 },
6058 { "CD", 0x4 },
6059 { "Headphone", 0x5 },
6060 },
6061 },
6062 {
6063 .num_items = 5,
6064 .items = {
6065 { "Mic", 0x0 },
6066 { "Line", 0x2 },
6067 { "CD", 0x4 },
6068 { "Headphone", 0x6 },
6069 { "Mixer", 0x5 },
6070 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006071 },
6072};
Michael Schwingencc959482009-02-22 18:58:45 +01006073
6074/* Maxdata Favorit 100XS */
6075static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
6076 {
6077 .num_items = 2,
6078 .items = {
6079 { "Line/Mic", 0x0 },
6080 { "CD", 0x4 },
6081 },
6082 },
6083 {
6084 .num_items = 3,
6085 .items = {
6086 { "Line/Mic", 0x0 },
6087 { "CD", 0x4 },
6088 { "Mixer", 0x5 },
6089 },
6090 },
6091};
6092
Linus Torvalds1da177e2005-04-16 15:20:36 -07006093/*
6094 * This is just place-holder, so there's something for alc_build_pcms to look
6095 * at when it calculates the maximum number of channels. ALC260 has no mixer
6096 * element which allows changing the channel mode, so the verb list is
6097 * never used.
6098 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006099static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006100 { 2, NULL },
6101};
6102
Kailang Yangdf694da2005-12-05 19:42:22 +01006103
6104/* Mixer combinations
6105 *
6106 * basic: base_output + input + pc_beep + capture
6107 * HP: base_output + input + capture_alt
6108 * HP_3013: hp_3013 + input + capture
6109 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006110 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01006111 */
6112
6113static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006114 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006115 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006116 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6117 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
6118 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6119 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6120 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006121};
Kailang Yangdf694da2005-12-05 19:42:22 +01006122
6123static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006124 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6125 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6126 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6127 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6128 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6129 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6130 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
6131 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006132 { } /* end */
6133};
6134
Takashi Iwaibec15c32008-01-28 18:16:30 +01006135/* update HP, line and mono out pins according to the master switch */
Takashi Iwaie9427962011-04-28 15:46:07 +02006136static void alc260_hp_master_update(struct hda_codec *codec)
Takashi Iwaibec15c32008-01-28 18:16:30 +01006137{
6138 struct alc_spec *spec = codec->spec;
Takashi Iwaie9427962011-04-28 15:46:07 +02006139
6140 /* change HP pins */
6141 do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins),
6142 spec->autocfg.hp_pins, spec->master_mute, true);
6143 update_speakers(codec);
Takashi Iwaibec15c32008-01-28 18:16:30 +01006144}
6145
6146static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
6147 struct snd_ctl_elem_value *ucontrol)
6148{
6149 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6150 struct alc_spec *spec = codec->spec;
Takashi Iwaie9427962011-04-28 15:46:07 +02006151 *ucontrol->value.integer.value = !spec->master_mute;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006152 return 0;
6153}
6154
6155static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
6156 struct snd_ctl_elem_value *ucontrol)
6157{
6158 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6159 struct alc_spec *spec = codec->spec;
Takashi Iwaie9427962011-04-28 15:46:07 +02006160 int val = !*ucontrol->value.integer.value;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006161
Takashi Iwaie9427962011-04-28 15:46:07 +02006162 if (val == spec->master_mute)
Takashi Iwaibec15c32008-01-28 18:16:30 +01006163 return 0;
Takashi Iwaie9427962011-04-28 15:46:07 +02006164 spec->master_mute = val;
6165 alc260_hp_master_update(codec);
Takashi Iwaibec15c32008-01-28 18:16:30 +01006166 return 1;
6167}
6168
6169static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
6170 {
6171 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6172 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01006173 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006174 .info = snd_ctl_boolean_mono_info,
6175 .get = alc260_hp_master_sw_get,
6176 .put = alc260_hp_master_sw_put,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006177 },
6178 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6179 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
6180 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6181 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
6182 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
6183 HDA_OUTPUT),
6184 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6185 { } /* end */
6186};
6187
6188static struct hda_verb alc260_hp_unsol_verbs[] = {
6189 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6190 {},
6191};
6192
Takashi Iwaie9427962011-04-28 15:46:07 +02006193static void alc260_hp_setup(struct hda_codec *codec)
Takashi Iwaibec15c32008-01-28 18:16:30 +01006194{
6195 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006196
Takashi Iwaie9427962011-04-28 15:46:07 +02006197 spec->autocfg.hp_pins[0] = 0x0f;
6198 spec->autocfg.speaker_pins[0] = 0x10;
6199 spec->autocfg.speaker_pins[1] = 0x11;
6200 spec->automute = 1;
6201 spec->automute_mode = ALC_AUTOMUTE_PIN;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006202}
6203
Kailang Yangdf694da2005-12-05 19:42:22 +01006204static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006205 {
6206 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6207 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01006208 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006209 .info = snd_ctl_boolean_mono_info,
6210 .get = alc260_hp_master_sw_get,
6211 .put = alc260_hp_master_sw_put,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006212 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006213 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6214 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
6215 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
6216 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
6217 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6218 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01006219 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6220 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02006221 { } /* end */
6222};
6223
Takashi Iwaie9427962011-04-28 15:46:07 +02006224static void alc260_hp_3013_setup(struct hda_codec *codec)
6225{
6226 struct alc_spec *spec = codec->spec;
6227
6228 spec->autocfg.hp_pins[0] = 0x15;
6229 spec->autocfg.speaker_pins[0] = 0x10;
6230 spec->autocfg.speaker_pins[1] = 0x11;
6231 spec->automute = 1;
6232 spec->automute_mode = ALC_AUTOMUTE_PIN;
6233}
6234
Kailang Yang3f878302008-08-26 13:02:23 +02006235static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
6236 .ops = &snd_hda_bind_vol,
6237 .values = {
6238 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
6239 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
6240 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
6241 0
6242 },
6243};
6244
6245static struct hda_bind_ctls alc260_dc7600_bind_switch = {
6246 .ops = &snd_hda_bind_sw,
6247 .values = {
6248 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
6249 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
6250 0
6251 },
6252};
6253
6254static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
6255 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
6256 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
6257 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
6258 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
6259 { } /* end */
6260};
6261
Takashi Iwaibec15c32008-01-28 18:16:30 +01006262static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
6263 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6264 {},
6265};
6266
Takashi Iwaie9427962011-04-28 15:46:07 +02006267static void alc260_hp_3012_setup(struct hda_codec *codec)
Takashi Iwaibec15c32008-01-28 18:16:30 +01006268{
6269 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006270
Takashi Iwaie9427962011-04-28 15:46:07 +02006271 spec->autocfg.hp_pins[0] = 0x10;
6272 spec->autocfg.speaker_pins[0] = 0x0f;
6273 spec->autocfg.speaker_pins[1] = 0x11;
6274 spec->autocfg.speaker_pins[2] = 0x15;
6275 spec->automute = 1;
6276 spec->automute_mode = ALC_AUTOMUTE_PIN;
Kailang Yang3f878302008-08-26 13:02:23 +02006277}
6278
6279/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006280 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
6281 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006282static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006283 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006284 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006285 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006286 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6287 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6288 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
6289 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006290 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006291 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6292 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006293 { } /* end */
6294};
6295
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006296/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
6297 * versions of the ALC260 don't act on requests to enable mic bias from NID
6298 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
6299 * datasheet doesn't mention this restriction. At this stage it's not clear
6300 * whether this behaviour is intentional or is a hardware bug in chip
6301 * revisions available in early 2006. Therefore for now allow the
6302 * "Headphone Jack Mode" control to span all choices, but if it turns out
6303 * that the lack of mic bias for this NID is intentional we could change the
6304 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6305 *
6306 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
6307 * don't appear to make the mic bias available from the "line" jack, even
6308 * though the NID used for this jack (0x14) can supply it. The theory is
6309 * that perhaps Acer have included blocking capacitors between the ALC260
6310 * and the output jack. If this turns out to be the case for all such
6311 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
6312 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01006313 *
6314 * The C20x Tablet series have a mono internal speaker which is controlled
6315 * via the chip's Mono sum widget and pin complex, so include the necessary
6316 * controls for such models. On models without a "mono speaker" the control
6317 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006318 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006319static struct snd_kcontrol_new alc260_acer_mixer[] = {
6320 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6321 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006322 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006323 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01006324 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006325 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01006326 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006327 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6328 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6329 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6330 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6331 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6332 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6333 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6334 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006335 { } /* end */
6336};
6337
Michael Schwingencc959482009-02-22 18:58:45 +01006338/* Maxdata Favorit 100XS: one output and one input (0x12) jack
6339 */
6340static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
6341 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6342 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
6343 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
6344 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6345 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6346 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6347 { } /* end */
6348};
6349
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006350/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
6351 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
6352 */
6353static struct snd_kcontrol_new alc260_will_mixer[] = {
6354 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6355 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6356 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6357 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6358 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6359 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6360 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6361 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6362 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6363 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006364 { } /* end */
6365};
6366
6367/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
6368 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
6369 */
6370static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
6371 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6372 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6373 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6374 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6375 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6376 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
6377 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
6378 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6379 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6380 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6381 { } /* end */
6382};
6383
Kailang Yangdf694da2005-12-05 19:42:22 +01006384/*
6385 * initialization verbs
6386 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006387static struct hda_verb alc260_init_verbs[] = {
6388 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006389 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006390 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006391 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006392 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006393 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006394 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006395 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006396 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02006397 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006398 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01006399 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006400 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02006401 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006402 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02006403 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006404 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02006405 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6406 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02006407 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006408 /* set connection select to line in (default select for this ADC) */
6409 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02006410 /* mute capture amp left and right */
6411 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6412 /* set connection select to line in (default select for this ADC) */
6413 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02006414 /* set vol=0 Line-Out mixer amp left and right */
6415 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6416 /* unmute pin widget amp left and right (no gain on this amp) */
6417 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6418 /* set vol=0 HP mixer amp left and right */
6419 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6420 /* unmute pin widget amp left and right (no gain on this amp) */
6421 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6422 /* set vol=0 Mono mixer amp left and right */
6423 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6424 /* unmute pin widget amp left and right (no gain on this amp) */
6425 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6426 /* unmute LINE-2 out pin */
6427 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006428 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6429 * Line In 2 = 0x03
6430 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006431 /* mute analog inputs */
6432 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6433 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6434 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6435 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6436 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006437 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006438 /* mute Front out path */
6439 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6440 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6441 /* mute Headphone out path */
6442 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6443 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6444 /* mute Mono out path */
6445 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6446 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006447 { }
6448};
6449
Takashi Iwai474167d2006-05-17 17:17:43 +02006450#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01006451static struct hda_verb alc260_hp_init_verbs[] = {
6452 /* Headphone and output */
6453 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6454 /* mono output */
6455 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6456 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6457 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6458 /* Mic2 (front panel) pin widget for input and vref at 80% */
6459 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6460 /* Line In pin widget for input */
6461 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6462 /* Line-2 pin widget for output */
6463 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6464 /* CD pin widget for input */
6465 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6466 /* unmute amp left and right */
6467 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6468 /* set connection select to line in (default select for this ADC) */
6469 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6470 /* unmute Line-Out mixer amp left and right (volume = 0) */
6471 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6472 /* mute pin widget amp left and right (no gain on this amp) */
6473 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6474 /* unmute HP mixer amp left and right (volume = 0) */
6475 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6476 /* mute pin widget amp left and right (no gain on this amp) */
6477 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006478 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6479 * Line In 2 = 0x03
6480 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006481 /* mute analog inputs */
6482 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6483 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6484 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6485 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6486 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006487 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6488 /* Unmute Front out path */
6489 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6490 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6491 /* Unmute Headphone out path */
6492 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6493 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6494 /* Unmute Mono out path */
6495 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6496 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6497 { }
6498};
Takashi Iwai474167d2006-05-17 17:17:43 +02006499#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006500
6501static struct hda_verb alc260_hp_3013_init_verbs[] = {
6502 /* Line out and output */
6503 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6504 /* mono output */
6505 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6506 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6507 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6508 /* Mic2 (front panel) pin widget for input and vref at 80% */
6509 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6510 /* Line In pin widget for input */
6511 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6512 /* Headphone pin widget for output */
6513 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6514 /* CD pin widget for input */
6515 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6516 /* unmute amp left and right */
6517 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6518 /* set connection select to line in (default select for this ADC) */
6519 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6520 /* unmute Line-Out mixer amp left and right (volume = 0) */
6521 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6522 /* mute pin widget amp left and right (no gain on this amp) */
6523 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6524 /* unmute HP mixer amp left and right (volume = 0) */
6525 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6526 /* mute pin widget amp left and right (no gain on this amp) */
6527 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006528 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6529 * Line In 2 = 0x03
6530 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006531 /* mute analog inputs */
6532 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6533 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6534 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6535 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6536 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006537 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6538 /* Unmute Front out path */
6539 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6540 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6541 /* Unmute Headphone out path */
6542 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6543 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6544 /* Unmute Mono out path */
6545 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6546 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6547 { }
6548};
6549
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006550/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006551 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
6552 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006553 */
6554static struct hda_verb alc260_fujitsu_init_verbs[] = {
6555 /* Disable all GPIOs */
6556 {0x01, AC_VERB_SET_GPIO_MASK, 0},
6557 /* Internal speaker is connected to headphone pin */
6558 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6559 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
6560 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006561 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
6562 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6563 /* Ensure all other unused pins are disabled and muted. */
6564 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6565 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006566 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006567 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006568 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006569 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6570 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6571 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006572
Jonathan Woithef7ace402006-02-28 11:46:14 +01006573 /* Disable digital (SPDIF) pins */
6574 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6575 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006576
Kailang Yangea1fb292008-08-26 12:58:38 +02006577 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01006578 * when acting as an output.
6579 */
6580 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6581
6582 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01006583 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6584 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6585 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6586 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6587 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6588 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6589 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6590 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6591 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006592
Jonathan Woithef7ace402006-02-28 11:46:14 +01006593 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
6594 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6595 /* Unmute Line1 pin widget output buffer since it starts as an output.
6596 * If the pin mode is changed by the user the pin mode control will
6597 * take care of enabling the pin's input/output buffers as needed.
6598 * Therefore there's no need to enable the input buffer at this
6599 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006600 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006601 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02006602 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006603 * mixer ctrl)
6604 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006605 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006606
Jonathan Woithef7ace402006-02-28 11:46:14 +01006607 /* Mute capture amp left and right */
6608 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006609 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01006610 * in (on mic1 pin)
6611 */
6612 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006613
Jonathan Woithef7ace402006-02-28 11:46:14 +01006614 /* Do the same for the second ADC: mute capture input amp and
6615 * set ADC connection to line in (on mic1 pin)
6616 */
6617 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6618 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006619
Jonathan Woithef7ace402006-02-28 11:46:14 +01006620 /* Mute all inputs to mixer widget (even unconnected ones) */
6621 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6622 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6623 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6624 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6625 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6626 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6627 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6628 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006629
6630 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006631};
6632
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006633/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
6634 * similar laptops (adapted from Fujitsu init verbs).
6635 */
6636static struct hda_verb alc260_acer_init_verbs[] = {
6637 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
6638 * the headphone jack. Turn this on and rely on the standard mute
6639 * methods whenever the user wants to turn these outputs off.
6640 */
6641 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6642 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6643 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6644 /* Internal speaker/Headphone jack is connected to Line-out pin */
6645 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6646 /* Internal microphone/Mic jack is connected to Mic1 pin */
6647 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6648 /* Line In jack is connected to Line1 pin */
6649 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01006650 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
6651 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006652 /* Ensure all other unused pins are disabled and muted. */
6653 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6654 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006655 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6656 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6657 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6658 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6659 /* Disable digital (SPDIF) pins */
6660 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6661 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6662
Kailang Yangea1fb292008-08-26 12:58:38 +02006663 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006664 * bus when acting as outputs.
6665 */
6666 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6667 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6668
6669 /* Start with output sum widgets muted and their output gains at min */
6670 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6671 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6672 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6673 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6674 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6675 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6676 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6677 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6678 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6679
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006680 /* Unmute Line-out pin widget amp left and right
6681 * (no equiv mixer ctrl)
6682 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006683 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01006684 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6685 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006686 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6687 * inputs. If the pin mode is changed by the user the pin mode control
6688 * will take care of enabling the pin's input/output buffers as needed.
6689 * Therefore there's no need to enable the input buffer at this
6690 * stage.
6691 */
6692 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6693 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6694
6695 /* Mute capture amp left and right */
6696 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6697 /* Set ADC connection select to match default mixer setting - mic
6698 * (on mic1 pin)
6699 */
6700 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6701
6702 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006703 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006704 */
6705 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006706 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006707
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
Michael Schwingencc959482009-02-22 18:58:45 +01006721/* Initialisation sequence for Maxdata Favorit 100XS
6722 * (adapted from Acer init verbs).
6723 */
6724static struct hda_verb alc260_favorit100_init_verbs[] = {
6725 /* GPIO 0 enables the output jack.
6726 * Turn this on and rely on the standard mute
6727 * methods whenever the user wants to turn these outputs off.
6728 */
6729 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6730 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6731 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6732 /* Line/Mic input jack is connected to Mic1 pin */
6733 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6734 /* Ensure all other unused pins are disabled and muted. */
6735 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6736 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6737 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6738 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6739 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6740 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6741 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6742 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6743 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6744 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6745 /* Disable digital (SPDIF) pins */
6746 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6747 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6748
6749 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6750 * bus when acting as outputs.
6751 */
6752 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6753 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6754
6755 /* Start with output sum widgets muted and their output gains at min */
6756 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6757 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6758 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6759 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6760 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6761 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6762 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6763 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6764 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6765
6766 /* Unmute Line-out pin widget amp left and right
6767 * (no equiv mixer ctrl)
6768 */
6769 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6770 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6771 * inputs. If the pin mode is changed by the user the pin mode control
6772 * will take care of enabling the pin's input/output buffers as needed.
6773 * Therefore there's no need to enable the input buffer at this
6774 * stage.
6775 */
6776 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6777
6778 /* Mute capture amp left and right */
6779 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6780 /* Set ADC connection select to match default mixer setting - mic
6781 * (on mic1 pin)
6782 */
6783 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6784
6785 /* Do similar with the second ADC: mute capture input amp and
6786 * set ADC connection to mic to match ALSA's default state.
6787 */
6788 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6789 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6790
6791 /* Mute all inputs to mixer widget (even unconnected ones) */
6792 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6793 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6794 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6795 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6796 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6797 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6798 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6799 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6800
6801 { }
6802};
6803
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006804static struct hda_verb alc260_will_verbs[] = {
6805 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6806 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6807 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6808 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6809 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6810 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6811 {}
6812};
6813
6814static struct hda_verb alc260_replacer_672v_verbs[] = {
6815 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6816 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6817 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6818
6819 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6820 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6821 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6822
6823 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6824 {}
6825};
6826
6827/* toggle speaker-output according to the hp-jack state */
6828static void alc260_replacer_672v_automute(struct hda_codec *codec)
6829{
6830 unsigned int present;
6831
6832 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006833 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006834 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006835 snd_hda_codec_write_cache(codec, 0x01, 0,
6836 AC_VERB_SET_GPIO_DATA, 1);
6837 snd_hda_codec_write_cache(codec, 0x0f, 0,
6838 AC_VERB_SET_PIN_WIDGET_CONTROL,
6839 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006840 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006841 snd_hda_codec_write_cache(codec, 0x01, 0,
6842 AC_VERB_SET_GPIO_DATA, 0);
6843 snd_hda_codec_write_cache(codec, 0x0f, 0,
6844 AC_VERB_SET_PIN_WIDGET_CONTROL,
6845 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006846 }
6847}
6848
6849static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6850 unsigned int res)
6851{
6852 if ((res >> 26) == ALC880_HP_EVENT)
6853 alc260_replacer_672v_automute(codec);
6854}
6855
Kailang Yang3f878302008-08-26 13:02:23 +02006856static struct hda_verb alc260_hp_dc7600_verbs[] = {
6857 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6858 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6859 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6860 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6861 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6862 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6863 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6864 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6865 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6866 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6867 {}
6868};
6869
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006870/* Test configuration for debugging, modelled after the ALC880 test
6871 * configuration.
6872 */
6873#ifdef CONFIG_SND_DEBUG
6874static hda_nid_t alc260_test_dac_nids[1] = {
6875 0x02,
6876};
6877static hda_nid_t alc260_test_adc_nids[2] = {
6878 0x04, 0x05,
6879};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006880/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006881 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006882 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006883 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006884static struct hda_input_mux alc260_test_capture_sources[2] = {
6885 {
6886 .num_items = 7,
6887 .items = {
6888 { "MIC1 pin", 0x0 },
6889 { "MIC2 pin", 0x1 },
6890 { "LINE1 pin", 0x2 },
6891 { "LINE2 pin", 0x3 },
6892 { "CD pin", 0x4 },
6893 { "LINE-OUT pin", 0x5 },
6894 { "HP-OUT pin", 0x6 },
6895 },
6896 },
6897 {
6898 .num_items = 8,
6899 .items = {
6900 { "MIC1 pin", 0x0 },
6901 { "MIC2 pin", 0x1 },
6902 { "LINE1 pin", 0x2 },
6903 { "LINE2 pin", 0x3 },
6904 { "CD pin", 0x4 },
6905 { "Mixer", 0x5 },
6906 { "LINE-OUT pin", 0x6 },
6907 { "HP-OUT pin", 0x7 },
6908 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006909 },
6910};
6911static struct snd_kcontrol_new alc260_test_mixer[] = {
6912 /* Output driver widgets */
6913 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6914 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6915 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6916 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6917 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6918 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6919
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006920 /* Modes for retasking pin widgets
6921 * Note: the ALC260 doesn't seem to act on requests to enable mic
6922 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6923 * mention this restriction. At this stage it's not clear whether
6924 * this behaviour is intentional or is a hardware bug in chip
6925 * revisions available at least up until early 2006. Therefore for
6926 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6927 * choices, but if it turns out that the lack of mic bias for these
6928 * NIDs is intentional we could change their modes from
6929 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6930 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006931 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6932 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6933 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6934 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6935 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6936 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6937
6938 /* Loopback mixer controls */
6939 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6940 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6941 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6942 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6943 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6944 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6945 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6946 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6947 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6948 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006949 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6950 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6951 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6952 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006953
6954 /* Controls for GPIO pins, assuming they are configured as outputs */
6955 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6956 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6957 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6958 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6959
Jonathan Woithe92621f12006-02-28 11:47:47 +01006960 /* Switches to allow the digital IO pins to be enabled. The datasheet
6961 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006962 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006963 */
6964 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6965 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6966
Jonathan Woithef8225f62008-01-08 12:16:54 +01006967 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6968 * this output to turn on an external amplifier.
6969 */
6970 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6971 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6972
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006973 { } /* end */
6974};
6975static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006976 /* Enable all GPIOs as outputs with an initial value of 0 */
6977 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6978 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6979 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6980
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006981 /* Enable retasking pins as output, initially without power amp */
6982 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6983 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6984 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6985 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6986 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6987 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6988
Jonathan Woithe92621f12006-02-28 11:47:47 +01006989 /* Disable digital (SPDIF) pins initially, but users can enable
6990 * them via a mixer switch. In the case of SPDIF-out, this initverb
6991 * payload also sets the generation to 0, output to be in "consumer"
6992 * PCM format, copyright asserted, no pre-emphasis and no validity
6993 * control.
6994 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006995 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6996 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6997
Kailang Yangea1fb292008-08-26 12:58:38 +02006998 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006999 * OUT1 sum bus when acting as an output.
7000 */
7001 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
7002 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
7003 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
7004 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
7005
7006 /* Start with output sum widgets muted and their output gains at min */
7007 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7008 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7009 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7010 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7011 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7012 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7013 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7014 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7015 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7016
Jonathan Woithecdcd9262006-02-28 11:36:42 +01007017 /* Unmute retasking pin widget output buffers since the default
7018 * state appears to be output. As the pin mode is changed by the
7019 * user the pin mode control will take care of enabling the pin's
7020 * input/output buffers as needed.
7021 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01007022 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7023 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7024 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7025 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7026 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7027 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7028 /* Also unmute the mono-out pin widget */
7029 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7030
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01007031 /* Mute capture amp left and right */
7032 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01007033 /* Set ADC connection select to match default mixer setting (mic1
7034 * pin)
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01007035 */
7036 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
7037
7038 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01007039 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01007040 */
7041 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7042 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
7043
7044 /* Mute all inputs to mixer widget (even unconnected ones) */
7045 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
7046 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
7047 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
7048 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
7049 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
7050 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
7051 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
7052 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
7053
7054 { }
7055};
7056#endif
7057
Takashi Iwai63300792008-01-24 15:31:36 +01007058#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
7059#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07007060
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007061#define alc260_pcm_digital_playback alc880_pcm_digital_playback
7062#define alc260_pcm_digital_capture alc880_pcm_digital_capture
7063
Kailang Yangdf694da2005-12-05 19:42:22 +01007064/*
7065 * for BIOS auto-configuration
7066 */
7067
7068static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02007069 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01007070{
7071 hda_nid_t nid_vol;
7072 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01007073 int err;
7074
7075 if (nid >= 0x0f && nid < 0x11) {
7076 nid_vol = nid - 0x7;
7077 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
7078 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
7079 } else if (nid == 0x11) {
7080 nid_vol = nid - 0x7;
7081 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
7082 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
7083 } else if (nid >= 0x12 && nid <= 0x15) {
7084 nid_vol = 0x08;
7085 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
7086 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
7087 } else
7088 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02007089
Takashi Iwai863b4512008-10-21 17:01:47 +02007090 if (!(*vol_bits & (1 << nid_vol))) {
7091 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02007092 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02007093 if (err < 0)
7094 return err;
7095 *vol_bits |= (1 << nid_vol);
7096 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02007097 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007098 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007099 return err;
7100 return 1;
7101}
7102
7103/* add playback controls from the parsed DAC table */
7104static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
7105 const struct auto_pin_cfg *cfg)
7106{
7107 hda_nid_t nid;
7108 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02007109 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01007110
7111 spec->multiout.num_dacs = 1;
7112 spec->multiout.dac_nids = spec->private_dac_nids;
7113 spec->multiout.dac_nids[0] = 0x02;
7114
7115 nid = cfg->line_out_pins[0];
7116 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02007117 const char *pfx;
7118 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
7119 pfx = "Master";
7120 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
7121 pfx = "Speaker";
7122 else
7123 pfx = "Front";
7124 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01007125 if (err < 0)
7126 return err;
7127 }
7128
Takashi Iwai82bc9552006-03-21 11:24:42 +01007129 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007130 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02007131 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01007132 if (err < 0)
7133 return err;
7134 }
7135
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007136 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007137 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02007138 err = alc260_add_playback_controls(spec, nid, "Headphone",
7139 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01007140 if (err < 0)
7141 return err;
7142 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007143 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01007144}
7145
7146/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02007147static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01007148 const struct auto_pin_cfg *cfg)
7149{
Takashi Iwai05f5f472009-08-25 13:10:18 +02007150 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01007151}
7152
7153static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
7154 hda_nid_t nid, int pin_type,
7155 int sel_idx)
7156{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007157 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007158 /* need the manual connection? */
7159 if (nid >= 0x12) {
7160 int idx = nid - 0x12;
7161 snd_hda_codec_write(codec, idx + 0x0b, 0,
7162 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01007163 }
7164}
7165
7166static void alc260_auto_init_multi_out(struct hda_codec *codec)
7167{
7168 struct alc_spec *spec = codec->spec;
7169 hda_nid_t nid;
7170
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007171 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007172 if (nid) {
7173 int pin_type = get_pin_type(spec->autocfg.line_out_type);
7174 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
7175 }
Kailang Yangea1fb292008-08-26 12:58:38 +02007176
Takashi Iwai82bc9552006-03-21 11:24:42 +01007177 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007178 if (nid)
7179 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
7180
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007181 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007182 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007183 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007184}
Kailang Yangdf694da2005-12-05 19:42:22 +01007185
7186#define ALC260_PIN_CD_NID 0x16
7187static void alc260_auto_init_analog_input(struct hda_codec *codec)
7188{
7189 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02007190 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +01007191 int i;
7192
Takashi Iwai66ceeb62010-08-30 13:05:52 +02007193 for (i = 0; i < cfg->num_inputs; i++) {
7194 hda_nid_t nid = cfg->inputs[i].pin;
Kailang Yangdf694da2005-12-05 19:42:22 +01007195 if (nid >= 0x12) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02007196 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01007197 if (nid != ALC260_PIN_CD_NID &&
7198 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007199 snd_hda_codec_write(codec, nid, 0,
7200 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01007201 AMP_OUT_MUTE);
7202 }
7203 }
7204}
7205
Takashi Iwai7f311a42010-04-09 17:32:23 +02007206#define alc260_auto_init_input_src alc880_auto_init_input_src
7207
Kailang Yangdf694da2005-12-05 19:42:22 +01007208/*
7209 * generic initialization of ADC, input mixers and output mixers
7210 */
7211static struct hda_verb alc260_volume_init_verbs[] = {
7212 /*
7213 * Unmute ADC0-1 and set the default input to mic-in
7214 */
7215 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
7216 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7217 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
7218 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02007219
Kailang Yangdf694da2005-12-05 19:42:22 +01007220 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7221 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007222 * Note: PASD motherboards uses the Line In 2 as the input for
7223 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007224 */
7225 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007226 /* mute analog inputs */
7227 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7228 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7229 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7230 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7231 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007232
7233 /*
7234 * Set up output mixers (0x08 - 0x0a)
7235 */
7236 /* set vol=0 to output mixers */
7237 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7238 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7239 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7240 /* set up input amps for analog loopback */
7241 /* Amp Indices: DAC = 0, mixer = 1 */
7242 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7243 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7244 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7245 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7246 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7247 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02007248
Kailang Yangdf694da2005-12-05 19:42:22 +01007249 { }
7250};
7251
7252static int alc260_parse_auto_config(struct hda_codec *codec)
7253{
7254 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007255 int err;
7256 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
7257
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007258 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7259 alc260_ignore);
7260 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007261 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007262 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
7263 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01007264 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02007265 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01007266 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02007267 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007268 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007269 return err;
7270
7271 spec->multiout.max_channels = 2;
7272
Takashi Iwai0852d7a2009-02-11 11:35:15 +01007273 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007274 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02007275 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01007276 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01007277
Takashi Iwaid88897e2008-10-31 15:01:37 +01007278 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01007279
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007280 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007281 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007282
Kailang Yang6227cdc2010-02-25 08:36:52 +01007283 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02007284
Kailang Yangdf694da2005-12-05 19:42:22 +01007285 return 1;
7286}
7287
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007288/* additional initialization for auto-configuration model */
7289static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007290{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007291 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007292 alc260_auto_init_multi_out(codec);
7293 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02007294 alc260_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02007295 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007296 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007297 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007298}
7299
Takashi Iwaicb53c622007-08-10 17:21:45 +02007300#ifdef CONFIG_SND_HDA_POWER_SAVE
7301static struct hda_amp_list alc260_loopbacks[] = {
7302 { 0x07, HDA_INPUT, 0 },
7303 { 0x07, HDA_INPUT, 1 },
7304 { 0x07, HDA_INPUT, 2 },
7305 { 0x07, HDA_INPUT, 3 },
7306 { 0x07, HDA_INPUT, 4 },
7307 { } /* end */
7308};
7309#endif
7310
Kailang Yangdf694da2005-12-05 19:42:22 +01007311/*
Takashi Iwaifc091762010-08-04 23:53:36 +02007312 * Pin config fixes
7313 */
7314enum {
7315 PINFIX_HP_DC5750,
7316};
7317
Takashi Iwaifc091762010-08-04 23:53:36 +02007318static const struct alc_fixup alc260_fixups[] = {
7319 [PINFIX_HP_DC5750] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007320 .type = ALC_FIXUP_PINS,
7321 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +02007322 { 0x11, 0x90130110 }, /* speaker */
7323 { }
7324 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007325 },
7326};
7327
7328static struct snd_pci_quirk alc260_fixup_tbl[] = {
7329 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
7330 {}
7331};
7332
7333/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007334 * ALC260 configurations
7335 */
Takashi Iwaiea734962011-01-17 11:29:34 +01007336static const char * const alc260_models[ALC260_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007337 [ALC260_BASIC] = "basic",
7338 [ALC260_HP] = "hp",
7339 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02007340 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007341 [ALC260_FUJITSU_S702X] = "fujitsu",
7342 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007343 [ALC260_WILL] = "will",
7344 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01007345 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01007346#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007347 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01007348#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007349 [ALC260_AUTO] = "auto",
7350};
7351
7352static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01007353 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05007354 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007355 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01007356 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01007357 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01007358 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007359 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02007360 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02007361 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007362 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
7363 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
7364 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
7365 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
7366 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
7367 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
7368 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
7369 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
7370 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007371 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007372 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02007373 {}
7374};
7375
Kailang Yangdf694da2005-12-05 19:42:22 +01007376static struct alc_config_preset alc260_presets[] = {
7377 [ALC260_BASIC] = {
7378 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007379 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007380 .init_verbs = { alc260_init_verbs },
7381 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7382 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007383 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01007384 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007385 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7386 .channel_mode = alc260_modes,
7387 .input_mux = &alc260_capture_source,
7388 },
7389 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01007390 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007391 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007392 .init_verbs = { alc260_init_verbs,
7393 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007394 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7395 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007396 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7397 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007398 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7399 .channel_mode = alc260_modes,
7400 .input_mux = &alc260_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +02007401 .unsol_event = alc_sku_unsol_event,
7402 .setup = alc260_hp_setup,
7403 .init_hook = alc_inithook,
Kailang Yangdf694da2005-12-05 19:42:22 +01007404 },
Kailang Yang3f878302008-08-26 13:02:23 +02007405 [ALC260_HP_DC7600] = {
7406 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007407 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02007408 .init_verbs = { alc260_init_verbs,
7409 alc260_hp_dc7600_verbs },
7410 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7411 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007412 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7413 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02007414 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7415 .channel_mode = alc260_modes,
7416 .input_mux = &alc260_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +02007417 .unsol_event = alc_sku_unsol_event,
7418 .setup = alc260_hp_3012_setup,
7419 .init_hook = alc_inithook,
Kailang Yang3f878302008-08-26 13:02:23 +02007420 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007421 [ALC260_HP_3013] = {
7422 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007423 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007424 .init_verbs = { alc260_hp_3013_init_verbs,
7425 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007426 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7427 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007428 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7429 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007430 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7431 .channel_mode = alc260_modes,
7432 .input_mux = &alc260_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +02007433 .unsol_event = alc_sku_unsol_event,
7434 .setup = alc260_hp_3013_setup,
7435 .init_hook = alc_inithook,
Kailang Yangdf694da2005-12-05 19:42:22 +01007436 },
7437 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007438 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007439 .init_verbs = { alc260_fujitsu_init_verbs },
7440 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7441 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01007442 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7443 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007444 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7445 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007446 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
7447 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01007448 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007449 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007450 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007451 .init_verbs = { alc260_acer_init_verbs },
7452 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7453 .dac_nids = alc260_dac_nids,
7454 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7455 .adc_nids = alc260_dual_adc_nids,
7456 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7457 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007458 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
7459 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007460 },
Michael Schwingencc959482009-02-22 18:58:45 +01007461 [ALC260_FAVORIT100] = {
7462 .mixers = { alc260_favorit100_mixer },
7463 .init_verbs = { alc260_favorit100_init_verbs },
7464 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7465 .dac_nids = alc260_dac_nids,
7466 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7467 .adc_nids = alc260_dual_adc_nids,
7468 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7469 .channel_mode = alc260_modes,
7470 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
7471 .input_mux = alc260_favorit100_capture_sources,
7472 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007473 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007474 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007475 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
7476 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7477 .dac_nids = alc260_dac_nids,
7478 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7479 .adc_nids = alc260_adc_nids,
7480 .dig_out_nid = ALC260_DIGOUT_NID,
7481 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7482 .channel_mode = alc260_modes,
7483 .input_mux = &alc260_capture_source,
7484 },
7485 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007486 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007487 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
7488 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7489 .dac_nids = alc260_dac_nids,
7490 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7491 .adc_nids = alc260_adc_nids,
7492 .dig_out_nid = ALC260_DIGOUT_NID,
7493 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7494 .channel_mode = alc260_modes,
7495 .input_mux = &alc260_capture_source,
7496 .unsol_event = alc260_replacer_672v_unsol_event,
7497 .init_hook = alc260_replacer_672v_automute,
7498 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01007499#ifdef CONFIG_SND_DEBUG
7500 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007501 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01007502 .init_verbs = { alc260_test_init_verbs },
7503 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
7504 .dac_nids = alc260_test_dac_nids,
7505 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
7506 .adc_nids = alc260_test_adc_nids,
7507 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7508 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007509 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
7510 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01007511 },
7512#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01007513};
7514
Linus Torvalds1da177e2005-04-16 15:20:36 -07007515static int patch_alc260(struct hda_codec *codec)
7516{
7517 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007518 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007519
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007520 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007521 if (spec == NULL)
7522 return -ENOMEM;
7523
7524 codec->spec = spec;
7525
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007526 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
7527 alc260_models,
7528 alc260_cfg_tbl);
7529 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02007530 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02007531 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01007532 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02007533 }
7534
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007535 if (board_config == ALC260_AUTO) {
7536 alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups);
7537 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
7538 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007539
Kailang Yangdf694da2005-12-05 19:42:22 +01007540 if (board_config == ALC260_AUTO) {
7541 /* automatic parse from the BIOS config */
7542 err = alc260_parse_auto_config(codec);
7543 if (err < 0) {
7544 alc_free(codec);
7545 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007546 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007547 printk(KERN_INFO
7548 "hda_codec: Cannot set up configuration "
7549 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007550 board_config = ALC260_BASIC;
7551 }
Takashi Iwai16ded522005-06-10 19:58:24 +02007552 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007553
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007554 err = snd_hda_attach_beep_device(codec, 0x1);
7555 if (err < 0) {
7556 alc_free(codec);
7557 return err;
7558 }
7559
Kailang Yangdf694da2005-12-05 19:42:22 +01007560 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02007561 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007562
Linus Torvalds1da177e2005-04-16 15:20:36 -07007563 spec->stream_analog_playback = &alc260_pcm_analog_playback;
7564 spec->stream_analog_capture = &alc260_pcm_analog_capture;
Jonathan Woithe53bacfb2010-08-08 00:17:05 +09307565 spec->stream_analog_alt_capture = &alc260_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007566
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007567 spec->stream_digital_playback = &alc260_pcm_digital_playback;
7568 spec->stream_digital_capture = &alc260_pcm_digital_capture;
7569
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007570 if (!spec->adc_nids && spec->input_mux) {
7571 /* check whether NID 0x04 is valid */
7572 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02007573 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007574 /* get type */
7575 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
7576 spec->adc_nids = alc260_adc_nids_alt;
7577 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
7578 } else {
7579 spec->adc_nids = alc260_adc_nids;
7580 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
7581 }
7582 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02007583 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007584 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007585
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007586 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwaifc091762010-08-04 23:53:36 +02007587
Takashi Iwai2134ea42008-01-10 16:53:55 +01007588 spec->vmaster_nid = 0x08;
7589
Linus Torvalds1da177e2005-04-16 15:20:36 -07007590 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007591 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007592 spec->init_hook = alc260_auto_init;
Takashi Iwai1c716152011-04-07 10:37:16 +02007593 spec->shutup = alc_eapd_shutup;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007594#ifdef CONFIG_SND_HDA_POWER_SAVE
7595 if (!spec->loopback.amplist)
7596 spec->loopback.amplist = alc260_loopbacks;
7597#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07007598
7599 return 0;
7600}
7601
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007602
Linus Torvalds1da177e2005-04-16 15:20:36 -07007603/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007604 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07007605 *
7606 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
7607 * configuration. Each pin widget can choose any input DACs and a mixer.
7608 * Each ADC is connected from a mixer of all inputs. This makes possible
7609 * 6-channel independent captures.
7610 *
7611 * In addition, an independent DAC for the multi-playback (not used in this
7612 * driver yet).
7613 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007614#define ALC882_DIGOUT_NID 0x06
7615#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02007616#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
7617#define ALC883_DIGIN_NID ALC882_DIGIN_NID
7618#define ALC1200_DIGOUT_NID 0x10
7619
Linus Torvalds1da177e2005-04-16 15:20:36 -07007620
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01007621static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007622 { 8, NULL }
7623};
7624
Takashi Iwai4953550a2009-06-30 15:28:30 +02007625/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007626static hda_nid_t alc882_dac_nids[4] = {
7627 /* front, rear, clfe, rear_surr */
7628 0x02, 0x03, 0x04, 0x05
7629};
Takashi Iwai4953550a2009-06-30 15:28:30 +02007630#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007631
Takashi Iwai4953550a2009-06-30 15:28:30 +02007632/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01007633#define alc882_adc_nids alc880_adc_nids
7634#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02007635#define alc883_adc_nids alc882_adc_nids_alt
7636static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
7637static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
7638#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007639
Takashi Iwaie1406342008-02-11 18:32:32 +01007640static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
7641static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007642#define alc883_capsrc_nids alc882_capsrc_nids_alt
7643static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7644#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01007645
Linus Torvalds1da177e2005-04-16 15:20:36 -07007646/* input MUX */
7647/* FIXME: should be a matrix-type input source selection */
7648
7649static struct hda_input_mux alc882_capture_source = {
7650 .num_items = 4,
7651 .items = {
7652 { "Mic", 0x0 },
7653 { "Front Mic", 0x1 },
7654 { "Line", 0x2 },
7655 { "CD", 0x4 },
7656 },
7657};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007658
Takashi Iwai4953550a2009-06-30 15:28:30 +02007659#define alc883_capture_source alc882_capture_source
7660
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007661static struct hda_input_mux alc889_capture_source = {
7662 .num_items = 3,
7663 .items = {
7664 { "Front Mic", 0x0 },
7665 { "Mic", 0x3 },
7666 { "Line", 0x2 },
7667 },
7668};
7669
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007670static struct hda_input_mux mb5_capture_source = {
7671 .num_items = 3,
7672 .items = {
7673 { "Mic", 0x1 },
Alex Murrayb8f171e2010-06-14 12:08:43 +09307674 { "Line", 0x7 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007675 { "CD", 0x4 },
7676 },
7677};
7678
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007679static struct hda_input_mux macmini3_capture_source = {
7680 .num_items = 2,
7681 .items = {
7682 { "Line", 0x2 },
7683 { "CD", 0x4 },
7684 },
7685};
7686
Takashi Iwai4953550a2009-06-30 15:28:30 +02007687static struct hda_input_mux alc883_3stack_6ch_intel = {
7688 .num_items = 4,
7689 .items = {
7690 { "Mic", 0x1 },
7691 { "Front Mic", 0x0 },
7692 { "Line", 0x2 },
7693 { "CD", 0x4 },
7694 },
7695};
7696
7697static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7698 .num_items = 2,
7699 .items = {
7700 { "Mic", 0x1 },
7701 { "Line", 0x2 },
7702 },
7703};
7704
7705static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7706 .num_items = 4,
7707 .items = {
7708 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +01007709 { "Internal Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007710 { "Line", 0x2 },
7711 { "CD", 0x4 },
7712 },
7713};
7714
7715static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7716 .num_items = 2,
7717 .items = {
7718 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +01007719 { "Internal Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007720 },
7721};
7722
7723static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7724 .num_items = 3,
7725 .items = {
7726 { "Mic", 0x0 },
7727 { "Front Mic", 0x1 },
7728 { "Line", 0x4 },
7729 },
7730};
7731
7732static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7733 .num_items = 2,
7734 .items = {
7735 { "Mic", 0x0 },
7736 { "Line", 0x2 },
7737 },
7738};
7739
7740static struct hda_input_mux alc889A_mb31_capture_source = {
7741 .num_items = 2,
7742 .items = {
7743 { "Mic", 0x0 },
7744 /* Front Mic (0x01) unused */
7745 { "Line", 0x2 },
7746 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007747 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007748 },
7749};
7750
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007751static struct hda_input_mux alc889A_imac91_capture_source = {
7752 .num_items = 2,
7753 .items = {
7754 { "Mic", 0x01 },
7755 { "Line", 0x2 }, /* Not sure! */
7756 },
7757};
7758
Takashi Iwai4953550a2009-06-30 15:28:30 +02007759/*
7760 * 2ch mode
7761 */
7762static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7763 { 2, NULL }
7764};
7765
Kailang Yangdf694da2005-12-05 19:42:22 +01007766/*
Kailang Yang272a5272007-05-14 11:00:38 +02007767 * 2ch mode
7768 */
7769static struct hda_verb alc882_3ST_ch2_init[] = {
7770 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7771 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7772 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7773 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7774 { } /* end */
7775};
7776
7777/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007778 * 4ch mode
7779 */
7780static struct hda_verb alc882_3ST_ch4_init[] = {
7781 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7782 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7783 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7784 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7785 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7786 { } /* end */
7787};
7788
7789/*
Kailang Yang272a5272007-05-14 11:00:38 +02007790 * 6ch mode
7791 */
7792static struct hda_verb alc882_3ST_ch6_init[] = {
7793 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7794 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7795 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7796 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7797 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7798 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7799 { } /* end */
7800};
7801
Takashi Iwai4953550a2009-06-30 15:28:30 +02007802static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007803 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007804 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007805 { 6, alc882_3ST_ch6_init },
7806};
7807
Takashi Iwai4953550a2009-06-30 15:28:30 +02007808#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7809
Kailang Yang272a5272007-05-14 11:00:38 +02007810/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307811 * 2ch mode
7812 */
7813static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7814 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7815 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7816 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7817 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7818 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7819 { } /* end */
7820};
7821
7822/*
7823 * 4ch mode
7824 */
7825static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7826 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7827 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7828 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7829 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7830 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7831 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7832 { } /* end */
7833};
7834
7835/*
7836 * 6ch mode
7837 */
7838static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7839 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7840 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7841 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7842 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7843 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7844 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7845 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7846 { } /* end */
7847};
7848
7849static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7850 { 2, alc883_3ST_ch2_clevo_init },
7851 { 4, alc883_3ST_ch4_clevo_init },
7852 { 6, alc883_3ST_ch6_clevo_init },
7853};
7854
7855
7856/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007857 * 6ch mode
7858 */
7859static struct hda_verb alc882_sixstack_ch6_init[] = {
7860 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7861 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7862 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7863 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7864 { } /* end */
7865};
7866
7867/*
7868 * 8ch mode
7869 */
7870static struct hda_verb alc882_sixstack_ch8_init[] = {
7871 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7872 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7873 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7874 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7875 { } /* end */
7876};
7877
7878static struct hda_channel_mode alc882_sixstack_modes[2] = {
7879 { 6, alc882_sixstack_ch6_init },
7880 { 8, alc882_sixstack_ch8_init },
7881};
7882
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007883
7884/* Macbook Air 2,1 */
7885
7886static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7887 { 2, NULL },
7888};
7889
Takashi Iwai87350ad2007-08-16 18:19:38 +02007890/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007891 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007892 */
7893
7894/*
7895 * 2ch mode
7896 */
7897static struct hda_verb alc885_mbp_ch2_init[] = {
7898 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7899 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7900 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7901 { } /* end */
7902};
7903
7904/*
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007905 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007906 */
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007907static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007908 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7909 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7910 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7911 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7912 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7913 { } /* end */
7914};
7915
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007916static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007917 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007918 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007919};
7920
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007921/*
7922 * 2ch
7923 * Speakers/Woofer/HP = Front
7924 * LineIn = Input
7925 */
7926static struct hda_verb alc885_mb5_ch2_init[] = {
7927 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7928 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7929 { } /* end */
7930};
7931
7932/*
7933 * 6ch mode
7934 * Speakers/HP = Front
7935 * Woofer = LFE
7936 * LineIn = Surround
7937 */
7938static struct hda_verb alc885_mb5_ch6_init[] = {
7939 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7940 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7941 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7942 { } /* end */
7943};
7944
7945static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7946 { 2, alc885_mb5_ch2_init },
7947 { 6, alc885_mb5_ch6_init },
7948};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007949
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007950#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007951
7952/*
7953 * 2ch mode
7954 */
7955static struct hda_verb alc883_4ST_ch2_init[] = {
7956 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7957 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7958 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7959 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7960 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7961 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7962 { } /* end */
7963};
7964
7965/*
7966 * 4ch mode
7967 */
7968static struct hda_verb alc883_4ST_ch4_init[] = {
7969 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7970 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7971 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7972 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7973 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7974 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7975 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7976 { } /* end */
7977};
7978
7979/*
7980 * 6ch mode
7981 */
7982static struct hda_verb alc883_4ST_ch6_init[] = {
7983 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7984 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7985 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7986 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7987 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7988 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7989 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7990 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7991 { } /* end */
7992};
7993
7994/*
7995 * 8ch mode
7996 */
7997static struct hda_verb alc883_4ST_ch8_init[] = {
7998 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7999 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8000 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
8001 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8002 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8003 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
8004 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8005 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8006 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
8007 { } /* end */
8008};
8009
8010static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
8011 { 2, alc883_4ST_ch2_init },
8012 { 4, alc883_4ST_ch4_init },
8013 { 6, alc883_4ST_ch6_init },
8014 { 8, alc883_4ST_ch8_init },
8015};
8016
8017
8018/*
8019 * 2ch mode
8020 */
8021static struct hda_verb alc883_3ST_ch2_intel_init[] = {
8022 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8023 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8024 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8025 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8026 { } /* end */
8027};
8028
8029/*
8030 * 4ch mode
8031 */
8032static struct hda_verb alc883_3ST_ch4_intel_init[] = {
8033 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8034 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8035 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8036 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8037 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
8038 { } /* end */
8039};
8040
8041/*
8042 * 6ch mode
8043 */
8044static struct hda_verb alc883_3ST_ch6_intel_init[] = {
8045 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8046 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8047 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
8048 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8049 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8050 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
8051 { } /* end */
8052};
8053
8054static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
8055 { 2, alc883_3ST_ch2_intel_init },
8056 { 4, alc883_3ST_ch4_intel_init },
8057 { 6, alc883_3ST_ch6_intel_init },
8058};
8059
8060/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08008061 * 2ch mode
8062 */
8063static struct hda_verb alc889_ch2_intel_init[] = {
8064 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
8065 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
8066 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
8067 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
8068 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8069 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8070 { } /* end */
8071};
8072
8073/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02008074 * 6ch mode
8075 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008076static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08008077 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
8078 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
8079 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
8080 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
8081 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008082 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8083 { } /* end */
8084};
8085
8086/*
8087 * 8ch mode
8088 */
8089static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08008090 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
8091 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
8092 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
8093 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
8094 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008095 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8096 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008097 { } /* end */
8098};
8099
Wu Fengguangdd7714c2009-07-30 14:36:35 +08008100static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
8101 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008102 { 6, alc889_ch6_intel_init },
8103 { 8, alc889_ch8_intel_init },
8104};
8105
8106/*
8107 * 6ch mode
8108 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008109static struct hda_verb alc883_sixstack_ch6_init[] = {
8110 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8111 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8112 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8113 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8114 { } /* end */
8115};
8116
8117/*
8118 * 8ch mode
8119 */
8120static struct hda_verb alc883_sixstack_ch8_init[] = {
8121 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8122 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8123 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8124 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8125 { } /* end */
8126};
8127
8128static struct hda_channel_mode alc883_sixstack_modes[2] = {
8129 { 6, alc883_sixstack_ch6_init },
8130 { 8, alc883_sixstack_ch8_init },
8131};
8132
8133
Linus Torvalds1da177e2005-04-16 15:20:36 -07008134/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
8135 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
8136 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01008137static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02008138 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01008139 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02008140 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01008141 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02008142 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8143 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01008144 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8145 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02008146 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01008147 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07008148 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8149 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8150 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8151 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8152 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8153 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008154 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07008155 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8156 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008157 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07008158 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07008159 { } /* end */
8160};
8161
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008162/* Macbook Air 2,1 same control for HP and internal Speaker */
8163
8164static struct snd_kcontrol_new alc885_mba21_mixer[] = {
8165 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8166 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
8167 { }
8168};
8169
8170
Takashi Iwai87350ad2007-08-16 18:19:38 +02008171static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730a2009-08-31 08:15:26 +02008172 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8173 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
8174 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
8175 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
8176 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01008177 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8178 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02008179 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8180 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008181 HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
8182 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02008183 { } /* end */
8184};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008185
8186static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008187 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8188 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8189 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8190 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8191 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
8192 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10308193 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
8194 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Alex Murrayb8f171e2010-06-14 12:08:43 +09308195 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
8196 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008197 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8198 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008199 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
8200 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0x00, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008201 { } /* end */
8202};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008203
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008204static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
8205 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8206 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8207 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8208 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8209 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
8210 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
8211 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
8212 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
8213 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
8214 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008215 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008216 { } /* end */
8217};
8218
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008219static struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008220 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8221 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008222 { } /* end */
8223};
8224
8225
Kailang Yangbdd148a2007-05-08 15:19:08 +02008226static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
8227 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8228 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8229 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8230 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8231 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8232 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8233 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008234 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02008235 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02008236 { } /* end */
8237};
8238
Kailang Yang272a5272007-05-14 11:00:38 +02008239static struct snd_kcontrol_new alc882_targa_mixer[] = {
8240 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8241 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8242 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8243 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8244 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8245 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8246 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8247 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8248 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008249 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008250 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8251 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008252 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008253 { } /* end */
8254};
8255
8256/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
8257 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
8258 */
8259static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
8260 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8261 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8262 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8263 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
8264 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8265 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8266 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8267 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8268 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
8269 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
8270 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8271 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008272 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008273 { } /* end */
8274};
8275
Takashi Iwai914759b2007-09-06 14:52:04 +02008276static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
8277 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8278 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8279 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8280 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8281 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8282 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8283 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8284 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008285 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008286 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008287 { } /* end */
8288};
8289
Kailang Yangdf694da2005-12-05 19:42:22 +01008290static struct snd_kcontrol_new alc882_chmode_mixer[] = {
8291 {
8292 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8293 .name = "Channel Mode",
8294 .info = alc_ch_mode_info,
8295 .get = alc_ch_mode_get,
8296 .put = alc_ch_mode_put,
8297 },
8298 { } /* end */
8299};
8300
Takashi Iwai4953550a2009-06-30 15:28:30 +02008301static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07008302 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008303 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8304 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008305 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008306 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8307 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008308 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008309 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8310 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008311 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008312 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8313 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008314
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008315 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008316 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008317 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008318 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008319 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008320 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008321 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008322 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008323 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008324 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008325 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008326 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008327 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008328 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008329 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008330 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008331 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008332 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008333 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8334 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008335 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008336 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8337 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008338 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008339 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8340 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8341 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8342 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8343 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008344 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008345 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008346
8347 /* FIXME: use matrix-type input source selection */
8348 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008349 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008350 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008351 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008352 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02008353 /* ADC2: mute amp left and right */
8354 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008355 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02008356 /* ADC3: mute amp left and right */
8357 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008358 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008359
8360 { }
8361};
8362
Takashi Iwai4953550a2009-06-30 15:28:30 +02008363static struct hda_verb alc882_adc1_init_verbs[] = {
8364 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8365 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8366 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8367 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8368 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8369 /* ADC1: mute amp left and right */
8370 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8371 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8372 { }
8373};
8374
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008375static struct hda_verb alc882_eapd_verbs[] = {
8376 /* change to EAPD mode */
8377 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008378 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008379 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008380};
8381
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008382static struct hda_verb alc889_eapd_verbs[] = {
8383 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8384 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8385 { }
8386};
8387
Wu Fengguang6732bd02009-07-30 09:19:14 +02008388static struct hda_verb alc_hp15_unsol_verbs[] = {
8389 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8390 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8391 {}
8392};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008393
8394static struct hda_verb alc885_init_verbs[] = {
8395 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01008396 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8397 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008398 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008399 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8400 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008401 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008402 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8403 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008404 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008405 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8406 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008407
8408 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02008409 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008410 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8411 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8412 /* Front Pin: output 0 (0x0c) */
8413 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8414 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8415 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8416 /* Rear Pin: output 1 (0x0d) */
8417 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8418 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8419 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
8420 /* CLFE Pin: output 2 (0x0e) */
8421 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8422 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8423 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8424 /* Side Pin: output 3 (0x0f) */
8425 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8426 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8427 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8428 /* Mic (rear) pin: input vref at 80% */
8429 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8430 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8431 /* Front Mic pin: input vref at 80% */
8432 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8433 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8434 /* Line In pin: input */
8435 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8436 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8437
8438 /* Mixer elements: 0x18, , 0x1a, 0x1b */
8439 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01008440 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008441 /* Input mixer2 */
8442 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008443 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008444 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008445 /* ADC2: mute amp left and right */
8446 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8447 /* ADC3: mute amp left and right */
8448 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8449
8450 { }
8451};
8452
8453static struct hda_verb alc885_init_input_verbs[] = {
8454 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8455 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8456 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8457 { }
8458};
8459
8460
8461/* Unmute Selector 24h and set the default input to front mic */
8462static struct hda_verb alc889_init_input_verbs[] = {
8463 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
8464 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8465 { }
8466};
8467
8468
Takashi Iwai4953550a2009-06-30 15:28:30 +02008469#define alc883_init_verbs alc882_base_init_verbs
8470
Tobin Davis9102cd12006-12-15 10:02:12 +01008471/* Mac Pro test */
8472static struct snd_kcontrol_new alc882_macpro_mixer[] = {
8473 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8474 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8475 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
8476 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8477 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008478 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01008479 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
8480 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008481 */
Tobin Davis9102cd12006-12-15 10:02:12 +01008482 { } /* end */
8483};
8484
8485static struct hda_verb alc882_macpro_init_verbs[] = {
8486 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8487 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8488 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8489 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8490 /* Front Pin: output 0 (0x0c) */
8491 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8492 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8493 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8494 /* Front Mic pin: input vref at 80% */
8495 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8496 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8497 /* Speaker: output */
8498 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8499 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8500 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
8501 /* Headphone output (output 0 - 0x0c) */
8502 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8503 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8504 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8505
8506 /* FIXME: use matrix-type input source selection */
8507 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8508 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8509 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8510 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8511 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8512 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8513 /* Input mixer2 */
8514 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8515 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8516 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8517 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8518 /* Input mixer3 */
8519 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8520 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8521 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8522 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8523 /* ADC1: mute amp left and right */
8524 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8525 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8526 /* ADC2: mute amp left and right */
8527 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8528 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8529 /* ADC3: mute amp left and right */
8530 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8531 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8532
8533 { }
8534};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008535
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008536/* Macbook 5,1 */
8537static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008538 /* DACs */
8539 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8540 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8541 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8542 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008543 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008544 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8545 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8546 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008547 /* Surround mixer */
8548 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8549 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8550 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8551 /* LFE mixer */
8552 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8553 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8554 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8555 /* HP mixer */
8556 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8557 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8558 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8559 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008560 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8561 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008562 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8563 /* LFE Pin (0x0e) */
8564 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8565 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8566 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8567 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008568 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8569 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008570 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10308571 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008572 /* Front Mic pin: input vref at 80% */
8573 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8574 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8575 /* Line In pin */
8576 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8577 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8578
Alex Murrayb8f171e2010-06-14 12:08:43 +09308579 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
8580 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
8581 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008582 { }
8583};
8584
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008585/* Macmini 3,1 */
8586static struct hda_verb alc885_macmini3_init_verbs[] = {
8587 /* DACs */
8588 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8589 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8590 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8591 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8592 /* Front mixer */
8593 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8594 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8595 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8596 /* Surround mixer */
8597 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8598 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8599 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8600 /* LFE mixer */
8601 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8602 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8603 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8604 /* HP mixer */
8605 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8606 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8607 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8608 /* Front Pin (0x0c) */
8609 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8610 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8611 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8612 /* LFE Pin (0x0e) */
8613 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8614 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8615 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8616 /* HP Pin (0x0f) */
8617 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8618 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8619 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
8620 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8621 /* Line In pin */
8622 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8623 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8624
8625 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8626 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8627 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8628 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8629 { }
8630};
8631
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008632
8633static struct hda_verb alc885_mba21_init_verbs[] = {
8634 /*Internal and HP Speaker Mixer*/
8635 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8636 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8637 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8638 /*Internal Speaker Pin (0x0c)*/
8639 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8640 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8641 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8642 /* HP Pin: output 0 (0x0e) */
8643 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
8644 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8645 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8646 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8647 /* Line in (is hp when jack connected)*/
8648 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8649 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8650
8651 { }
8652 };
8653
8654
Takashi Iwai87350ad2007-08-16 18:19:38 +02008655/* Macbook Pro rev3 */
8656static struct hda_verb alc885_mbp3_init_verbs[] = {
8657 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8658 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8659 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8660 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8661 /* Rear mixer */
8662 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8663 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8664 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02008665 /* HP mixer */
8666 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8667 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8668 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008669 /* Front Pin: output 0 (0x0c) */
8670 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8671 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8672 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02008673 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02008674 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02008675 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8676 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008677 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8678 /* Mic (rear) pin: input vref at 80% */
8679 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8680 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8681 /* Front Mic pin: input vref at 80% */
8682 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8683 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8684 /* Line In pin: use output 1 when in LineOut mode */
8685 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8686 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8687 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8688
8689 /* FIXME: use matrix-type input source selection */
8690 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8691 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8692 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8693 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8694 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8695 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8696 /* Input mixer2 */
8697 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8698 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8699 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8700 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8701 /* Input mixer3 */
8702 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8703 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8704 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8705 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8706 /* ADC1: mute amp left and right */
8707 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8708 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8709 /* ADC2: mute amp left and right */
8710 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8711 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8712 /* ADC3: mute amp left and right */
8713 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8714 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8715
8716 { }
8717};
8718
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008719/* iMac 9,1 */
8720static struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008721 /* Internal Speaker Pin (0x0c) */
8722 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8723 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8724 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8725 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8726 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8727 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8728 /* HP Pin: Rear */
8729 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8730 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8731 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8732 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8733 /* Line in Rear */
8734 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8735 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8736 /* Front Mic pin: input vref at 80% */
8737 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8738 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008739 /* Rear mixer */
8740 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8741 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8742 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008743 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8744 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8745 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8746 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8747 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008748 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8749 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8750 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8751 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008752 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008753 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8754 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8755 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8756 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008757 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008758 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8759 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8760 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8761 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008762 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008763 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8764 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008765 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008766 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8767 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008768 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008769 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8770 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008771 { }
8772};
8773
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008774/* iMac 24 mixer. */
8775static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8776 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8777 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8778 { } /* end */
8779};
8780
8781/* iMac 24 init verbs. */
8782static struct hda_verb alc885_imac24_init_verbs[] = {
8783 /* Internal speakers: output 0 (0x0c) */
8784 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8785 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8786 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8787 /* Internal speakers: output 0 (0x0c) */
8788 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8789 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8790 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8791 /* Headphone: output 0 (0x0c) */
8792 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8793 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8794 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8795 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8796 /* Front Mic: input vref at 80% */
8797 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8798 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8799 { }
8800};
8801
8802/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008803static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008804{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008805 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008806
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008807 spec->autocfg.hp_pins[0] = 0x14;
8808 spec->autocfg.speaker_pins[0] = 0x18;
8809 spec->autocfg.speaker_pins[1] = 0x1a;
Takashi Iwaid922b512011-04-28 12:18:53 +02008810 spec->automute = 1;
8811 spec->automute_mode = ALC_AUTOMUTE_AMP;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008812}
8813
Takashi Iwai9d54f082010-02-22 08:34:40 +01008814#define alc885_mb5_setup alc885_imac24_setup
8815#define alc885_macmini3_setup alc885_imac24_setup
8816
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008817/* Macbook Air 2,1 */
8818static void alc885_mba21_setup(struct hda_codec *codec)
8819{
8820 struct alc_spec *spec = codec->spec;
8821
8822 spec->autocfg.hp_pins[0] = 0x14;
8823 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwaid922b512011-04-28 12:18:53 +02008824 spec->automute = 1;
8825 spec->automute_mode = ALC_AUTOMUTE_AMP;
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008826}
8827
8828
8829
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008830static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008831{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008832 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008833
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008834 spec->autocfg.hp_pins[0] = 0x15;
8835 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +02008836 spec->automute = 1;
8837 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008838}
8839
Takashi Iwai9d54f082010-02-22 08:34:40 +01008840static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308841{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008842 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308843
Takashi Iwai9d54f082010-02-22 08:34:40 +01008844 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008845 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008846 spec->autocfg.speaker_pins[1] = 0x1a;
Takashi Iwaid922b512011-04-28 12:18:53 +02008847 spec->automute = 1;
8848 spec->automute_mode = ALC_AUTOMUTE_AMP;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008849}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008850
Kailang Yang272a5272007-05-14 11:00:38 +02008851static struct hda_verb alc882_targa_verbs[] = {
8852 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8853 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8854
8855 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8856 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008857
Kailang Yang272a5272007-05-14 11:00:38 +02008858 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8859 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8860 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8861
8862 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008863 { } /* end */
8864};
8865
8866/* toggle speaker-output according to the hp-jack state */
8867static void alc882_targa_automute(struct hda_codec *codec)
8868{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008869 struct alc_spec *spec = codec->spec;
Takashi Iwaid922b512011-04-28 12:18:53 +02008870 alc_hp_automute(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008871 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008872 spec->jack_present ? 1 : 3);
8873}
8874
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008875static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008876{
8877 struct alc_spec *spec = codec->spec;
8878
8879 spec->autocfg.hp_pins[0] = 0x14;
8880 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaid922b512011-04-28 12:18:53 +02008881 spec->automute = 1;
8882 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yang272a5272007-05-14 11:00:38 +02008883}
8884
8885static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8886{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008887 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008888 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008889}
8890
8891static struct hda_verb alc882_asus_a7j_verbs[] = {
8892 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8893 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8894
8895 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8896 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8897 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008898
Kailang Yang272a5272007-05-14 11:00:38 +02008899 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8900 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8901 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8902
8903 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8904 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8905 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8906 { } /* end */
8907};
8908
Takashi Iwai914759b2007-09-06 14:52:04 +02008909static struct hda_verb alc882_asus_a7m_verbs[] = {
8910 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8911 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8912
8913 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8914 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8915 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008916
Takashi Iwai914759b2007-09-06 14:52:04 +02008917 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8918 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8919 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8920
8921 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8922 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8923 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8924 { } /* end */
8925};
8926
Tobin Davis9102cd12006-12-15 10:02:12 +01008927static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8928{
8929 unsigned int gpiostate, gpiomask, gpiodir;
8930
8931 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8932 AC_VERB_GET_GPIO_DATA, 0);
8933
8934 if (!muted)
8935 gpiostate |= (1 << pin);
8936 else
8937 gpiostate &= ~(1 << pin);
8938
8939 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8940 AC_VERB_GET_GPIO_MASK, 0);
8941 gpiomask |= (1 << pin);
8942
8943 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8944 AC_VERB_GET_GPIO_DIRECTION, 0);
8945 gpiodir |= (1 << pin);
8946
8947
8948 snd_hda_codec_write(codec, codec->afg, 0,
8949 AC_VERB_SET_GPIO_MASK, gpiomask);
8950 snd_hda_codec_write(codec, codec->afg, 0,
8951 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8952
8953 msleep(1);
8954
8955 snd_hda_codec_write(codec, codec->afg, 0,
8956 AC_VERB_SET_GPIO_DATA, gpiostate);
8957}
8958
Takashi Iwai7debbe52007-08-16 15:01:03 +02008959/* set up GPIO at initialization */
8960static void alc885_macpro_init_hook(struct hda_codec *codec)
8961{
8962 alc882_gpio_mute(codec, 0, 0);
8963 alc882_gpio_mute(codec, 1, 0);
8964}
8965
8966/* set up GPIO and update auto-muting at initialization */
8967static void alc885_imac24_init_hook(struct hda_codec *codec)
8968{
8969 alc885_macpro_init_hook(codec);
Takashi Iwaid922b512011-04-28 12:18:53 +02008970 alc_hp_automute(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008971}
8972
Kailang Yangdf694da2005-12-05 19:42:22 +01008973/*
8974 * generic initialization of ADC, input mixers and output mixers
8975 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008976static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008977 /*
8978 * Unmute ADC0-2 and set the default input to mic-in
8979 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008980 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8981 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8982 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8983 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8984
Kailang Yangdf694da2005-12-05 19:42:22 +01008985 /*
8986 * Set up output mixers (0x0c - 0x0f)
8987 */
8988 /* set vol=0 to output mixers */
8989 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8990 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8991 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8992 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8993 /* set up input amps for analog loopback */
8994 /* Amp Indices: DAC = 0, mixer = 1 */
8995 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8996 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8997 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8998 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8999 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9000 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9001 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9002 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9003 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9004 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9005
9006 /* FIXME: use matrix-type input source selection */
9007 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01009008 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01009009 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009010 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01009011 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009012 { }
9013};
9014
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009015/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
9016static struct hda_verb alc889A_mb31_ch2_init[] = {
9017 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
9018 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
9019 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
9020 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
9021 { } /* end */
9022};
9023
9024/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
9025static struct hda_verb alc889A_mb31_ch4_init[] = {
9026 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
9027 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
9028 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
9029 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
9030 { } /* end */
9031};
9032
9033/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
9034static struct hda_verb alc889A_mb31_ch5_init[] = {
9035 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
9036 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
9037 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
9038 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
9039 { } /* end */
9040};
9041
9042/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
9043static struct hda_verb alc889A_mb31_ch6_init[] = {
9044 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
9045 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
9046 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
9047 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
9048 { } /* end */
9049};
9050
9051static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
9052 { 2, alc889A_mb31_ch2_init },
9053 { 4, alc889A_mb31_ch4_init },
9054 { 5, alc889A_mb31_ch5_init },
9055 { 6, alc889A_mb31_ch6_init },
9056};
9057
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009058static struct hda_verb alc883_medion_eapd_verbs[] = {
9059 /* eanable EAPD on medion laptop */
9060 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9061 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
9062 { }
9063};
9064
Takashi Iwai4953550a2009-06-30 15:28:30 +02009065#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009066
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009067static struct snd_kcontrol_new alc883_mitac_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_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9071 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9072 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9073 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9074 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9075 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009076 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009077 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9078 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009079 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009080 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009081 { } /* end */
9082};
9083
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009084static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009085 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9086 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
9087 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9088 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
9089 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009090 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01009091 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009092 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009093 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009094 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01009095 { } /* end */
9096};
9097
Jiang zhefb97dc62008-03-06 11:07:11 +01009098static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
9099 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9100 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
9101 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9102 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
9103 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009104 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01009105 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009106 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009107 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009108 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01009109 { } /* end */
9110};
9111
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009112static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
9113 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9114 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9115 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9116 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9117 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9118 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9119 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9120 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009121 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009122 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9123 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009124 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009125 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009126 { } /* end */
9127};
9128
9129static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
9130 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9131 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9132 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9133 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9134 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9135 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9136 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9137 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9138 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9139 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9140 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9141 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9142 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9143 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009144 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009145 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9146 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009147 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009148 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009149 { } /* end */
9150};
9151
Jiang zhe17bba1b2008-06-04 12:11:07 +02009152static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
9153 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9154 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9155 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9156 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9157 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
9158 HDA_OUTPUT),
9159 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9160 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9161 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9162 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9163 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9164 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9165 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9166 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9167 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009168 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02009169 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9170 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009171 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02009172 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02009173 { } /* end */
9174};
9175
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009176static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
9177 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9178 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9179 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9180 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9181 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
9182 HDA_OUTPUT),
9183 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9184 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9185 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9186 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9187 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
9188 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9189 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9190 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9191 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009192 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1b, 0, HDA_INPUT),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009193 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
9194 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009195 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009196 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9197 { } /* end */
9198};
9199
Takashi Iwaid1d985f2006-11-23 19:27:12 +01009200static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02009201 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02009202 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009203 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02009204 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009205 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9206 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02009207 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9208 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009209 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9210 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9211 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9212 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9213 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9214 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009215 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009216 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9217 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009218 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009219 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009220 { } /* end */
9221};
9222
Sasha Alexandrc2592492009-06-16 14:52:54 -04009223static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009224 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009225 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009226 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009227 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009228 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9229 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9230 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9231 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9232 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9233 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9234 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9235 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9236 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9237 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9238 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009239 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009240 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009241 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009242};
Kailang Yangccc656c2006-10-17 12:32:26 +02009243
Sasha Alexandrc2592492009-06-16 14:52:54 -04009244static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009245 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009246 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009247 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009248 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009249 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9250 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9251 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009252 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009253 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009254 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009255 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009256 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009257 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009258};
Kailang Yangccc656c2006-10-17 12:32:26 +02009259
Takashi Iwaib99dba32009-09-17 18:23:00 +02009260static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
9261 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9262 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009263 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009264 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009265 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009266 { } /* end */
9267};
9268
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009269static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
9270 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9271 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009272 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9273 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009274 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9275 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009276 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009277 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009278 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009279};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009280
Kailang Yang272a5272007-05-14 11:00:38 +02009281static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
9282 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9283 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
9284 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9285 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9286 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9287 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9288 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009289 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9290 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02009291 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02009292};
Kailang Yang272a5272007-05-14 11:00:38 +02009293
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009294static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
9295 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9296 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9297 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9298 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
9299 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
9300 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
9301 { } /* end */
9302};
9303
9304static struct hda_verb alc883_medion_wim2160_verbs[] = {
9305 /* Unmute front mixer */
9306 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9307 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9308
9309 /* Set speaker pin to front mixer */
9310 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9311
9312 /* Init headphone pin */
9313 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9314 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9315 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9316 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9317
9318 { } /* end */
9319};
9320
9321/* toggle speaker-output according to the hp-jack state */
9322static void alc883_medion_wim2160_setup(struct hda_codec *codec)
9323{
9324 struct alc_spec *spec = codec->spec;
9325
9326 spec->autocfg.hp_pins[0] = 0x1a;
9327 spec->autocfg.speaker_pins[0] = 0x15;
Takashi Iwaid922b512011-04-28 12:18:53 +02009328 spec->automute = 1;
9329 spec->automute_mode = ALC_AUTOMUTE_AMP;
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009330}
9331
Tobin Davis2880a862007-08-07 11:50:26 +02009332static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02009333 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9334 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009335 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009336 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9337 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009338 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009339 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009340 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009341 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02009342};
Tobin Davis2880a862007-08-07 11:50:26 +02009343
Tony Vroond2fd4b02009-06-21 00:40:10 +01009344static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
9345 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009346 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01009347 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9348 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009349 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9350 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9351 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009352 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009353 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9354 { } /* end */
9355};
9356
Kailang Yange2757d52008-08-26 13:17:46 +02009357static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
9358 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9359 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9360 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9361 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
9362 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
9363 0x0d, 1, 0x0, HDA_OUTPUT),
9364 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
9365 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
9366 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
9367 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9368 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009369 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9370 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9371 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9372 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9373 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009374 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009375 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9376 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009377 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009378 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009379 { } /* end */
9380};
9381
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009382static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
9383 /* Output mixers */
9384 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
9385 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
9386 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
9387 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
9388 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
9389 HDA_OUTPUT),
9390 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
9391 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
9392 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
9393 /* Output switches */
9394 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
9395 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
9396 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
9397 /* Boost mixers */
David Henningsson5f99f862011-01-04 15:24:24 +01009398 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
9399 HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009400 /* Input mixers */
9401 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
9402 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
9403 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9404 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9405 { } /* end */
9406};
9407
Guido Günther3e1647c2009-06-05 00:47:26 +02009408static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
9409 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9410 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9411 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9412 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009413 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
Guido Günther3e1647c2009-06-05 00:47:26 +02009414 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9415 { } /* end */
9416};
9417
Kailang Yange2757d52008-08-26 13:17:46 +02009418static struct hda_bind_ctls alc883_bind_cap_vol = {
9419 .ops = &snd_hda_bind_vol,
9420 .values = {
9421 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9422 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9423 0
9424 },
9425};
9426
9427static struct hda_bind_ctls alc883_bind_cap_switch = {
9428 .ops = &snd_hda_bind_sw,
9429 .values = {
9430 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9431 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9432 0
9433 },
9434};
9435
9436static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
9437 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9438 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9439 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9440 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9441 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9442 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009443 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009444 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009445 { } /* end */
9446};
9447
9448static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009449 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
9450 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
9451 {
9452 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9453 /* .name = "Capture Source", */
9454 .name = "Input Source",
9455 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009456 .info = alc_mux_enum_info,
9457 .get = alc_mux_enum_get,
9458 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02009459 },
9460 { } /* end */
9461};
9462
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009463static struct snd_kcontrol_new alc883_chmode_mixer[] = {
9464 {
9465 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9466 .name = "Channel Mode",
9467 .info = alc_ch_mode_info,
9468 .get = alc_ch_mode_get,
9469 .put = alc_ch_mode_put,
9470 },
9471 { } /* end */
9472};
9473
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009474/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009475static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009476{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009477 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009478
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009479 spec->autocfg.hp_pins[0] = 0x15;
9480 spec->autocfg.speaker_pins[0] = 0x14;
9481 spec->autocfg.speaker_pins[1] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02009482 spec->automute = 1;
9483 spec->automute_mode = ALC_AUTOMUTE_AMP;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009484}
9485
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009486static struct hda_verb alc883_mitac_verbs[] = {
9487 /* HP */
9488 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9489 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9490 /* Subwoofer */
9491 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9492 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9493
9494 /* enable unsolicited event */
9495 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9496 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
9497
9498 { } /* end */
9499};
9500
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309501static struct hda_verb alc883_clevo_m540r_verbs[] = {
9502 /* HP */
9503 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9504 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9505 /* Int speaker */
9506 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
9507
9508 /* enable unsolicited event */
9509 /*
9510 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9511 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9512 */
9513
9514 { } /* end */
9515};
9516
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009517static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009518 /* HP */
9519 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9520 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9521 /* Int speaker */
9522 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
9523 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9524
9525 /* enable unsolicited event */
9526 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009527 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01009528
9529 { } /* end */
9530};
9531
Jiang zhefb97dc62008-03-06 11:07:11 +01009532static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
9533 /* HP */
9534 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9535 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9536 /* Subwoofer */
9537 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9538 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9539
9540 /* enable unsolicited event */
9541 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9542
9543 { } /* end */
9544};
9545
Sasha Alexandrc2592492009-06-16 14:52:54 -04009546static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009547 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9548 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9549
9550 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9551 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02009552
David Heidelberger64a8be72009-06-08 16:15:18 +02009553/* Connect Line-Out side jack (SPDIF) to Side */
9554 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9555 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9556 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9557/* Connect Mic jack to CLFE */
9558 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9559 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9560 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
9561/* Connect Line-in jack to Surround */
9562 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9563 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9564 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
9565/* Connect HP out jack to Front */
9566 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9567 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9568 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02009569
9570 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02009571
9572 { } /* end */
9573};
9574
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009575static struct hda_verb alc883_lenovo_101e_verbs[] = {
9576 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9577 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
9578 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
9579 { } /* end */
9580};
9581
Kailang Yang272a5272007-05-14 11:00:38 +02009582static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
9583 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9584 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9585 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9586 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9587 { } /* end */
9588};
9589
9590static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
9591 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9592 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9593 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9594 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
9595 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9596 { } /* end */
9597};
9598
Kailang Yang189609a2007-08-20 11:31:23 +02009599static struct hda_verb alc883_haier_w66_verbs[] = {
9600 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9601 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9602
9603 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9604
9605 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9606 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9607 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9608 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9609 { } /* end */
9610};
9611
Kailang Yange2757d52008-08-26 13:17:46 +02009612static struct hda_verb alc888_lenovo_sky_verbs[] = {
9613 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9614 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9615 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9616 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9617 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9618 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9619 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9620 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9621 { } /* end */
9622};
9623
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009624static struct hda_verb alc888_6st_dell_verbs[] = {
9625 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9626 { }
9627};
9628
Guido Günther3e1647c2009-06-05 00:47:26 +02009629static struct hda_verb alc883_vaiott_verbs[] = {
9630 /* HP */
9631 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9632 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9633
9634 /* enable unsolicited event */
9635 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9636
9637 { } /* end */
9638};
9639
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009640static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009641{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009642 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009643
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009644 spec->autocfg.hp_pins[0] = 0x1b;
9645 spec->autocfg.speaker_pins[0] = 0x14;
9646 spec->autocfg.speaker_pins[1] = 0x16;
9647 spec->autocfg.speaker_pins[2] = 0x18;
Takashi Iwaid922b512011-04-28 12:18:53 +02009648 spec->automute = 1;
9649 spec->automute_mode = ALC_AUTOMUTE_AMP;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009650}
9651
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009652static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009653 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01009654 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
9655 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009656 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009657 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009658};
9659
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009660/*
9661 * 2ch mode
9662 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009663static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009664 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9665 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9666 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9667 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009668 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009669};
9670
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009671/*
9672 * 4ch mode
9673 */
9674static struct hda_verb alc888_3st_hp_4ch_init[] = {
9675 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9676 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9677 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9678 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9679 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9680 { } /* end */
9681};
9682
9683/*
9684 * 6ch mode
9685 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009686static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009687 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9688 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009689 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009690 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9691 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009692 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9693 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009694};
9695
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009696static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009697 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009698 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009699 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009700};
9701
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02009702static void alc888_lenovo_ms7195_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009703{
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02009704 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009705
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02009706 spec->autocfg.hp_pins[0] = 0x1b;
9707 spec->autocfg.line_out_pins[0] = 0x14;
9708 spec->autocfg.speaker_pins[0] = 0x15;
9709 spec->automute = 1;
9710 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yang272a5272007-05-14 11:00:38 +02009711}
9712
Kailang Yang272a5272007-05-14 11:00:38 +02009713/* toggle speaker-output according to the hp-jack state */
Takashi Iwaidc4271702010-11-29 07:42:59 +01009714static void alc883_lenovo_nb0763_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009715{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009716 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009717
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009718 spec->autocfg.hp_pins[0] = 0x14;
9719 spec->autocfg.speaker_pins[0] = 0x15;
Takashi Iwaid922b512011-04-28 12:18:53 +02009720 spec->automute = 1;
9721 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yang272a5272007-05-14 11:00:38 +02009722}
9723
Kailang Yangccc656c2006-10-17 12:32:26 +02009724/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009725#define alc883_targa_init_hook alc882_targa_init_hook
9726#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009727
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009728static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009729{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009730 struct alc_spec *spec = codec->spec;
9731
9732 spec->autocfg.hp_pins[0] = 0x15;
9733 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +02009734 spec->automute = 1;
9735 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009736}
9737
9738static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9739{
Takashi Iwaid922b512011-04-28 12:18:53 +02009740 alc_hp_automute(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +01009741 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009742}
9743
9744static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009745 unsigned int res)
9746{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009747 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009748 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +01009749 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009750 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009751 default:
Takashi Iwaid922b512011-04-28 12:18:53 +02009752 alc_sku_unsol_event(codec, res);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009753 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009754 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009755}
9756
Jiang zhefb97dc62008-03-06 11:07:11 +01009757/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009758static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009759{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009760 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009761
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009762 spec->autocfg.hp_pins[0] = 0x14;
9763 spec->autocfg.speaker_pins[0] = 0x15;
Takashi Iwaid922b512011-04-28 12:18:53 +02009764 spec->automute = 1;
9765 spec->automute_mode = ALC_AUTOMUTE_AMP;
Jiang zhefb97dc62008-03-06 11:07:11 +01009766}
9767
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009768static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009769{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009770 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009771
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009772 spec->autocfg.hp_pins[0] = 0x1b;
9773 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +02009774 spec->automute = 1;
9775 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yang189609a2007-08-20 11:31:23 +02009776}
9777
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02009778static void alc883_lenovo_101e_setup(struct hda_codec *codec)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009779{
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02009780 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009781
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02009782 spec->autocfg.hp_pins[0] = 0x1b;
9783 spec->autocfg.line_out_pins[0] = 0x14;
9784 spec->autocfg.speaker_pins[0] = 0x15;
9785 spec->automute = 1;
9786 spec->detect_line = 1;
9787 spec->automute_lines = 1;
9788 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009789}
9790
Takashi Iwai676a9b52007-08-16 15:23:35 +02009791/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009792static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009793{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009794 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009795
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009796 spec->autocfg.hp_pins[0] = 0x14;
9797 spec->autocfg.speaker_pins[0] = 0x15;
9798 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwaid922b512011-04-28 12:18:53 +02009799 spec->automute = 1;
9800 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009801}
9802
Kailang Yangd1a991a2007-08-15 16:21:59 +02009803static struct hda_verb alc883_acer_eapd_verbs[] = {
9804 /* HP Pin: output 0 (0x0c) */
9805 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9806 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9807 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9808 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009809 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9810 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009811 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009812 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9813 /* eanable EAPD on medion laptop */
9814 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9815 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009816 /* enable unsolicited event */
9817 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009818 { }
9819};
9820
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009821static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009822{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009823 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009824
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009825 spec->autocfg.hp_pins[0] = 0x1b;
9826 spec->autocfg.speaker_pins[0] = 0x14;
9827 spec->autocfg.speaker_pins[1] = 0x15;
9828 spec->autocfg.speaker_pins[2] = 0x16;
9829 spec->autocfg.speaker_pins[3] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02009830 spec->automute = 1;
9831 spec->automute_mode = ALC_AUTOMUTE_AMP;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009832}
9833
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009834static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009835{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009836 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009837
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009838 spec->autocfg.hp_pins[0] = 0x1b;
9839 spec->autocfg.speaker_pins[0] = 0x14;
9840 spec->autocfg.speaker_pins[1] = 0x15;
9841 spec->autocfg.speaker_pins[2] = 0x16;
9842 spec->autocfg.speaker_pins[3] = 0x17;
9843 spec->autocfg.speaker_pins[4] = 0x1a;
Takashi Iwaid922b512011-04-28 12:18:53 +02009844 spec->automute = 1;
9845 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yange2757d52008-08-26 13:17:46 +02009846}
9847
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009848static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02009849{
9850 struct alc_spec *spec = codec->spec;
9851
9852 spec->autocfg.hp_pins[0] = 0x15;
9853 spec->autocfg.speaker_pins[0] = 0x14;
9854 spec->autocfg.speaker_pins[1] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02009855 spec->automute = 1;
9856 spec->automute_mode = ALC_AUTOMUTE_AMP;
Guido Günther3e1647c2009-06-05 00:47:26 +02009857}
9858
Kailang Yange2757d52008-08-26 13:17:46 +02009859static struct hda_verb alc888_asus_m90v_verbs[] = {
9860 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9861 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9862 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9863 /* enable unsolicited event */
9864 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9865 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9866 { } /* end */
9867};
9868
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009869static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009870{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009871 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009872
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009873 spec->autocfg.hp_pins[0] = 0x1b;
9874 spec->autocfg.speaker_pins[0] = 0x14;
9875 spec->autocfg.speaker_pins[1] = 0x15;
9876 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009877 spec->ext_mic.pin = 0x18;
9878 spec->int_mic.pin = 0x19;
9879 spec->ext_mic.mux_idx = 0;
9880 spec->int_mic.mux_idx = 1;
9881 spec->auto_mic = 1;
Takashi Iwaid922b512011-04-28 12:18:53 +02009882 spec->automute = 1;
9883 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yange2757d52008-08-26 13:17:46 +02009884}
9885
9886static struct hda_verb alc888_asus_eee1601_verbs[] = {
9887 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9888 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9889 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9890 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9891 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9892 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9893 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9894 /* enable unsolicited event */
9895 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9896 { } /* end */
9897};
9898
Kailang Yange2757d52008-08-26 13:17:46 +02009899static void alc883_eee1601_inithook(struct hda_codec *codec)
9900{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009901 struct alc_spec *spec = codec->spec;
9902
9903 spec->autocfg.hp_pins[0] = 0x14;
9904 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaid922b512011-04-28 12:18:53 +02009905 alc_hp_automute(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009906}
9907
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009908static struct hda_verb alc889A_mb31_verbs[] = {
9909 /* Init rear pin (used as headphone output) */
9910 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9911 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9912 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9913 /* Init line pin (used as output in 4ch and 6ch mode) */
9914 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9915 /* Init line 2 pin (used as headphone out by default) */
9916 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9917 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9918 { } /* end */
9919};
9920
9921/* Mute speakers according to the headphone jack state */
9922static void alc889A_mb31_automute(struct hda_codec *codec)
9923{
9924 unsigned int present;
9925
9926 /* Mute only in 2ch or 4ch mode */
9927 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9928 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009929 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009930 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9931 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9932 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9933 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9934 }
9935}
9936
9937static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9938{
9939 if ((res >> 26) == ALC880_HP_EVENT)
9940 alc889A_mb31_automute(codec);
9941}
9942
Takashi Iwai4953550a2009-06-30 15:28:30 +02009943
Takashi Iwaicb53c622007-08-10 17:21:45 +02009944#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009945#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009946#endif
9947
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009948/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009949#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9950#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9951#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9952#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9953
9954static hda_nid_t alc883_slave_dig_outs[] = {
9955 ALC1200_DIGOUT_NID, 0,
9956};
9957
9958static hda_nid_t alc1200_slave_dig_outs[] = {
9959 ALC883_DIGOUT_NID, 0,
9960};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009961
9962/*
9963 * configuration and preset
9964 */
Takashi Iwaiea734962011-01-17 11:29:34 +01009965static const char * const alc882_models[ALC882_MODEL_LAST] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02009966 [ALC882_3ST_DIG] = "3stack-dig",
9967 [ALC882_6ST_DIG] = "6stack-dig",
9968 [ALC882_ARIMA] = "arima",
9969 [ALC882_W2JC] = "w2jc",
9970 [ALC882_TARGA] = "targa",
9971 [ALC882_ASUS_A7J] = "asus-a7j",
9972 [ALC882_ASUS_A7M] = "asus-a7m",
9973 [ALC885_MACPRO] = "macpro",
9974 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009975 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009976 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009977 [ALC885_MBP3] = "mbp3",
9978 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009979 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009980 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009981 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9982 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009983 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009984 [ALC883_TARGA_DIG] = "targa-dig",
9985 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009986 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009987 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009988 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009989 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009990 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009991 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009992 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009993 [ALC883_MEDION] = "medion",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009994 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009995 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009996 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009997 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9998 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009999 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +020010000 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010001 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010002 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010003 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010004 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010005 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +010010006 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010007 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +020010008 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010009 [ALC889A_INTEL] = "intel-alc889a",
10010 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +010010011 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010012 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +020010013 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010014 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010015};
10016
Takashi Iwai4953550a2009-06-30 15:28:30 +020010017static struct snd_pci_quirk alc882_cfg_tbl[] = {
10018 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
10019
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010020 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +010010021 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +010010022 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010023 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
10024 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +020010025 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010026 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
10027 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +010010028 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +010010029 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +020010030 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
10031 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +020010032 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
10033 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010034 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
10035 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +010010036 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +020010037 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +010010038 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +010010039 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010040 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
10041 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +020010042 /* default Acer -- disabled as it causes more problems.
10043 * model=auto should work fine now
10044 */
10045 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010046
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010047 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010048
Tobin Davisfebe3372007-06-12 11:27:46 +020010049 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010050 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
10051 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +010010052 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +010010053 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -030010054 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010055
10056 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
10057 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
10058 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +020010059 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010060 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
10061 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
10062 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010063 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +010010064 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +010010065 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +020010066 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010067
10068 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +020010069 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010070 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +110010071 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010072 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
10073 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +020010074 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010075 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010076
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010077 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
10078 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
10079 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010080 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +010010081 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010082 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010083 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +010010084 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010085 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
10086 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
10087 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
10088 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
10089 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
10090 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -070010091 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010092 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
10093 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
10094 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +010010095 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +020010096 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010097 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
10098 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +020010099 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +010010100 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +010010101 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +010010102 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +020010103 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -040010104 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +010010105 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010106 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -070010107 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010108
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010109 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +020010110 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010111 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
10112 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010113 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010114 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -040010115 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010116 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010117 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +020010118 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +010010119 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +020010120 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010121 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +020010122 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +020010123 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010124 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
10125 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +020010126 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Takashi Iwai959973b2008-11-05 11:30:56 +010010127 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +010010128 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +020010129 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010130
Jiang zhe17bba1b2008-06-04 12:11:07 +020010131 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
10132 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +110010133 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010134 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
10135 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
10136 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -040010137 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010138
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010139 {}
10140};
10141
Takashi Iwai4953550a2009-06-30 15:28:30 +020010142/* codec SSID table for Intel Mac */
10143static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
10144 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
10145 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
10146 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
10147 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
10148 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
10149 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
10150 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -040010151 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -070010152 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -070010153 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -070010154 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010155 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
10156 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
10157 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010158 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010159 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Luke Yelavich3bfea982010-06-22 11:04:19 +100010160 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -050010161 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
10162 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +020010163 */
10164 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -050010165 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010166 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010167 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010168};
10169
Takashi Iwai4953550a2009-06-30 15:28:30 +020010170static struct alc_config_preset alc882_presets[] = {
10171 [ALC882_3ST_DIG] = {
10172 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010173 .init_verbs = { alc882_base_init_verbs,
10174 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010175 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10176 .dac_nids = alc882_dac_nids,
10177 .dig_out_nid = ALC882_DIGOUT_NID,
10178 .dig_in_nid = ALC882_DIGIN_NID,
10179 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10180 .channel_mode = alc882_ch_modes,
10181 .need_dac_fix = 1,
10182 .input_mux = &alc882_capture_source,
10183 },
10184 [ALC882_6ST_DIG] = {
10185 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010186 .init_verbs = { alc882_base_init_verbs,
10187 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010188 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10189 .dac_nids = alc882_dac_nids,
10190 .dig_out_nid = ALC882_DIGOUT_NID,
10191 .dig_in_nid = ALC882_DIGIN_NID,
10192 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
10193 .channel_mode = alc882_sixstack_modes,
10194 .input_mux = &alc882_capture_source,
10195 },
10196 [ALC882_ARIMA] = {
10197 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010198 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10199 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010200 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10201 .dac_nids = alc882_dac_nids,
10202 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
10203 .channel_mode = alc882_sixstack_modes,
10204 .input_mux = &alc882_capture_source,
10205 },
10206 [ALC882_W2JC] = {
10207 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010208 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10209 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010210 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10211 .dac_nids = alc882_dac_nids,
10212 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10213 .channel_mode = alc880_threestack_modes,
10214 .need_dac_fix = 1,
10215 .input_mux = &alc882_capture_source,
10216 .dig_out_nid = ALC882_DIGOUT_NID,
10217 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -080010218 [ALC885_MBA21] = {
10219 .mixers = { alc885_mba21_mixer },
10220 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
10221 .num_dacs = 2,
10222 .dac_nids = alc882_dac_nids,
10223 .channel_mode = alc885_mba21_ch_modes,
10224 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10225 .input_mux = &alc882_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010226 .unsol_event = alc_sku_unsol_event,
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -080010227 .setup = alc885_mba21_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010228 .init_hook = alc_hp_automute,
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -080010229 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010230 [ALC885_MBP3] = {
10231 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
10232 .init_verbs = { alc885_mbp3_init_verbs,
10233 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +020010234 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010235 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +020010236 .hp_nid = 0x04,
10237 .channel_mode = alc885_mbp_4ch_modes,
10238 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010239 .input_mux = &alc882_capture_source,
10240 .dig_out_nid = ALC882_DIGOUT_NID,
10241 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaid922b512011-04-28 12:18:53 +020010242 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010243 .setup = alc885_mbp3_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010244 .init_hook = alc_hp_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010245 },
10246 [ALC885_MB5] = {
10247 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
10248 .init_verbs = { alc885_mb5_init_verbs,
10249 alc880_gpio1_init_verbs },
10250 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10251 .dac_nids = alc882_dac_nids,
10252 .channel_mode = alc885_mb5_6ch_modes,
10253 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
10254 .input_mux = &mb5_capture_source,
10255 .dig_out_nid = ALC882_DIGOUT_NID,
10256 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaid922b512011-04-28 12:18:53 +020010257 .unsol_event = alc_sku_unsol_event,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010258 .setup = alc885_mb5_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010259 .init_hook = alc_hp_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010260 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010261 [ALC885_MACMINI3] = {
10262 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
10263 .init_verbs = { alc885_macmini3_init_verbs,
10264 alc880_gpio1_init_verbs },
10265 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10266 .dac_nids = alc882_dac_nids,
10267 .channel_mode = alc885_macmini3_6ch_modes,
10268 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
10269 .input_mux = &macmini3_capture_source,
10270 .dig_out_nid = ALC882_DIGOUT_NID,
10271 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaid922b512011-04-28 12:18:53 +020010272 .unsol_event = alc_sku_unsol_event,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010273 .setup = alc885_macmini3_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010274 .init_hook = alc_hp_automute,
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010275 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010276 [ALC885_MACPRO] = {
10277 .mixers = { alc882_macpro_mixer },
10278 .init_verbs = { alc882_macpro_init_verbs },
10279 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10280 .dac_nids = alc882_dac_nids,
10281 .dig_out_nid = ALC882_DIGOUT_NID,
10282 .dig_in_nid = ALC882_DIGIN_NID,
10283 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10284 .channel_mode = alc882_ch_modes,
10285 .input_mux = &alc882_capture_source,
10286 .init_hook = alc885_macpro_init_hook,
10287 },
10288 [ALC885_IMAC24] = {
10289 .mixers = { alc885_imac24_mixer },
10290 .init_verbs = { alc885_imac24_init_verbs },
10291 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10292 .dac_nids = alc882_dac_nids,
10293 .dig_out_nid = ALC882_DIGOUT_NID,
10294 .dig_in_nid = ALC882_DIGIN_NID,
10295 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10296 .channel_mode = alc882_ch_modes,
10297 .input_mux = &alc882_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010298 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010299 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010300 .init_hook = alc885_imac24_init_hook,
10301 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010302 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010303 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010304 .init_verbs = { alc885_imac91_init_verbs,
10305 alc880_gpio1_init_verbs },
10306 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10307 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010308 .channel_mode = alc885_mba21_ch_modes,
10309 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10310 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010311 .dig_out_nid = ALC882_DIGOUT_NID,
10312 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaid922b512011-04-28 12:18:53 +020010313 .unsol_event = alc_sku_unsol_event,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010314 .setup = alc885_imac91_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010315 .init_hook = alc_hp_automute,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010316 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010317 [ALC882_TARGA] = {
10318 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010319 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +020010320 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010321 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10322 .dac_nids = alc882_dac_nids,
10323 .dig_out_nid = ALC882_DIGOUT_NID,
10324 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10325 .adc_nids = alc882_adc_nids,
10326 .capsrc_nids = alc882_capsrc_nids,
10327 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10328 .channel_mode = alc882_3ST_6ch_modes,
10329 .need_dac_fix = 1,
10330 .input_mux = &alc882_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010331 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010332 .setup = alc882_targa_setup,
10333 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010334 },
10335 [ALC882_ASUS_A7J] = {
10336 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010337 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10338 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010339 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10340 .dac_nids = alc882_dac_nids,
10341 .dig_out_nid = ALC882_DIGOUT_NID,
10342 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10343 .adc_nids = alc882_adc_nids,
10344 .capsrc_nids = alc882_capsrc_nids,
10345 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10346 .channel_mode = alc882_3ST_6ch_modes,
10347 .need_dac_fix = 1,
10348 .input_mux = &alc882_capture_source,
10349 },
10350 [ALC882_ASUS_A7M] = {
10351 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010352 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10353 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010354 alc882_asus_a7m_verbs },
10355 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10356 .dac_nids = alc882_dac_nids,
10357 .dig_out_nid = ALC882_DIGOUT_NID,
10358 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10359 .channel_mode = alc880_threestack_modes,
10360 .need_dac_fix = 1,
10361 .input_mux = &alc882_capture_source,
10362 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010363 [ALC883_3ST_2ch_DIG] = {
10364 .mixers = { alc883_3ST_2ch_mixer },
10365 .init_verbs = { alc883_init_verbs },
10366 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10367 .dac_nids = alc883_dac_nids,
10368 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010369 .dig_in_nid = ALC883_DIGIN_NID,
10370 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10371 .channel_mode = alc883_3ST_2ch_modes,
10372 .input_mux = &alc883_capture_source,
10373 },
10374 [ALC883_3ST_6ch_DIG] = {
10375 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10376 .init_verbs = { alc883_init_verbs },
10377 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10378 .dac_nids = alc883_dac_nids,
10379 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010380 .dig_in_nid = ALC883_DIGIN_NID,
10381 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10382 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010383 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010384 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010385 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010386 [ALC883_3ST_6ch] = {
10387 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10388 .init_verbs = { alc883_init_verbs },
10389 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10390 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010391 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10392 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010393 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010394 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010395 },
Jiang zhe17bba1b2008-06-04 12:11:07 +020010396 [ALC883_3ST_6ch_INTEL] = {
10397 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
10398 .init_verbs = { alc883_init_verbs },
10399 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10400 .dac_nids = alc883_dac_nids,
10401 .dig_out_nid = ALC883_DIGOUT_NID,
10402 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010403 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +020010404 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
10405 .channel_mode = alc883_3ST_6ch_intel_modes,
10406 .need_dac_fix = 1,
10407 .input_mux = &alc883_3stack_6ch_intel,
10408 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010409 [ALC889A_INTEL] = {
10410 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020010411 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
10412 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010413 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10414 .dac_nids = alc883_dac_nids,
10415 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10416 .adc_nids = alc889_adc_nids,
10417 .dig_out_nid = ALC883_DIGOUT_NID,
10418 .dig_in_nid = ALC883_DIGIN_NID,
10419 .slave_dig_outs = alc883_slave_dig_outs,
10420 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10421 .channel_mode = alc889_8ch_intel_modes,
10422 .capsrc_nids = alc889_capsrc_nids,
10423 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010424 .setup = alc889_automute_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010425 .init_hook = alc_hp_automute,
10426 .unsol_event = alc_sku_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010427 .need_dac_fix = 1,
10428 },
10429 [ALC889_INTEL] = {
10430 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
10431 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010432 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010433 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10434 .dac_nids = alc883_dac_nids,
10435 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10436 .adc_nids = alc889_adc_nids,
10437 .dig_out_nid = ALC883_DIGOUT_NID,
10438 .dig_in_nid = ALC883_DIGIN_NID,
10439 .slave_dig_outs = alc883_slave_dig_outs,
10440 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10441 .channel_mode = alc889_8ch_intel_modes,
10442 .capsrc_nids = alc889_capsrc_nids,
10443 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010444 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010445 .init_hook = alc889_intel_init_hook,
Takashi Iwaid922b512011-04-28 12:18:53 +020010446 .unsol_event = alc_sku_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010447 .need_dac_fix = 1,
10448 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010449 [ALC883_6ST_DIG] = {
10450 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10451 .init_verbs = { alc883_init_verbs },
10452 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10453 .dac_nids = alc883_dac_nids,
10454 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010455 .dig_in_nid = ALC883_DIGIN_NID,
10456 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10457 .channel_mode = alc883_sixstack_modes,
10458 .input_mux = &alc883_capture_source,
10459 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010460 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010461 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +020010462 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10463 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010464 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10465 .dac_nids = alc883_dac_nids,
10466 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010467 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10468 .channel_mode = alc883_3ST_6ch_modes,
10469 .need_dac_fix = 1,
10470 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010471 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010472 .setup = alc882_targa_setup,
10473 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010474 },
10475 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010476 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +020010477 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10478 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010479 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10480 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010481 .adc_nids = alc883_adc_nids_alt,
10482 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010483 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +020010484 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010485 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10486 .channel_mode = alc883_3ST_2ch_modes,
10487 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010488 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010489 .setup = alc882_targa_setup,
10490 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010491 },
David Heidelberger64a8be72009-06-08 16:15:18 +020010492 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +020010493 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
10494 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +020010495 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010496 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +020010497 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10498 .dac_nids = alc883_dac_nids,
10499 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10500 .adc_nids = alc883_adc_nids_rev,
10501 .capsrc_nids = alc883_capsrc_nids_rev,
10502 .dig_out_nid = ALC883_DIGOUT_NID,
10503 .dig_in_nid = ALC883_DIGIN_NID,
10504 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
10505 .channel_mode = alc883_4ST_8ch_modes,
10506 .need_dac_fix = 1,
10507 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010508 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010509 .setup = alc882_targa_setup,
10510 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +020010511 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +020010512 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010513 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +020010514 /* On TravelMate laptops, GPIO 0 enables the internal speaker
10515 * and the headphone jack. Turn this on and rely on the
10516 * standard mute methods whenever the user wants to turn
10517 * these outputs off.
10518 */
10519 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
10520 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10521 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +020010522 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10523 .channel_mode = alc883_3ST_2ch_modes,
10524 .input_mux = &alc883_capture_source,
10525 },
Tobin Davis2880a862007-08-07 11:50:26 +020010526 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010527 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010528 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +020010529 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10530 .dac_nids = alc883_dac_nids,
10531 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +020010532 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10533 .channel_mode = alc883_3ST_2ch_modes,
10534 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010535 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010536 .setup = alc883_acer_aspire_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010537 .init_hook = alc_hp_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010538 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010539 [ALC888_ACER_ASPIRE_4930G] = {
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +010010540 .mixers = { alc888_acer_aspire_4930g_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010541 alc883_chmode_mixer },
10542 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10543 alc888_acer_aspire_4930g_verbs },
10544 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10545 .dac_nids = alc883_dac_nids,
10546 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10547 .adc_nids = alc883_adc_nids_rev,
10548 .capsrc_nids = alc883_capsrc_nids_rev,
10549 .dig_out_nid = ALC883_DIGOUT_NID,
10550 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10551 .channel_mode = alc883_3ST_6ch_modes,
10552 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +010010553 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010554 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010555 ARRAY_SIZE(alc888_2_capture_sources),
10556 .input_mux = alc888_2_capture_sources,
Takashi Iwaid922b512011-04-28 12:18:53 +020010557 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010558 .setup = alc888_acer_aspire_4930g_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010559 .init_hook = alc_hp_automute,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010560 },
Tony Vroond2fd4b02009-06-21 00:40:10 +010010561 [ALC888_ACER_ASPIRE_6530G] = {
10562 .mixers = { alc888_acer_aspire_6530_mixer },
10563 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10564 alc888_acer_aspire_6530g_verbs },
10565 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10566 .dac_nids = alc883_dac_nids,
10567 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10568 .adc_nids = alc883_adc_nids_rev,
10569 .capsrc_nids = alc883_capsrc_nids_rev,
10570 .dig_out_nid = ALC883_DIGOUT_NID,
10571 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10572 .channel_mode = alc883_3ST_2ch_modes,
10573 .num_mux_defs =
10574 ARRAY_SIZE(alc888_2_capture_sources),
10575 .input_mux = alc888_acer_aspire_6530_sources,
Takashi Iwaid922b512011-04-28 12:18:53 +020010576 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010577 .setup = alc888_acer_aspire_6530g_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010578 .init_hook = alc_hp_automute,
Tony Vroond2fd4b02009-06-21 00:40:10 +010010579 },
Hector Martin3b315d72009-06-02 10:54:19 +020010580 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +010010581 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +020010582 alc883_chmode_mixer },
10583 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +010010584 alc889_acer_aspire_8930g_verbs,
10585 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +020010586 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10587 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +020010588 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10589 .adc_nids = alc889_adc_nids,
10590 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +020010591 .dig_out_nid = ALC883_DIGOUT_NID,
10592 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10593 .channel_mode = alc883_3ST_6ch_modes,
10594 .need_dac_fix = 1,
10595 .const_channel_count = 6,
10596 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +020010597 ARRAY_SIZE(alc889_capture_sources),
10598 .input_mux = alc889_capture_sources,
Takashi Iwaid922b512011-04-28 12:18:53 +020010599 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010600 .setup = alc889_acer_aspire_8930g_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010601 .init_hook = alc_hp_automute,
Hector Martinf5de24b2009-12-20 22:51:31 +010010602#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050010603 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +010010604#endif
Hector Martin3b315d72009-06-02 10:54:19 +020010605 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010606 [ALC888_ACER_ASPIRE_7730G] = {
10607 .mixers = { alc883_3ST_6ch_mixer,
10608 alc883_chmode_mixer },
10609 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10610 alc888_acer_aspire_7730G_verbs },
10611 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10612 .dac_nids = alc883_dac_nids,
10613 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10614 .adc_nids = alc883_adc_nids_rev,
10615 .capsrc_nids = alc883_capsrc_nids_rev,
10616 .dig_out_nid = ALC883_DIGOUT_NID,
10617 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10618 .channel_mode = alc883_3ST_6ch_modes,
10619 .need_dac_fix = 1,
10620 .const_channel_count = 6,
10621 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010622 .unsol_event = alc_sku_unsol_event,
Denis Kuplyakovd9477202010-11-24 06:01:09 +010010623 .setup = alc888_acer_aspire_7730g_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010624 .init_hook = alc_hp_automute,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010625 },
Tobin Davisc07584c2006-10-13 12:32:16 +020010626 [ALC883_MEDION] = {
10627 .mixers = { alc883_fivestack_mixer,
10628 alc883_chmode_mixer },
10629 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010630 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +020010631 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10632 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010633 .adc_nids = alc883_adc_nids_alt,
10634 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010635 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +020010636 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10637 .channel_mode = alc883_sixstack_modes,
10638 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010639 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010640 [ALC883_MEDION_WIM2160] = {
10641 .mixers = { alc883_medion_wim2160_mixer },
10642 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
10643 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10644 .dac_nids = alc883_dac_nids,
10645 .dig_out_nid = ALC883_DIGOUT_NID,
10646 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
10647 .adc_nids = alc883_adc_nids,
10648 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10649 .channel_mode = alc883_3ST_2ch_modes,
10650 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010651 .unsol_event = alc_sku_unsol_event,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010652 .setup = alc883_medion_wim2160_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010653 .init_hook = alc_hp_automute,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010654 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010655 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010656 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010657 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10658 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10659 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010660 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10661 .channel_mode = alc883_3ST_2ch_modes,
10662 .input_mux = &alc883_capture_source,
10663 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010664 [ALC883_CLEVO_M540R] = {
10665 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10666 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10667 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10668 .dac_nids = alc883_dac_nids,
10669 .dig_out_nid = ALC883_DIGOUT_NID,
10670 .dig_in_nid = ALC883_DIGIN_NID,
10671 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10672 .channel_mode = alc883_3ST_6ch_clevo_modes,
10673 .need_dac_fix = 1,
10674 .input_mux = &alc883_capture_source,
10675 /* This machine has the hardware HP auto-muting, thus
10676 * we need no software mute via unsol event
10677 */
10678 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010679 [ALC883_CLEVO_M720] = {
10680 .mixers = { alc883_clevo_m720_mixer },
10681 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010682 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10683 .dac_nids = alc883_dac_nids,
10684 .dig_out_nid = ALC883_DIGOUT_NID,
10685 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10686 .channel_mode = alc883_3ST_2ch_modes,
10687 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010688 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010689 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010690 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010691 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010692 [ALC883_LENOVO_101E_2ch] = {
10693 .mixers = { alc883_lenovo_101e_2ch_mixer},
10694 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10695 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10696 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010697 .adc_nids = alc883_adc_nids_alt,
10698 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010699 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010700 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10701 .channel_mode = alc883_3ST_2ch_modes,
10702 .input_mux = &alc883_lenovo_101e_capture_source,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020010703 .setup = alc883_lenovo_101e_setup,
10704 .unsol_event = alc_sku_unsol_event,
10705 .init_hook = alc_inithook,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010706 },
Kailang Yang272a5272007-05-14 11:00:38 +020010707 [ALC883_LENOVO_NB0763] = {
10708 .mixers = { alc883_lenovo_nb0763_mixer },
10709 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10710 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10711 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010712 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10713 .channel_mode = alc883_3ST_2ch_modes,
10714 .need_dac_fix = 1,
10715 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010716 .unsol_event = alc_sku_unsol_event,
Takashi Iwaidc4271702010-11-29 07:42:59 +010010717 .setup = alc883_lenovo_nb0763_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010718 .init_hook = alc_hp_automute,
Kailang Yang272a5272007-05-14 11:00:38 +020010719 },
10720 [ALC888_LENOVO_MS7195_DIG] = {
10721 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10722 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10723 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10724 .dac_nids = alc883_dac_nids,
10725 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010726 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10727 .channel_mode = alc883_3ST_6ch_modes,
10728 .need_dac_fix = 1,
10729 .input_mux = &alc883_capture_source,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020010730 .unsol_event = alc_sku_unsol_event,
10731 .setup = alc888_lenovo_ms7195_setup,
10732 .init_hook = alc_inithook,
Kailang Yang189609a2007-08-20 11:31:23 +020010733 },
10734 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010735 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010736 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10737 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10738 .dac_nids = alc883_dac_nids,
10739 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010740 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10741 .channel_mode = alc883_3ST_2ch_modes,
10742 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010743 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010744 .setup = alc883_haier_w66_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010745 .init_hook = alc_hp_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010746 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010747 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010748 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010749 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010750 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10751 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010752 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10753 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010754 .need_dac_fix = 1,
10755 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010756 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010757 .setup = alc888_3st_hp_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010758 .init_hook = alc_hp_automute,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010759 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010760 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010761 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010762 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10763 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10764 .dac_nids = alc883_dac_nids,
10765 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010766 .dig_in_nid = ALC883_DIGIN_NID,
10767 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10768 .channel_mode = alc883_sixstack_modes,
10769 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010770 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010771 .setup = alc888_6st_dell_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010772 .init_hook = alc_hp_automute,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010773 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010774 [ALC883_MITAC] = {
10775 .mixers = { alc883_mitac_mixer },
10776 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10777 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10778 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010779 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10780 .channel_mode = alc883_3ST_2ch_modes,
10781 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010782 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010783 .setup = alc883_mitac_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010784 .init_hook = alc_hp_automute,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010785 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010786 [ALC883_FUJITSU_PI2515] = {
10787 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10788 .init_verbs = { alc883_init_verbs,
10789 alc883_2ch_fujitsu_pi2515_verbs},
10790 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10791 .dac_nids = alc883_dac_nids,
10792 .dig_out_nid = ALC883_DIGOUT_NID,
10793 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10794 .channel_mode = alc883_3ST_2ch_modes,
10795 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010796 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010797 .setup = alc883_2ch_fujitsu_pi2515_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010798 .init_hook = alc_hp_automute,
Jiang zhefb97dc62008-03-06 11:07:11 +010010799 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010800 [ALC888_FUJITSU_XA3530] = {
10801 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10802 .init_verbs = { alc883_init_verbs,
10803 alc888_fujitsu_xa3530_verbs },
10804 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10805 .dac_nids = alc883_dac_nids,
10806 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10807 .adc_nids = alc883_adc_nids_rev,
10808 .capsrc_nids = alc883_capsrc_nids_rev,
10809 .dig_out_nid = ALC883_DIGOUT_NID,
10810 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10811 .channel_mode = alc888_4ST_8ch_intel_modes,
10812 .num_mux_defs =
10813 ARRAY_SIZE(alc888_2_capture_sources),
10814 .input_mux = alc888_2_capture_sources,
Takashi Iwaid922b512011-04-28 12:18:53 +020010815 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010816 .setup = alc888_fujitsu_xa3530_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010817 .init_hook = alc_hp_automute,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010818 },
Kailang Yange2757d52008-08-26 13:17:46 +020010819 [ALC888_LENOVO_SKY] = {
10820 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10821 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10822 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10823 .dac_nids = alc883_dac_nids,
10824 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010825 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10826 .channel_mode = alc883_sixstack_modes,
10827 .need_dac_fix = 1,
10828 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010829 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010830 .setup = alc888_lenovo_sky_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010831 .init_hook = alc_hp_automute,
Kailang Yange2757d52008-08-26 13:17:46 +020010832 },
10833 [ALC888_ASUS_M90V] = {
10834 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10835 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10836 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10837 .dac_nids = alc883_dac_nids,
10838 .dig_out_nid = ALC883_DIGOUT_NID,
10839 .dig_in_nid = ALC883_DIGIN_NID,
10840 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10841 .channel_mode = alc883_3ST_6ch_modes,
10842 .need_dac_fix = 1,
10843 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010844 .unsol_event = alc_sku_unsol_event,
10845 .setup = alc883_mode2_setup,
10846 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010847 },
10848 [ALC888_ASUS_EEE1601] = {
10849 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010850 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010851 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10852 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10853 .dac_nids = alc883_dac_nids,
10854 .dig_out_nid = ALC883_DIGOUT_NID,
10855 .dig_in_nid = ALC883_DIGIN_NID,
10856 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10857 .channel_mode = alc883_3ST_2ch_modes,
10858 .need_dac_fix = 1,
10859 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010860 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010861 .init_hook = alc883_eee1601_inithook,
10862 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010863 [ALC1200_ASUS_P5Q] = {
10864 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10865 .init_verbs = { alc883_init_verbs },
10866 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10867 .dac_nids = alc883_dac_nids,
10868 .dig_out_nid = ALC1200_DIGOUT_NID,
10869 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010870 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010871 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10872 .channel_mode = alc883_sixstack_modes,
10873 .input_mux = &alc883_capture_source,
10874 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010875 [ALC889A_MB31] = {
10876 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10877 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10878 alc880_gpio1_init_verbs },
10879 .adc_nids = alc883_adc_nids,
10880 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010881 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010882 .dac_nids = alc883_dac_nids,
10883 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10884 .channel_mode = alc889A_mb31_6ch_modes,
10885 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10886 .input_mux = &alc889A_mb31_capture_source,
10887 .dig_out_nid = ALC883_DIGOUT_NID,
10888 .unsol_event = alc889A_mb31_unsol_event,
10889 .init_hook = alc889A_mb31_automute,
10890 },
Guido Günther3e1647c2009-06-05 00:47:26 +020010891 [ALC883_SONY_VAIO_TT] = {
10892 .mixers = { alc883_vaiott_mixer },
10893 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10894 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10895 .dac_nids = alc883_dac_nids,
10896 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10897 .channel_mode = alc883_3ST_2ch_modes,
10898 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010899 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010900 .setup = alc883_vaiott_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010901 .init_hook = alc_hp_automute,
Guido Günther3e1647c2009-06-05 00:47:26 +020010902 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010903};
10904
10905
10906/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010907 * Pin config fixes
10908 */
10909enum {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010910 PINFIX_ABIT_AW9D_MAX,
David Henningsson32eea382011-03-04 13:37:50 +010010911 PINFIX_LENOVO_Y530,
Takashi Iwai954a29c2010-07-30 10:55:44 +020010912 PINFIX_PB_M5210,
David Henningssonc3d226a2010-10-14 15:42:08 +020010913 PINFIX_ACER_ASPIRE_7736,
Takashi Iwaic6b35872011-03-28 12:05:31 +020010914 PINFIX_GIGABYTE_880GM,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010915};
10916
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010917static const struct alc_fixup alc882_fixups[] = {
10918 [PINFIX_ABIT_AW9D_MAX] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010919 .type = ALC_FIXUP_PINS,
10920 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020010921 { 0x15, 0x01080104 }, /* side */
10922 { 0x16, 0x01011012 }, /* rear */
10923 { 0x17, 0x01016011 }, /* clfe */
10924 { }
10925 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010926 },
David Henningsson32eea382011-03-04 13:37:50 +010010927 [PINFIX_LENOVO_Y530] = {
10928 .type = ALC_FIXUP_PINS,
10929 .v.pins = (const struct alc_pincfg[]) {
10930 { 0x15, 0x99130112 }, /* rear int speakers */
10931 { 0x16, 0x99130111 }, /* subwoofer */
10932 { }
10933 }
10934 },
Takashi Iwai954a29c2010-07-30 10:55:44 +020010935 [PINFIX_PB_M5210] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010936 .type = ALC_FIXUP_VERBS,
10937 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020010938 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
10939 {}
10940 }
Takashi Iwai954a29c2010-07-30 10:55:44 +020010941 },
David Henningssonc3d226a2010-10-14 15:42:08 +020010942 [PINFIX_ACER_ASPIRE_7736] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010943 .type = ALC_FIXUP_SKU,
10944 .v.sku = ALC_FIXUP_SKU_IGNORE,
David Henningssonc3d226a2010-10-14 15:42:08 +020010945 },
Takashi Iwaic6b35872011-03-28 12:05:31 +020010946 [PINFIX_GIGABYTE_880GM] = {
10947 .type = ALC_FIXUP_PINS,
10948 .v.pins = (const struct alc_pincfg[]) {
10949 { 0x14, 0x1114410 }, /* set as speaker */
10950 { }
10951 }
10952 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010953};
10954
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010955static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010956 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
David Henningsson32eea382011-03-04 13:37:50 +010010957 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", PINFIX_LENOVO_Y530),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010958 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
David Henningssonc3d226a2010-10-14 15:42:08 +020010959 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736),
Takashi Iwaic6b35872011-03-28 12:05:31 +020010960 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte", PINFIX_GIGABYTE_880GM),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010961 {}
10962};
10963
10964/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010965 * BIOS auto configuration
10966 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010967static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10968 const struct auto_pin_cfg *cfg)
10969{
10970 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10971}
10972
Takashi Iwai4953550a2009-06-30 15:28:30 +020010973static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010974 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010975 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010976{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010977 int idx;
10978
Takashi Iwai489008c2010-04-07 09:06:00 +020010979 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010980 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010981
Takashi Iwai489008c2010-04-07 09:06:00 +020010982 if (dac == 0x25)
10983 idx = 4;
10984 else if (dac >= 0x02 && dac <= 0x05)
10985 idx = dac - 2;
10986 else
10987 return;
10988 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010989}
10990
Takashi Iwai4953550a2009-06-30 15:28:30 +020010991static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010992{
10993 struct alc_spec *spec = codec->spec;
10994 int i;
10995
10996 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010997 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010998 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010999 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020011000 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020011001 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011002 }
11003}
11004
Takashi Iwai4953550a2009-06-30 15:28:30 +020011005static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011006{
11007 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020011008 hda_nid_t pin, dac;
Takashi Iwai5855fb82010-09-16 18:24:02 +020011009 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011010
David Henningsson0a3fabe2011-03-04 16:54:52 +010011011 if (spec->autocfg.line_out_type != AUTO_PIN_HP_OUT) {
11012 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
11013 pin = spec->autocfg.hp_pins[i];
11014 if (!pin)
11015 break;
11016 dac = spec->multiout.hp_nid;
11017 if (!dac)
11018 dac = spec->multiout.dac_nids[0]; /* to front */
11019 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
11020 }
Takashi Iwai489008c2010-04-07 09:06:00 +020011021 }
David Henningsson0a3fabe2011-03-04 16:54:52 +010011022
11023 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT) {
11024 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
11025 pin = spec->autocfg.speaker_pins[i];
11026 if (!pin)
11027 break;
11028 dac = spec->multiout.extra_out_nid[0];
11029 if (!dac)
11030 dac = spec->multiout.dac_nids[0]; /* to front */
11031 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
11032 }
Takashi Iwai489008c2010-04-07 09:06:00 +020011033 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011034}
11035
Takashi Iwai4953550a2009-06-30 15:28:30 +020011036static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011037{
11038 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020011039 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011040 int i;
11041
Takashi Iwai66ceeb62010-08-30 13:05:52 +020011042 for (i = 0; i < cfg->num_inputs; i++) {
11043 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai30ea0982010-09-16 18:47:56 +020011044 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai4953550a2009-06-30 15:28:30 +020011045 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
11046 snd_hda_codec_write(codec, nid, 0,
11047 AC_VERB_SET_AMP_GAIN_MUTE,
11048 AMP_OUT_MUTE);
11049 }
11050}
11051
11052static void alc882_auto_init_input_src(struct hda_codec *codec)
11053{
11054 struct alc_spec *spec = codec->spec;
11055 int c;
11056
11057 for (c = 0; c < spec->num_adc_nids; c++) {
11058 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
11059 hda_nid_t nid = spec->capsrc_nids[c];
11060 unsigned int mux_idx;
11061 const struct hda_input_mux *imux;
11062 int conns, mute, idx, item;
11063
Takashi Iwai10696aa2011-04-07 12:46:45 +020011064 /* mute ADC */
11065 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
11066 AC_VERB_SET_AMP_GAIN_MUTE,
11067 AMP_IN_MUTE(0));
11068
Takashi Iwai4953550a2009-06-30 15:28:30 +020011069 conns = snd_hda_get_connections(codec, nid, conn_list,
11070 ARRAY_SIZE(conn_list));
11071 if (conns < 0)
11072 continue;
11073 mux_idx = c >= spec->num_mux_defs ? 0 : c;
11074 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010011075 if (!imux->num_items && mux_idx > 0)
11076 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020011077 for (idx = 0; idx < conns; idx++) {
11078 /* if the current connection is the selected one,
11079 * unmute it as default - otherwise mute it
11080 */
11081 mute = AMP_IN_MUTE(idx);
11082 for (item = 0; item < imux->num_items; item++) {
11083 if (imux->items[item].index == idx) {
11084 if (spec->cur_mux[c] == item)
11085 mute = AMP_IN_UNMUTE(idx);
11086 break;
11087 }
11088 }
11089 /* check if we have a selector or mixer
11090 * we could check for the widget type instead, but
11091 * just check for Amp-In presence (in case of mixer
11092 * without amp-in there is something wrong, this
11093 * function shouldn't be used or capsrc nid is wrong)
11094 */
11095 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011096 snd_hda_codec_write(codec, nid, 0,
11097 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020011098 mute);
11099 else if (mute != AMP_IN_MUTE(idx))
11100 snd_hda_codec_write(codec, nid, 0,
11101 AC_VERB_SET_CONNECT_SEL,
11102 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011103 }
11104 }
11105}
11106
Takashi Iwai4953550a2009-06-30 15:28:30 +020011107/* add mic boosts if needed */
11108static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011109{
11110 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020011111 struct auto_pin_cfg *cfg = &spec->autocfg;
David Henningsson5322bf22011-01-05 11:03:56 +010011112 int i, err;
Takashi Iwai53e8c322010-12-17 15:23:41 +010011113 int type_idx = 0;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011114 hda_nid_t nid;
David Henningsson5322bf22011-01-05 11:03:56 +010011115 const char *prev_label = NULL;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011116
Takashi Iwai66ceeb62010-08-30 13:05:52 +020011117 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +020011118 if (cfg->inputs[i].type > AUTO_PIN_MIC)
Takashi Iwai66ceeb62010-08-30 13:05:52 +020011119 break;
11120 nid = cfg->inputs[i].pin;
11121 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
David Henningsson5322bf22011-01-05 11:03:56 +010011122 const char *label;
11123 char boost_label[32];
11124
11125 label = hda_get_autocfg_input_label(codec, cfg, i);
11126 if (prev_label && !strcmp(label, prev_label))
Takashi Iwai53e8c322010-12-17 15:23:41 +010011127 type_idx++;
11128 else
11129 type_idx = 0;
David Henningsson5322bf22011-01-05 11:03:56 +010011130 prev_label = label;
11131
11132 snprintf(boost_label, sizeof(boost_label),
11133 "%s Boost Volume", label);
11134 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11135 boost_label, type_idx,
Takashi Iwai4953550a2009-06-30 15:28:30 +020011136 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020011137 if (err < 0)
11138 return err;
11139 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011140 }
11141 return 0;
11142}
11143
11144/* almost identical with ALC880 parser... */
11145static int alc882_parse_auto_config(struct hda_codec *codec)
11146{
11147 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011148 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai757899a2010-07-30 10:48:14 +020011149 int err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011150
Takashi Iwai05f5f472009-08-25 13:10:18 +020011151 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11152 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011153 if (err < 0)
11154 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011155 if (!spec->autocfg.line_outs)
11156 return 0; /* can't find valid BIOS pin config */
11157
11158 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
11159 if (err < 0)
11160 return err;
Takashi Iwaice764ab2011-04-27 16:35:23 +020011161 err = alc_auto_add_multi_channel_mode(codec);
11162 if (err < 0)
11163 return err;
Takashi Iwai569ed342011-01-19 10:14:46 +010011164 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
Takashi Iwai05f5f472009-08-25 13:10:18 +020011165 if (err < 0)
11166 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020011167 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
11168 "Headphone");
11169 if (err < 0)
11170 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011171 err = alc880_auto_create_extra_out(spec,
11172 spec->autocfg.speaker_pins[0],
11173 "Speaker");
11174 if (err < 0)
11175 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011176 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
11177 if (err < 0)
11178 return err;
11179
11180 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11181
Takashi Iwai757899a2010-07-30 10:48:14 +020011182 alc_auto_parse_digital(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020011183
11184 if (spec->kctls.list)
11185 add_mixer(spec, spec->kctls.list);
11186
11187 add_verb(spec, alc883_auto_init_verbs);
11188 /* if ADC 0x07 is available, initialize it, too */
11189 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
11190 add_verb(spec, alc882_adc1_init_verbs);
11191
11192 spec->num_mux_defs = 1;
11193 spec->input_mux = &spec->private_imux[0];
11194
Kailang Yang6227cdc2010-02-25 08:36:52 +010011195 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020011196
11197 err = alc_auto_add_mic_boost(codec);
11198 if (err < 0)
11199 return err;
11200
Takashi Iwai776e1842007-08-29 15:07:11 +020011201 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011202}
11203
11204/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020011205static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011206{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011207 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011208 alc882_auto_init_multi_out(codec);
11209 alc882_auto_init_hp_out(codec);
11210 alc882_auto_init_analog_input(codec);
11211 alc882_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020011212 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011213 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011214 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011215}
11216
Takashi Iwai4953550a2009-06-30 15:28:30 +020011217static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011218{
11219 struct alc_spec *spec;
11220 int err, board_config;
11221
11222 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11223 if (spec == NULL)
11224 return -ENOMEM;
11225
11226 codec->spec = spec;
11227
Takashi Iwai4953550a2009-06-30 15:28:30 +020011228 switch (codec->vendor_id) {
11229 case 0x10ec0882:
11230 case 0x10ec0885:
11231 break;
11232 default:
11233 /* ALC883 and variants */
11234 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11235 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011236 }
11237
Takashi Iwai4953550a2009-06-30 15:28:30 +020011238 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
11239 alc882_models,
11240 alc882_cfg_tbl);
11241
11242 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
11243 board_config = snd_hda_check_board_codec_sid_config(codec,
11244 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
11245
11246 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020011247 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020011248 codec->chip_name);
11249 board_config = ALC882_AUTO;
11250 }
11251
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010011252 if (board_config == ALC882_AUTO) {
11253 alc_pick_fixup(codec, NULL, alc882_fixup_tbl, alc882_fixups);
11254 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
11255 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011256
David Henningsson90622912010-10-14 14:50:18 +020011257 alc_auto_parse_customize_define(codec);
11258
Takashi Iwai4953550a2009-06-30 15:28:30 +020011259 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011260 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020011261 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011262 if (err < 0) {
11263 alc_free(codec);
11264 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011265 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011266 printk(KERN_INFO
11267 "hda_codec: Cannot set up configuration "
11268 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020011269 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011270 }
11271 }
11272
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011273 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020011274 err = snd_hda_attach_beep_device(codec, 0x1);
11275 if (err < 0) {
11276 alc_free(codec);
11277 return err;
11278 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011279 }
11280
Takashi Iwai4953550a2009-06-30 15:28:30 +020011281 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011282 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011283
Takashi Iwai4953550a2009-06-30 15:28:30 +020011284 spec->stream_analog_playback = &alc882_pcm_analog_playback;
11285 spec->stream_analog_capture = &alc882_pcm_analog_capture;
11286 /* FIXME: setup DAC5 */
11287 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
11288 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
11289
11290 spec->stream_digital_playback = &alc882_pcm_digital_playback;
11291 spec->stream_digital_capture = &alc882_pcm_digital_capture;
11292
Takashi Iwai4953550a2009-06-30 15:28:30 +020011293 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011294 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011295 spec->num_adc_nids = 0;
11296 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011297 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011298 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011299 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020011300 hda_nid_t nid = alc882_adc_nids[i];
11301 unsigned int wcap = get_wcaps(codec, nid);
11302 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011303 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020011304 if (wcap != AC_WID_AUD_IN)
11305 continue;
11306 spec->private_adc_nids[spec->num_adc_nids] = nid;
11307 err = snd_hda_get_connections(codec, nid, &cap, 1);
11308 if (err < 0)
11309 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011310 err = snd_hda_get_connections(codec, cap, items,
11311 ARRAY_SIZE(items));
11312 if (err < 0)
11313 continue;
11314 for (j = 0; j < imux->num_items; j++)
11315 if (imux->items[j].index >= err)
11316 break;
11317 if (j < imux->num_items)
11318 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011319 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
11320 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011321 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011322 spec->adc_nids = spec->private_adc_nids;
11323 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020011324 }
11325
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011326 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010011327
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011328 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010011329 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011330
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010011331 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020011332
Takashi Iwai2134ea42008-01-10 16:53:55 +010011333 spec->vmaster_nid = 0x0c;
11334
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011335 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011336 if (board_config == ALC882_AUTO)
11337 spec->init_hook = alc882_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020011338
11339 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020011340#ifdef CONFIG_SND_HDA_POWER_SAVE
11341 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020011342 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011343#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011344
11345 return 0;
11346}
11347
Takashi Iwai4953550a2009-06-30 15:28:30 +020011348
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011349/*
Kailang Yangdf694da2005-12-05 19:42:22 +010011350 * ALC262 support
11351 */
11352
11353#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
11354#define ALC262_DIGIN_NID ALC880_DIGIN_NID
11355
11356#define alc262_dac_nids alc260_dac_nids
11357#define alc262_adc_nids alc882_adc_nids
11358#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010011359#define alc262_capsrc_nids alc882_capsrc_nids
11360#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010011361
11362#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010011363#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010011364
Kailang Yang4e555fe2008-08-26 13:05:55 +020011365static hda_nid_t alc262_dmic_adc_nids[1] = {
11366 /* ADC0 */
11367 0x09
11368};
11369
11370static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
11371
Kailang Yangdf694da2005-12-05 19:42:22 +010011372static struct snd_kcontrol_new alc262_base_mixer[] = {
11373 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11374 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11375 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11376 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11377 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11378 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11379 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11380 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011381 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011382 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11383 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011384 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011385 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
11386 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11387 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
11388 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011389 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010011390};
11391
Takashi Iwaice875f02008-01-28 18:17:43 +010011392/* update HP, line and mono-out pins according to the master switch */
Takashi Iwaie9427962011-04-28 15:46:07 +020011393#define alc262_hp_master_update alc260_hp_master_update
Takashi Iwaice875f02008-01-28 18:17:43 +010011394
Takashi Iwaie9427962011-04-28 15:46:07 +020011395static void alc262_hp_bpc_setup(struct hda_codec *codec)
Takashi Iwaice875f02008-01-28 18:17:43 +010011396{
11397 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011398
Takashi Iwaie9427962011-04-28 15:46:07 +020011399 spec->autocfg.hp_pins[0] = 0x1b;
11400 spec->autocfg.speaker_pins[0] = 0x16;
11401 spec->automute = 1;
11402 spec->automute_mode = ALC_AUTOMUTE_PIN;
Takashi Iwaice875f02008-01-28 18:17:43 +010011403}
11404
Takashi Iwaie9427962011-04-28 15:46:07 +020011405static void alc262_hp_wildwest_setup(struct hda_codec *codec)
Takashi Iwaice875f02008-01-28 18:17:43 +010011406{
11407 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011408
Takashi Iwaie9427962011-04-28 15:46:07 +020011409 spec->autocfg.hp_pins[0] = 0x15;
11410 spec->autocfg.speaker_pins[0] = 0x16;
11411 spec->automute = 1;
11412 spec->automute_mode = ALC_AUTOMUTE_PIN;
Takashi Iwaice875f02008-01-28 18:17:43 +010011413}
11414
Takashi Iwaib72519b2009-05-08 14:31:55 +020011415#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaie9427962011-04-28 15:46:07 +020011416#define alc262_hp_master_sw_put alc260_hp_master_sw_put
Takashi Iwaice875f02008-01-28 18:17:43 +010011417
Takashi Iwaib72519b2009-05-08 14:31:55 +020011418#define ALC262_HP_MASTER_SWITCH \
11419 { \
11420 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11421 .name = "Master Playback Switch", \
11422 .info = snd_ctl_boolean_mono_info, \
11423 .get = alc262_hp_master_sw_get, \
11424 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011425 }, \
11426 { \
11427 .iface = NID_MAPPING, \
11428 .name = "Master Playback Switch", \
11429 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020011430 }
11431
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011432
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011433static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011434 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011435 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11436 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11437 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011438 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11439 HDA_OUTPUT),
11440 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11441 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011442 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11443 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011444 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011445 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11446 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011447 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011448 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11449 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11450 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11451 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011452 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
11453 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
11454 { } /* end */
11455};
11456
Kailang Yangcd7509a2007-01-26 18:33:17 +010011457static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011458 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010011459 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11460 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11461 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11462 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011463 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11464 HDA_OUTPUT),
11465 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11466 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011467 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
11468 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011469 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011470 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11471 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11472 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11473 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011474 { } /* end */
11475};
11476
11477static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
11478 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11479 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011480 HDA_CODEC_VOLUME("Rear Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011481 { } /* end */
11482};
11483
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011484/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011485static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011486{
11487 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011488
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011489 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010011490 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +020011491 spec->automute = 1;
11492 spec->automute_mode = ALC_AUTOMUTE_PIN;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011493}
11494
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011495static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010011496 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11497 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011498 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11499 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11500 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11501 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011502 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011503 { } /* end */
11504};
11505
11506static struct hda_verb alc262_hp_t5735_verbs[] = {
11507 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11508 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11509
11510 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11511 { }
11512};
11513
Kailang Yang8c427222008-01-10 13:03:59 +010011514static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010011515 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11516 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010011517 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11518 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010011519 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11520 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11521 { } /* end */
11522};
11523
11524static struct hda_verb alc262_hp_rp5700_verbs[] = {
11525 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11526 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11527 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11528 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11529 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11530 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11531 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11532 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11533 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11534 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11535 {}
11536};
11537
11538static struct hda_input_mux alc262_hp_rp5700_capture_source = {
11539 .num_items = 1,
11540 .items = {
11541 { "Line", 0x1 },
11542 },
11543};
11544
Takashi Iwai42171c12009-05-08 14:11:43 +020011545/* bind hp and internal speaker mute (with plug check) as master switch */
Takashi Iwaie9427962011-04-28 15:46:07 +020011546#define alc262_hippo_master_update alc262_hp_master_update
Takashi Iwai42171c12009-05-08 14:11:43 +020011547#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
Takashi Iwaie9427962011-04-28 15:46:07 +020011548#define alc262_hippo_master_sw_put alc262_hp_master_sw_put
Takashi Iwai5b319542007-07-26 11:49:22 +020011549
Takashi Iwai42171c12009-05-08 14:11:43 +020011550#define ALC262_HIPPO_MASTER_SWITCH \
11551 { \
11552 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11553 .name = "Master Playback Switch", \
11554 .info = snd_ctl_boolean_mono_info, \
11555 .get = alc262_hippo_master_sw_get, \
11556 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011557 }, \
11558 { \
11559 .iface = NID_MAPPING, \
11560 .name = "Master Playback Switch", \
11561 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
11562 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020011563 }
11564
11565static struct snd_kcontrol_new alc262_hippo_mixer[] = {
11566 ALC262_HIPPO_MASTER_SWITCH,
11567 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11568 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11569 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11570 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11571 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11572 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11573 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011574 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011575 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11576 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011577 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011578 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11579 { } /* end */
11580};
11581
11582static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
11583 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11584 ALC262_HIPPO_MASTER_SWITCH,
11585 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11586 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11587 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11588 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11589 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11590 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011591 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011592 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11593 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011594 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011595 { } /* end */
11596};
11597
11598/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011599static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011600{
11601 struct alc_spec *spec = codec->spec;
11602
11603 spec->autocfg.hp_pins[0] = 0x15;
11604 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaie9427962011-04-28 15:46:07 +020011605 spec->automute = 1;
11606 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai42171c12009-05-08 14:11:43 +020011607}
11608
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011609static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011610{
11611 struct alc_spec *spec = codec->spec;
11612
11613 spec->autocfg.hp_pins[0] = 0x1b;
11614 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaie9427962011-04-28 15:46:07 +020011615 spec->automute = 1;
11616 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai42171c12009-05-08 14:11:43 +020011617}
11618
11619
Kailang Yang272a5272007-05-14 11:00:38 +020011620static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011621 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011622 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011623 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11624 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11625 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11626 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11627 { } /* end */
11628};
11629
Kailang Yang83c34212007-07-05 11:43:05 +020011630static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011631 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11632 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011633 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11634 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11635 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11636 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11637 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11638 { } /* end */
11639};
Kailang Yang272a5272007-05-14 11:00:38 +020011640
Tony Vroonba340e82009-02-02 19:01:30 +000011641static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11642 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11643 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11644 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11645 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11646 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11647 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11648 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11649 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011650 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroonba340e82009-02-02 19:01:30 +000011651 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11652 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011653 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tony Vroonba340e82009-02-02 19:01:30 +000011654 { } /* end */
11655};
11656
11657static struct hda_verb alc262_tyan_verbs[] = {
11658 /* Headphone automute */
11659 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11660 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11661 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11662
11663 /* P11 AUX_IN, white 4-pin connector */
11664 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11665 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11666 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11667 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11668
11669 {}
11670};
11671
11672/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011673static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011674{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011675 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011676
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011677 spec->autocfg.hp_pins[0] = 0x1b;
11678 spec->autocfg.speaker_pins[0] = 0x15;
Takashi Iwaid922b512011-04-28 12:18:53 +020011679 spec->automute = 1;
11680 spec->automute_mode = ALC_AUTOMUTE_AMP;
Tony Vroonba340e82009-02-02 19:01:30 +000011681}
11682
Tony Vroonba340e82009-02-02 19:01:30 +000011683
Kailang Yangdf694da2005-12-05 19:42:22 +010011684#define alc262_capture_mixer alc882_capture_mixer
11685#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11686
11687/*
11688 * generic initialization of ADC, input mixers and output mixers
11689 */
11690static struct hda_verb alc262_init_verbs[] = {
11691 /*
11692 * Unmute ADC0-2 and set the default input to mic-in
11693 */
11694 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11695 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11696 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11697 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11698 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11699 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11700
Takashi Iwaicb53c622007-08-10 17:21:45 +020011701 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011702 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011703 * Note: PASD motherboards uses the Line In 2 as the input for
11704 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011705 */
11706 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011707 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11708 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11709 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11710 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11711 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011712
11713 /*
11714 * Set up output mixers (0x0c - 0x0e)
11715 */
11716 /* set vol=0 to output mixers */
11717 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11718 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11719 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11720 /* set up input amps for analog loopback */
11721 /* Amp Indices: DAC = 0, mixer = 1 */
11722 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11723 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11724 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11725 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11726 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11727 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11728
11729 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11730 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11731 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11732 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11733 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11734 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11735
11736 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11737 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11738 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11739 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11740 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011741
Kailang Yangdf694da2005-12-05 19:42:22 +010011742 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11743 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011744
Kailang Yangdf694da2005-12-05 19:42:22 +010011745 /* FIXME: use matrix-type input source selection */
11746 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11747 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11748 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11749 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11750 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11751 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11752 /* Input mixer2 */
11753 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11754 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11755 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11756 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11757 /* Input mixer3 */
11758 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11759 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11760 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011761 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011762
11763 { }
11764};
11765
Kailang Yang4e555fe2008-08-26 13:05:55 +020011766static struct hda_verb alc262_eapd_verbs[] = {
11767 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11768 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11769 { }
11770};
11771
Kailang Yangccc656c2006-10-17 12:32:26 +020011772static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11773 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11774 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11775 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11776
11777 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11778 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11779 {}
11780};
11781
Kailang Yang272a5272007-05-14 11:00:38 +020011782static struct hda_verb alc262_sony_unsol_verbs[] = {
11783 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11784 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11785 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11786
11787 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11788 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011789 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011790};
11791
Kailang Yang4e555fe2008-08-26 13:05:55 +020011792static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11793 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11794 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11795 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11796 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11797 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011798 { } /* end */
11799};
11800
11801static struct hda_verb alc262_toshiba_s06_verbs[] = {
11802 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11803 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11804 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11805 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11806 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11807 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11808 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11809 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11810 {}
11811};
11812
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011813static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011814{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011815 struct alc_spec *spec = codec->spec;
11816
11817 spec->autocfg.hp_pins[0] = 0x15;
11818 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011819 spec->ext_mic.pin = 0x18;
11820 spec->ext_mic.mux_idx = 0;
11821 spec->int_mic.pin = 0x12;
11822 spec->int_mic.mux_idx = 9;
11823 spec->auto_mic = 1;
Takashi Iwaid922b512011-04-28 12:18:53 +020011824 spec->automute = 1;
11825 spec->automute_mode = ALC_AUTOMUTE_PIN;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011826}
11827
Takashi Iwai834be882006-03-01 14:16:17 +010011828/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011829 * nec model
11830 * 0x15 = headphone
11831 * 0x16 = internal speaker
11832 * 0x18 = external mic
11833 */
11834
11835static struct snd_kcontrol_new alc262_nec_mixer[] = {
11836 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11837 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11838
11839 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11840 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011841 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011842
11843 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11844 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11845 { } /* end */
11846};
11847
11848static struct hda_verb alc262_nec_verbs[] = {
11849 /* Unmute Speaker */
11850 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11851
11852 /* Headphone */
11853 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11854 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11855
11856 /* External mic to headphone */
11857 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11858 /* External mic to speaker */
11859 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11860 {}
11861};
11862
11863/*
Takashi Iwai834be882006-03-01 14:16:17 +010011864 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011865 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11866 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011867 */
11868
11869#define ALC_HP_EVENT 0x37
11870
11871static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11872 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11873 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011874 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11875 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011876 {}
11877};
11878
Jiang zhe0e31daf2008-03-20 12:12:39 +010011879static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11880 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11881 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11882 {}
11883};
11884
Daniel T Chene2595322009-12-19 18:19:02 -050011885static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11886 /* Front Mic pin: input vref at 50% */
11887 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11888 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11889 {}
11890};
11891
Takashi Iwai834be882006-03-01 14:16:17 +010011892static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011893 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011894 .items = {
11895 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +010011896 { "Internal Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011897 { "CD", 0x4 },
11898 },
11899};
11900
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011901static struct hda_input_mux alc262_HP_capture_source = {
11902 .num_items = 5,
11903 .items = {
11904 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011905 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011906 { "Line", 0x2 },
11907 { "CD", 0x4 },
11908 { "AUX IN", 0x6 },
11909 },
11910};
11911
zhejiangaccbe492007-08-31 12:36:05 +020011912static struct hda_input_mux alc262_HP_D7000_capture_source = {
11913 .num_items = 4,
11914 .items = {
11915 { "Mic", 0x0 },
11916 { "Front Mic", 0x2 },
11917 { "Line", 0x1 },
11918 { "CD", 0x4 },
11919 },
11920};
11921
Takashi Iwai0f0f3912011-04-28 16:26:24 +020011922static void alc262_fujitsu_setup(struct hda_codec *codec)
Takashi Iwai834be882006-03-01 14:16:17 +010011923{
11924 struct alc_spec *spec = codec->spec;
Takashi Iwai834be882006-03-01 14:16:17 +010011925
Takashi Iwai0f0f3912011-04-28 16:26:24 +020011926 spec->autocfg.hp_pins[0] = 0x14;
11927 spec->autocfg.hp_pins[1] = 0x1b;
11928 spec->autocfg.speaker_pins[0] = 0x15;
11929 spec->automute = 1;
11930 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011931}
11932
Takashi Iwai834be882006-03-01 14:16:17 +010011933/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011934static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11935 .ops = &snd_hda_bind_vol,
11936 .values = {
11937 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11938 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11939 0
11940 },
11941};
Takashi Iwai834be882006-03-01 14:16:17 +010011942
Takashi Iwai834be882006-03-01 14:16:17 +010011943static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011944 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011945 {
11946 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11947 .name = "Master Playback Switch",
Takashi Iwai0f0f3912011-04-28 16:26:24 +020011948 .subdevice = HDA_SUBDEV_NID_FLAG | 0x14,
11949 .info = snd_ctl_boolean_mono_info,
11950 .get = alc262_hp_master_sw_get,
11951 .put = alc262_hp_master_sw_put,
Takashi Iwai834be882006-03-01 14:16:17 +010011952 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011953 {
11954 .iface = NID_MAPPING,
11955 .name = "Master Playback Switch",
11956 .private_value = 0x1b,
11957 },
Takashi Iwai834be882006-03-01 14:16:17 +010011958 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11959 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011960 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011961 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11962 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011963 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010011964 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11965 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011966 { } /* end */
11967};
11968
Takashi Iwai0f0f3912011-04-28 16:26:24 +020011969static void alc262_lenovo_3000_setup(struct hda_codec *codec)
Jiang zhe0e31daf2008-03-20 12:12:39 +010011970{
Takashi Iwai0f0f3912011-04-28 16:26:24 +020011971 struct alc_spec *spec = codec->spec;
Jiang zhe0e31daf2008-03-20 12:12:39 +010011972
Takashi Iwai0f0f3912011-04-28 16:26:24 +020011973 spec->autocfg.hp_pins[0] = 0x1b;
11974 spec->autocfg.speaker_pins[0] = 0x14;
11975 spec->autocfg.speaker_pins[1] = 0x16;
11976 spec->automute = 1;
11977 spec->automute_mode = ALC_AUTOMUTE_AMP;
Jiang zhe0e31daf2008-03-20 12:12:39 +010011978}
11979
11980static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11981 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11982 {
11983 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11984 .name = "Master Playback Switch",
Takashi Iwai0f0f3912011-04-28 16:26:24 +020011985 .subdevice = HDA_SUBDEV_NID_FLAG | 0x1b,
11986 .info = snd_ctl_boolean_mono_info,
11987 .get = alc262_hp_master_sw_get,
11988 .put = alc262_hp_master_sw_put,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011989 },
11990 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11991 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011992 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011993 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11994 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011995 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010011996 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11997 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011998 { } /* end */
11999};
12000
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012001static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
12002 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020012003 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012004 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12005 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010012006 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012007 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12008 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010012009 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012010 { } /* end */
12011};
12012
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012013/* additional init verbs for Benq laptops */
12014static struct hda_verb alc262_EAPD_verbs[] = {
12015 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
12016 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
12017 {}
12018};
12019
Kailang Yang83c34212007-07-05 11:43:05 +020012020static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
12021 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12022 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12023
12024 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
12025 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
12026 {}
12027};
12028
Tobin Davisf651b502007-10-26 12:40:47 +020012029/* Samsung Q1 Ultra Vista model setup */
12030static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012031 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
12032 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020012033 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12034 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010012035 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
12036 HDA_CODEC_VOLUME("Headphone Mic Boost Volume", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020012037 { } /* end */
12038};
12039
12040static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012041 /* output mixer */
12042 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12043 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12044 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12045 /* speaker */
12046 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12047 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12048 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12049 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12050 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020012051 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012052 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12053 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12054 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12055 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12056 /* internal mic */
12057 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12058 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12059 /* ADC, choose mic */
12060 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12061 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12062 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12063 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12064 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12065 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12066 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12067 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12068 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
12069 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020012070 {}
12071};
12072
Tobin Davisf651b502007-10-26 12:40:47 +020012073/* mute/unmute internal speaker according to the hp jack and mute state */
12074static void alc262_ultra_automute(struct hda_codec *codec)
12075{
12076 struct alc_spec *spec = codec->spec;
12077 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020012078
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012079 mute = 0;
12080 /* auto-mute only when HP is used as HP */
12081 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012082 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012083 if (spec->jack_present)
12084 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020012085 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012086 /* mute/unmute internal speaker */
12087 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12088 HDA_AMP_MUTE, mute);
12089 /* mute/unmute HP */
12090 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12091 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020012092}
12093
12094/* unsolicited event for HP jack sensing */
12095static void alc262_ultra_unsol_event(struct hda_codec *codec,
12096 unsigned int res)
12097{
12098 if ((res >> 26) != ALC880_HP_EVENT)
12099 return;
12100 alc262_ultra_automute(codec);
12101}
12102
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012103static struct hda_input_mux alc262_ultra_capture_source = {
12104 .num_items = 2,
12105 .items = {
12106 { "Mic", 0x1 },
12107 { "Headphone", 0x7 },
12108 },
12109};
12110
12111static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
12112 struct snd_ctl_elem_value *ucontrol)
12113{
12114 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12115 struct alc_spec *spec = codec->spec;
12116 int ret;
12117
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012118 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012119 if (!ret)
12120 return 0;
12121 /* reprogram the HP pin as mic or HP according to the input source */
12122 snd_hda_codec_write_cache(codec, 0x15, 0,
12123 AC_VERB_SET_PIN_WIDGET_CONTROL,
12124 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
12125 alc262_ultra_automute(codec); /* mute/unmute HP */
12126 return ret;
12127}
12128
12129static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
12130 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
12131 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
12132 {
12133 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12134 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012135 .info = alc_mux_enum_info,
12136 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012137 .put = alc262_ultra_mux_enum_put,
12138 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010012139 {
12140 .iface = NID_MAPPING,
12141 .name = "Capture Source",
12142 .private_value = 0x15,
12143 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012144 { } /* end */
12145};
12146
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012147/* We use two mixers depending on the output pin; 0x16 is a mono output
12148 * and thus it's bound with a different mixer.
12149 * This function returns which mixer amp should be used.
12150 */
12151static int alc262_check_volbit(hda_nid_t nid)
12152{
12153 if (!nid)
12154 return 0;
12155 else if (nid == 0x16)
12156 return 2;
12157 else
12158 return 1;
12159}
12160
12161static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012162 const char *pfx, int *vbits, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012163{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012164 unsigned long val;
12165 int vbit;
12166
12167 vbit = alc262_check_volbit(nid);
12168 if (!vbit)
12169 return 0;
12170 if (*vbits & vbit) /* a volume control for this mixer already there */
12171 return 0;
12172 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012173 if (vbit == 2)
12174 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
12175 else
12176 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012177 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012178}
12179
12180static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012181 const char *pfx, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012182{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012183 unsigned long val;
12184
12185 if (!nid)
12186 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012187 if (nid == 0x16)
12188 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
12189 else
12190 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012191 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012192}
12193
Kailang Yangdf694da2005-12-05 19:42:22 +010012194/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012195static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
12196 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012197{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012198 const char *pfx;
12199 int vbits;
Takashi Iwai033688a2010-09-08 15:47:09 +020012200 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +010012201
12202 spec->multiout.num_dacs = 1; /* only use one dac */
12203 spec->multiout.dac_nids = spec->private_dac_nids;
12204 spec->multiout.dac_nids[0] = 2;
12205
Takashi Iwaice764ab2011-04-27 16:35:23 +020012206 pfx = alc_get_line_out_pfx(spec, true);
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010012207 if (!pfx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012208 pfx = "Front";
Takashi Iwai033688a2010-09-08 15:47:09 +020012209 for (i = 0; i < 2; i++) {
12210 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, i);
12211 if (err < 0)
12212 return err;
12213 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12214 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i],
12215 "Speaker", i);
12216 if (err < 0)
12217 return err;
12218 }
12219 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12220 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i],
12221 "Headphone", i);
12222 if (err < 0)
12223 return err;
12224 }
12225 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012226
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012227 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
12228 alc262_check_volbit(cfg->speaker_pins[0]) |
12229 alc262_check_volbit(cfg->hp_pins[0]);
12230 if (vbits == 1 || vbits == 2)
12231 pfx = "Master"; /* only one mixer is used */
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012232 vbits = 0;
Takashi Iwai033688a2010-09-08 15:47:09 +020012233 for (i = 0; i < 2; i++) {
12234 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx,
12235 &vbits, i);
12236 if (err < 0)
12237 return err;
12238 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12239 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i],
12240 "Speaker", &vbits, i);
12241 if (err < 0)
12242 return err;
12243 }
12244 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12245 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i],
12246 "Headphone", &vbits, i);
12247 if (err < 0)
12248 return err;
12249 }
12250 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012251 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010012252}
12253
Takashi Iwai05f5f472009-08-25 13:10:18 +020012254#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010012255 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010012256
12257/*
12258 * generic initialization of ADC, input mixers and output mixers
12259 */
12260static struct hda_verb alc262_volume_init_verbs[] = {
12261 /*
12262 * Unmute ADC0-2 and set the default input to mic-in
12263 */
12264 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12265 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12266 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12267 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12268 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12269 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12270
Takashi Iwaicb53c622007-08-10 17:21:45 +020012271 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010012272 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012273 * Note: PASD motherboards uses the Line In 2 as the input for
12274 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010012275 */
12276 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012277 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12278 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12279 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12280 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12281 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012282
12283 /*
12284 * Set up output mixers (0x0c - 0x0f)
12285 */
12286 /* set vol=0 to output mixers */
12287 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12288 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12289 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020012290
Kailang Yangdf694da2005-12-05 19:42:22 +010012291 /* set up input amps for analog loopback */
12292 /* Amp Indices: DAC = 0, mixer = 1 */
12293 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12294 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12295 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12296 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12297 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12298 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12299
12300 /* FIXME: use matrix-type input source selection */
12301 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12302 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12303 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12304 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12305 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12306 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12307 /* Input mixer2 */
12308 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12309 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12310 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12311 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12312 /* Input mixer3 */
12313 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12314 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12315 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12316 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12317
12318 { }
12319};
12320
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012321static struct hda_verb alc262_HP_BPC_init_verbs[] = {
12322 /*
12323 * Unmute ADC0-2 and set the default input to mic-in
12324 */
12325 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12326 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12327 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12328 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12329 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12330 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12331
Takashi Iwaicb53c622007-08-10 17:21:45 +020012332 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012333 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012334 * Note: PASD motherboards uses the Line In 2 as the input for
12335 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012336 */
12337 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012338 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12339 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12340 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12341 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12342 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12343 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12344 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012345
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012346 /*
12347 * Set up output mixers (0x0c - 0x0e)
12348 */
12349 /* set vol=0 to output mixers */
12350 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12351 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12352 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12353
12354 /* set up input amps for analog loopback */
12355 /* Amp Indices: DAC = 0, mixer = 1 */
12356 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12357 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12358 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12359 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12360 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12361 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12362
Takashi Iwaice875f02008-01-28 18:17:43 +010012363 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012364 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12365 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12366
12367 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12368 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12369
12370 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12371 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12372
12373 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12374 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12375 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12376 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12377 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12378
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012379 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012380 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12381 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012382 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012383 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12384 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12385
12386
12387 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012388 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
12389 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012390 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012391 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12392 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12393 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12394 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12395 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12396 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12397 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12398 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012399 /* Input mixer2 */
12400 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012401 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12402 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12403 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12404 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12405 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12406 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12407 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12408 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012409 /* Input mixer3 */
12410 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012411 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12412 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12413 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12414 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12415 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12416 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12417 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12418 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012419
Takashi Iwaice875f02008-01-28 18:17:43 +010012420 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12421
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012422 { }
12423};
12424
Kailang Yangcd7509a2007-01-26 18:33:17 +010012425static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
12426 /*
12427 * Unmute ADC0-2 and set the default input to mic-in
12428 */
12429 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12430 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12431 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12432 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12433 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12434 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12435
Takashi Iwaicb53c622007-08-10 17:21:45 +020012436 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010012437 * mixer widget
12438 * Note: PASD motherboards uses the Line In 2 as the input for front
12439 * panel mic (mic 2)
12440 */
12441 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012442 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12443 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12444 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12445 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12446 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12447 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12448 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12449 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010012450 /*
12451 * Set up output mixers (0x0c - 0x0e)
12452 */
12453 /* set vol=0 to output mixers */
12454 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12455 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12456 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12457
12458 /* set up input amps for analog loopback */
12459 /* Amp Indices: DAC = 0, mixer = 1 */
12460 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12461 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12462 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12463 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12464 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12465 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12466
12467
12468 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
12469 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
12470 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
12471 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
12472 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12473 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
12474 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
12475
12476 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12477 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12478
12479 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12480 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12481
12482 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
12483 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12484 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12485 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
12486 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12487 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12488
12489 /* FIXME: use matrix-type input source selection */
12490 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12491 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12492 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
12493 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
12494 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
12495 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
12496 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
12497 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12498 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
12499 /* Input mixer2 */
12500 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12501 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12502 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12503 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12504 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12505 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12506 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12507 /* Input mixer3 */
12508 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12509 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12510 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12511 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12512 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12513 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12514 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12515
Takashi Iwaice875f02008-01-28 18:17:43 +010012516 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12517
Kailang Yangcd7509a2007-01-26 18:33:17 +010012518 { }
12519};
12520
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012521static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
12522
12523 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12524 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12525 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12526
12527 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12528 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12529 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12530 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12531
12532 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12533 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12534 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12535 {}
12536};
12537
Takashi Iwai18675e42010-09-08 15:55:44 +020012538/*
12539 * Pin config fixes
12540 */
12541enum {
12542 PINFIX_FSC_H270,
12543};
12544
12545static const struct alc_fixup alc262_fixups[] = {
12546 [PINFIX_FSC_H270] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010012547 .type = ALC_FIXUP_PINS,
12548 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai18675e42010-09-08 15:55:44 +020012549 { 0x14, 0x99130110 }, /* speaker */
12550 { 0x15, 0x0221142f }, /* front HP */
12551 { 0x1b, 0x0121141f }, /* rear HP */
12552 { }
12553 }
12554 },
Takashi Iwai18675e42010-09-08 15:55:44 +020012555};
12556
12557static struct snd_pci_quirk alc262_fixup_tbl[] = {
12558 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270),
12559 {}
12560};
12561
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012562
Takashi Iwaicb53c622007-08-10 17:21:45 +020012563#ifdef CONFIG_SND_HDA_POWER_SAVE
12564#define alc262_loopbacks alc880_loopbacks
12565#endif
12566
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012567/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012568#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12569#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12570#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12571#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12572
12573/*
12574 * BIOS auto configuration
12575 */
12576static int alc262_parse_auto_config(struct hda_codec *codec)
12577{
12578 struct alc_spec *spec = codec->spec;
12579 int err;
12580 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12581
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012582 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12583 alc262_ignore);
12584 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012585 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012586 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012587 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012588 spec->multiout.max_channels = 2;
12589 spec->no_analog = 1;
12590 goto dig_only;
12591 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012592 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012593 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012594 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12595 if (err < 0)
12596 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012597 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012598 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012599 return err;
12600
12601 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12602
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012603 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012604 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012605
Takashi Iwai603c4012008-07-30 15:01:44 +020012606 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012607 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012608
Takashi Iwaid88897e2008-10-31 15:01:37 +010012609 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012610 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012611 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012612
Takashi Iwai776e1842007-08-29 15:07:11 +020012613 err = alc_auto_add_mic_boost(codec);
12614 if (err < 0)
12615 return err;
12616
Kailang Yang6227cdc2010-02-25 08:36:52 +010012617 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012618
Kailang Yangdf694da2005-12-05 19:42:22 +010012619 return 1;
12620}
12621
12622#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12623#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12624#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012625#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012626
12627
12628/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012629static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012630{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012631 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012632 alc262_auto_init_multi_out(codec);
12633 alc262_auto_init_hp_out(codec);
12634 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012635 alc262_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012636 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012637 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012638 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012639}
12640
12641/*
12642 * configuration and preset
12643 */
Takashi Iwaiea734962011-01-17 11:29:34 +010012644static const char * const alc262_models[ALC262_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012645 [ALC262_BASIC] = "basic",
12646 [ALC262_HIPPO] = "hippo",
12647 [ALC262_HIPPO_1] = "hippo_1",
12648 [ALC262_FUJITSU] = "fujitsu",
12649 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012650 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012651 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012652 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012653 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012654 [ALC262_BENQ_T31] = "benq-t31",
12655 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012656 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012657 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012658 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012659 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012660 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012661 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012662 [ALC262_AUTO] = "auto",
12663};
12664
12665static struct snd_pci_quirk alc262_cfg_tbl[] = {
12666 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012667 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012668 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12669 ALC262_HP_BPC),
12670 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12671 ALC262_HP_BPC),
Takashi Iwai5734a072011-01-19 17:07:12 +010012672 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1500, "HP z series",
12673 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012674 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12675 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012676 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012677 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012678 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012679 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012680 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012681 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012682 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012683 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012684 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12685 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12686 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012687 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12688 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012689 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012690 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012691 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012692 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012693 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012694 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012695 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012696 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012697#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012698 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12699 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012700#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012701 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012702 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012703 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012704 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012705 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012706 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012707 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12708 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012709 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012710 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012711 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012712 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012713 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012714 {}
12715};
12716
12717static struct alc_config_preset alc262_presets[] = {
12718 [ALC262_BASIC] = {
12719 .mixers = { alc262_base_mixer },
12720 .init_verbs = { alc262_init_verbs },
12721 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12722 .dac_nids = alc262_dac_nids,
12723 .hp_nid = 0x03,
12724 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12725 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012726 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012727 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012728 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012729 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012730 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012731 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12732 .dac_nids = alc262_dac_nids,
12733 .hp_nid = 0x03,
12734 .dig_out_nid = ALC262_DIGOUT_NID,
12735 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12736 .channel_mode = alc262_modes,
12737 .input_mux = &alc262_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012738 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012739 .setup = alc262_hippo_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020012740 .init_hook = alc_inithook,
Kailang Yangccc656c2006-10-17 12:32:26 +020012741 },
12742 [ALC262_HIPPO_1] = {
12743 .mixers = { alc262_hippo1_mixer },
12744 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12745 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12746 .dac_nids = alc262_dac_nids,
12747 .hp_nid = 0x02,
12748 .dig_out_nid = ALC262_DIGOUT_NID,
12749 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12750 .channel_mode = alc262_modes,
12751 .input_mux = &alc262_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012752 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012753 .setup = alc262_hippo1_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020012754 .init_hook = alc_inithook,
Kailang Yangccc656c2006-10-17 12:32:26 +020012755 },
Takashi Iwai834be882006-03-01 14:16:17 +010012756 [ALC262_FUJITSU] = {
12757 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012758 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12759 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012760 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12761 .dac_nids = alc262_dac_nids,
12762 .hp_nid = 0x03,
12763 .dig_out_nid = ALC262_DIGOUT_NID,
12764 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12765 .channel_mode = alc262_modes,
12766 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwai0f0f3912011-04-28 16:26:24 +020012767 .unsol_event = alc_sku_unsol_event,
12768 .setup = alc262_fujitsu_setup,
12769 .init_hook = alc_inithook,
Takashi Iwai834be882006-03-01 14:16:17 +010012770 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012771 [ALC262_HP_BPC] = {
12772 .mixers = { alc262_HP_BPC_mixer },
12773 .init_verbs = { alc262_HP_BPC_init_verbs },
12774 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12775 .dac_nids = alc262_dac_nids,
12776 .hp_nid = 0x03,
12777 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12778 .channel_mode = alc262_modes,
12779 .input_mux = &alc262_HP_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012780 .unsol_event = alc_sku_unsol_event,
12781 .setup = alc262_hp_bpc_setup,
12782 .init_hook = alc_inithook,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012783 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012784 [ALC262_HP_BPC_D7000_WF] = {
12785 .mixers = { alc262_HP_BPC_WildWest_mixer },
12786 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12787 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12788 .dac_nids = alc262_dac_nids,
12789 .hp_nid = 0x03,
12790 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12791 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012792 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012793 .unsol_event = alc_sku_unsol_event,
12794 .setup = alc262_hp_wildwest_setup,
12795 .init_hook = alc_inithook,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012796 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012797 [ALC262_HP_BPC_D7000_WL] = {
12798 .mixers = { alc262_HP_BPC_WildWest_mixer,
12799 alc262_HP_BPC_WildWest_option_mixer },
12800 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12801 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12802 .dac_nids = alc262_dac_nids,
12803 .hp_nid = 0x03,
12804 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12805 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012806 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012807 .unsol_event = alc_sku_unsol_event,
12808 .setup = alc262_hp_wildwest_setup,
12809 .init_hook = alc_inithook,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012810 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012811 [ALC262_HP_TC_T5735] = {
12812 .mixers = { alc262_hp_t5735_mixer },
12813 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12814 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12815 .dac_nids = alc262_dac_nids,
12816 .hp_nid = 0x03,
12817 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12818 .channel_mode = alc262_modes,
12819 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012820 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012821 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012822 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012823 },
12824 [ALC262_HP_RP5700] = {
12825 .mixers = { alc262_hp_rp5700_mixer },
12826 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12827 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12828 .dac_nids = alc262_dac_nids,
12829 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12830 .channel_mode = alc262_modes,
12831 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012832 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012833 [ALC262_BENQ_ED8] = {
12834 .mixers = { alc262_base_mixer },
12835 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12836 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12837 .dac_nids = alc262_dac_nids,
12838 .hp_nid = 0x03,
12839 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12840 .channel_mode = alc262_modes,
12841 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012842 },
Kailang Yang272a5272007-05-14 11:00:38 +020012843 [ALC262_SONY_ASSAMD] = {
12844 .mixers = { alc262_sony_mixer },
12845 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12846 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12847 .dac_nids = alc262_dac_nids,
12848 .hp_nid = 0x02,
12849 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12850 .channel_mode = alc262_modes,
12851 .input_mux = &alc262_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012852 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012853 .setup = alc262_hippo_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020012854 .init_hook = alc_inithook,
Kailang Yang83c34212007-07-05 11:43:05 +020012855 },
12856 [ALC262_BENQ_T31] = {
12857 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012858 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12859 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012860 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12861 .dac_nids = alc262_dac_nids,
12862 .hp_nid = 0x03,
12863 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12864 .channel_mode = alc262_modes,
12865 .input_mux = &alc262_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012866 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012867 .setup = alc262_hippo_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020012868 .init_hook = alc_inithook,
Kailang Yangea1fb292008-08-26 12:58:38 +020012869 },
Tobin Davisf651b502007-10-26 12:40:47 +020012870 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012871 .mixers = { alc262_ultra_mixer },
12872 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012873 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012874 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12875 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012876 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12877 .channel_mode = alc262_modes,
12878 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012879 .adc_nids = alc262_adc_nids, /* ADC0 */
12880 .capsrc_nids = alc262_capsrc_nids,
12881 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012882 .unsol_event = alc262_ultra_unsol_event,
12883 .init_hook = alc262_ultra_automute,
12884 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012885 [ALC262_LENOVO_3000] = {
12886 .mixers = { alc262_lenovo_3000_mixer },
12887 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012888 alc262_lenovo_3000_unsol_verbs,
12889 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012890 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12891 .dac_nids = alc262_dac_nids,
12892 .hp_nid = 0x03,
12893 .dig_out_nid = ALC262_DIGOUT_NID,
12894 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12895 .channel_mode = alc262_modes,
12896 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwai0f0f3912011-04-28 16:26:24 +020012897 .unsol_event = alc_sku_unsol_event,
12898 .setup = alc262_lenovo_3000_setup,
12899 .init_hook = alc_inithook,
Jiang zhe0e31daf2008-03-20 12:12:39 +010012900 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012901 [ALC262_NEC] = {
12902 .mixers = { alc262_nec_mixer },
12903 .init_verbs = { alc262_nec_verbs },
12904 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12905 .dac_nids = alc262_dac_nids,
12906 .hp_nid = 0x03,
12907 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12908 .channel_mode = alc262_modes,
12909 .input_mux = &alc262_capture_source,
12910 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012911 [ALC262_TOSHIBA_S06] = {
12912 .mixers = { alc262_toshiba_s06_mixer },
12913 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12914 alc262_eapd_verbs },
12915 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12916 .capsrc_nids = alc262_dmic_capsrc_nids,
12917 .dac_nids = alc262_dac_nids,
12918 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012919 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012920 .dig_out_nid = ALC262_DIGOUT_NID,
12921 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12922 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012923 .unsol_event = alc_sku_unsol_event,
12924 .setup = alc262_toshiba_s06_setup,
12925 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012926 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012927 [ALC262_TOSHIBA_RX1] = {
12928 .mixers = { alc262_toshiba_rx1_mixer },
12929 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12930 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12931 .dac_nids = alc262_dac_nids,
12932 .hp_nid = 0x03,
12933 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12934 .channel_mode = alc262_modes,
12935 .input_mux = &alc262_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012936 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012937 .setup = alc262_hippo_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020012938 .init_hook = alc_inithook,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012939 },
Tony Vroonba340e82009-02-02 19:01:30 +000012940 [ALC262_TYAN] = {
12941 .mixers = { alc262_tyan_mixer },
12942 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12943 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12944 .dac_nids = alc262_dac_nids,
12945 .hp_nid = 0x02,
12946 .dig_out_nid = ALC262_DIGOUT_NID,
12947 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12948 .channel_mode = alc262_modes,
12949 .input_mux = &alc262_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020012950 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012951 .setup = alc262_tyan_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020012952 .init_hook = alc_hp_automute,
Tony Vroonba340e82009-02-02 19:01:30 +000012953 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012954};
12955
12956static int patch_alc262(struct hda_codec *codec)
12957{
12958 struct alc_spec *spec;
12959 int board_config;
12960 int err;
12961
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012962 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012963 if (spec == NULL)
12964 return -ENOMEM;
12965
12966 codec->spec = spec;
12967#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012968 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12969 * under-run
12970 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012971 {
12972 int tmp;
12973 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12974 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12975 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12976 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12977 }
12978#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012979 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012980
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012981 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12982
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012983 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12984 alc262_models,
12985 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012986
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012987 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012988 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12989 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012990 board_config = ALC262_AUTO;
12991 }
12992
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010012993 if (board_config == ALC262_AUTO) {
12994 alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups);
12995 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
12996 }
Takashi Iwai18675e42010-09-08 15:55:44 +020012997
Kailang Yangdf694da2005-12-05 19:42:22 +010012998 if (board_config == ALC262_AUTO) {
12999 /* automatic parse from the BIOS config */
13000 err = alc262_parse_auto_config(codec);
13001 if (err < 0) {
13002 alc_free(codec);
13003 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013004 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013005 printk(KERN_INFO
13006 "hda_codec: Cannot set up configuration "
13007 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013008 board_config = ALC262_BASIC;
13009 }
13010 }
13011
Takashi Iwaidc1eae22010-07-29 15:30:02 +020013012 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010013013 err = snd_hda_attach_beep_device(codec, 0x1);
13014 if (err < 0) {
13015 alc_free(codec);
13016 return err;
13017 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013018 }
13019
Kailang Yangdf694da2005-12-05 19:42:22 +010013020 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013021 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013022
Kailang Yangdf694da2005-12-05 19:42:22 +010013023 spec->stream_analog_playback = &alc262_pcm_analog_playback;
13024 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020013025
Kailang Yangdf694da2005-12-05 19:42:22 +010013026 spec->stream_digital_playback = &alc262_pcm_digital_playback;
13027 spec->stream_digital_capture = &alc262_pcm_digital_capture;
13028
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013029 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020013030 int i;
13031 /* check whether the digital-mic has to be supported */
13032 for (i = 0; i < spec->input_mux->num_items; i++) {
13033 if (spec->input_mux->items[i].index >= 9)
13034 break;
13035 }
13036 if (i < spec->input_mux->num_items) {
13037 /* use only ADC0 */
13038 spec->adc_nids = alc262_dmic_adc_nids;
13039 spec->num_adc_nids = 1;
13040 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010013041 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020013042 /* all analog inputs */
13043 /* check whether NID 0x07 is valid */
13044 unsigned int wcap = get_wcaps(codec, 0x07);
13045
13046 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013047 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020013048 if (wcap != AC_WID_AUD_IN) {
13049 spec->adc_nids = alc262_adc_nids_alt;
13050 spec->num_adc_nids =
13051 ARRAY_SIZE(alc262_adc_nids_alt);
13052 spec->capsrc_nids = alc262_capsrc_nids_alt;
13053 } else {
13054 spec->adc_nids = alc262_adc_nids;
13055 spec->num_adc_nids =
13056 ARRAY_SIZE(alc262_adc_nids);
13057 spec->capsrc_nids = alc262_capsrc_nids;
13058 }
Kailang Yangdf694da2005-12-05 19:42:22 +010013059 }
13060 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010013061 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013062 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020013063 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010013064 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010013065
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010013066 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai18675e42010-09-08 15:55:44 +020013067
Takashi Iwai2134ea42008-01-10 16:53:55 +010013068 spec->vmaster_nid = 0x0c;
13069
Kailang Yangdf694da2005-12-05 19:42:22 +010013070 codec->patch_ops = alc_patch_ops;
13071 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013072 spec->init_hook = alc262_auto_init;
Takashi Iwai1c716152011-04-07 10:37:16 +020013073 spec->shutup = alc_eapd_shutup;
Kailang Yangbf1b0222010-10-21 08:49:56 +020013074
13075 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020013076#ifdef CONFIG_SND_HDA_POWER_SAVE
13077 if (!spec->loopback.amplist)
13078 spec->loopback.amplist = alc262_loopbacks;
13079#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020013080
Kailang Yangdf694da2005-12-05 19:42:22 +010013081 return 0;
13082}
13083
Kailang Yangdf694da2005-12-05 19:42:22 +010013084/*
Kailang Yanga361d842007-06-05 12:30:55 +020013085 * ALC268 channel source setting (2 channel)
13086 */
13087#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
13088#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020013089
Kailang Yanga361d842007-06-05 12:30:55 +020013090static hda_nid_t alc268_dac_nids[2] = {
13091 /* front, hp */
13092 0x02, 0x03
13093};
13094
13095static hda_nid_t alc268_adc_nids[2] = {
13096 /* ADC0-1 */
13097 0x08, 0x07
13098};
13099
13100static hda_nid_t alc268_adc_nids_alt[1] = {
13101 /* ADC0 */
13102 0x08
13103};
13104
Takashi Iwaie1406342008-02-11 18:32:32 +010013105static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
13106
Kailang Yanga361d842007-06-05 12:30:55 +020013107static struct snd_kcontrol_new alc268_base_mixer[] = {
13108 /* output mixer control */
13109 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13110 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13111 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13112 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013113 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13114 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
13115 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020013116 { }
13117};
13118
Takashi Iwai42171c12009-05-08 14:11:43 +020013119static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
13120 /* output mixer control */
13121 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13122 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13123 ALC262_HIPPO_MASTER_SWITCH,
David Henningsson5f99f862011-01-04 15:24:24 +010013124 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13125 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
13126 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020013127 { }
13128};
13129
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013130/* bind Beep switches of both NID 0x0f and 0x10 */
13131static struct hda_bind_ctls alc268_bind_beep_sw = {
13132 .ops = &snd_hda_bind_sw,
13133 .values = {
13134 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
13135 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
13136 0
13137 },
13138};
13139
13140static struct snd_kcontrol_new alc268_beep_mixer[] = {
13141 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
13142 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
13143 { }
13144};
13145
Kailang Yangd1a991a2007-08-15 16:21:59 +020013146static struct hda_verb alc268_eapd_verbs[] = {
13147 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13148 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13149 { }
13150};
13151
Takashi Iwaid2738092007-08-16 14:59:45 +020013152/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020013153static struct hda_verb alc268_toshiba_verbs[] = {
13154 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13155 { } /* end */
13156};
13157
13158/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020013159/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020013160static struct hda_bind_ctls alc268_acer_bind_master_vol = {
13161 .ops = &snd_hda_bind_vol,
13162 .values = {
13163 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
13164 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
13165 0
13166 },
13167};
13168
Takashi Iwai0f0f3912011-04-28 16:26:24 +020013169static void alc268_acer_setup(struct hda_codec *codec)
Takashi Iwai889c4392007-08-23 18:56:52 +020013170{
13171 struct alc_spec *spec = codec->spec;
Takashi Iwai889c4392007-08-23 18:56:52 +020013172
Takashi Iwai0f0f3912011-04-28 16:26:24 +020013173 spec->autocfg.hp_pins[0] = 0x14;
13174 spec->autocfg.speaker_pins[0] = 0x15;
13175 spec->automute = 1;
13176 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai889c4392007-08-23 18:56:52 +020013177}
13178
Takashi Iwai0f0f3912011-04-28 16:26:24 +020013179#define alc268_acer_master_sw_get alc262_hp_master_sw_get
13180#define alc268_acer_master_sw_put alc262_hp_master_sw_put
Takashi Iwaid2738092007-08-16 14:59:45 +020013181
Kailang Yang8ef355d2008-08-26 13:10:22 +020013182static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
13183 /* output mixer control */
13184 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13185 {
13186 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13187 .name = "Master Playback Switch",
Takashi Iwai0f0f3912011-04-28 16:26:24 +020013188 .subdevice = HDA_SUBDEV_NID_FLAG | 0x15,
13189 .info = snd_ctl_boolean_mono_info,
13190 .get = alc268_acer_master_sw_get,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013191 .put = alc268_acer_master_sw_put,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013192 },
13193 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
13194 { }
13195};
13196
Takashi Iwaid2738092007-08-16 14:59:45 +020013197static struct snd_kcontrol_new alc268_acer_mixer[] = {
13198 /* output mixer control */
13199 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13200 {
13201 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13202 .name = "Master Playback Switch",
Takashi Iwai0f0f3912011-04-28 16:26:24 +020013203 .subdevice = HDA_SUBDEV_NID_FLAG | 0x14,
13204 .info = snd_ctl_boolean_mono_info,
13205 .get = alc268_acer_master_sw_get,
Takashi Iwaid2738092007-08-16 14:59:45 +020013206 .put = alc268_acer_master_sw_put,
Takashi Iwaid2738092007-08-16 14:59:45 +020013207 },
David Henningsson5f99f862011-01-04 15:24:24 +010013208 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13209 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
13210 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020013211 { }
13212};
13213
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013214static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
13215 /* output mixer control */
13216 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13217 {
13218 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13219 .name = "Master Playback Switch",
Takashi Iwai0f0f3912011-04-28 16:26:24 +020013220 .subdevice = HDA_SUBDEV_NID_FLAG | 0x14,
13221 .info = snd_ctl_boolean_mono_info,
13222 .get = alc268_acer_master_sw_get,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013223 .put = alc268_acer_master_sw_put,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013224 },
David Henningsson5f99f862011-01-04 15:24:24 +010013225 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13226 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013227 { }
13228};
13229
Kailang Yang8ef355d2008-08-26 13:10:22 +020013230static struct hda_verb alc268_acer_aspire_one_verbs[] = {
13231 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13232 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13233 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13234 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13235 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
13236 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
13237 { }
13238};
13239
Takashi Iwaid2738092007-08-16 14:59:45 +020013240static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013241 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
13242 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020013243 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13244 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013245 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13246 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020013247 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13248 { }
13249};
13250
13251/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013252#define alc268_toshiba_setup alc262_hippo_setup
Takashi Iwaid2738092007-08-16 14:59:45 +020013253
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013254static void alc268_acer_lc_setup(struct hda_codec *codec)
13255{
13256 struct alc_spec *spec = codec->spec;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020013257 spec->autocfg.hp_pins[0] = 0x15;
13258 spec->autocfg.speaker_pins[0] = 0x14;
13259 spec->automute_mixer_nid[0] = 0x0f;
13260 spec->automute = 1;
13261 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013262 spec->ext_mic.pin = 0x18;
13263 spec->ext_mic.mux_idx = 0;
13264 spec->int_mic.pin = 0x12;
13265 spec->int_mic.mux_idx = 6;
13266 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013267}
13268
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013269static struct snd_kcontrol_new alc268_dell_mixer[] = {
13270 /* output mixer control */
13271 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13272 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13273 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13274 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013275 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13276 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013277 { }
13278};
13279
13280static struct hda_verb alc268_dell_verbs[] = {
13281 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13282 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13283 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013284 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013285 { }
13286};
13287
13288/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013289static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013290{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013291 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013292
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013293 spec->autocfg.hp_pins[0] = 0x15;
13294 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013295 spec->ext_mic.pin = 0x18;
13296 spec->ext_mic.mux_idx = 0;
13297 spec->int_mic.pin = 0x19;
13298 spec->int_mic.mux_idx = 1;
13299 spec->auto_mic = 1;
Takashi Iwaid922b512011-04-28 12:18:53 +020013300 spec->automute = 1;
13301 spec->automute_mode = ALC_AUTOMUTE_PIN;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013302}
13303
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013304static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
13305 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13306 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13307 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13308 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13309 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13310 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013311 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13312 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013313 { }
13314};
13315
13316static struct hda_verb alc267_quanta_il1_verbs[] = {
13317 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13318 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
13319 { }
13320};
13321
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013322static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013323{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013324 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013325 spec->autocfg.hp_pins[0] = 0x15;
13326 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013327 spec->ext_mic.pin = 0x18;
13328 spec->ext_mic.mux_idx = 0;
13329 spec->int_mic.pin = 0x19;
13330 spec->int_mic.mux_idx = 1;
13331 spec->auto_mic = 1;
Takashi Iwaid922b512011-04-28 12:18:53 +020013332 spec->automute = 1;
13333 spec->automute_mode = ALC_AUTOMUTE_PIN;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013334}
13335
Kailang Yanga361d842007-06-05 12:30:55 +020013336/*
13337 * generic initialization of ADC, input mixers and output mixers
13338 */
13339static struct hda_verb alc268_base_init_verbs[] = {
13340 /* Unmute DAC0-1 and set vol = 0 */
13341 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013342 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013343
13344 /*
13345 * Set up output mixers (0x0c - 0x0e)
13346 */
13347 /* set vol=0 to output mixers */
13348 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013349 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
13350
13351 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13352 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13353
13354 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13355 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
13356 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13357 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13358 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13359 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13360 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13361 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13362
13363 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13364 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13365 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13366 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013367 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013368
13369 /* set PCBEEP vol = 0, mute connections */
13370 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13371 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13372 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013373
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013374 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013375
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013376 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13377 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13378 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13379 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013380
Kailang Yanga361d842007-06-05 12:30:55 +020013381 { }
13382};
13383
13384/*
13385 * generic initialization of ADC, input mixers and output mixers
13386 */
13387static struct hda_verb alc268_volume_init_verbs[] = {
13388 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013389 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13390 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013391
13392 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13393 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13394 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13395 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13396 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13397
Kailang Yanga361d842007-06-05 12:30:55 +020013398 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013399 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13400 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13401
13402 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013403 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013404
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013405 /* set PCBEEP vol = 0, mute connections */
13406 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13407 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13408 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013409
13410 { }
13411};
13412
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013413static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
13414 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13415 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13416 { } /* end */
13417};
13418
Kailang Yanga361d842007-06-05 12:30:55 +020013419static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
13420 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13421 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013422 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013423 { } /* end */
13424};
13425
13426static struct snd_kcontrol_new alc268_capture_mixer[] = {
13427 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13428 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13429 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13430 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013431 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013432 { } /* end */
13433};
13434
13435static struct hda_input_mux alc268_capture_source = {
13436 .num_items = 4,
13437 .items = {
13438 { "Mic", 0x0 },
13439 { "Front Mic", 0x1 },
13440 { "Line", 0x2 },
13441 { "CD", 0x3 },
13442 },
13443};
13444
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013445static struct hda_input_mux alc268_acer_capture_source = {
13446 .num_items = 3,
13447 .items = {
13448 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013449 { "Internal Mic", 0x1 },
13450 { "Line", 0x2 },
13451 },
13452};
13453
13454static struct hda_input_mux alc268_acer_dmic_capture_source = {
13455 .num_items = 3,
13456 .items = {
13457 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013458 { "Internal Mic", 0x6 },
13459 { "Line", 0x2 },
13460 },
13461};
13462
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013463#ifdef CONFIG_SND_DEBUG
13464static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013465 /* Volume widgets */
13466 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13467 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13468 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13469 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13470 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13471 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13472 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13473 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13474 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13475 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13476 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13477 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13478 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013479 /* The below appears problematic on some hardwares */
13480 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013481 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13482 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13483 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13484 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13485
13486 /* Modes for retasking pin widgets */
13487 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13488 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13489 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13490 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13491
13492 /* Controls for GPIO pins, assuming they are configured as outputs */
13493 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13494 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13495 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13496 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13497
13498 /* Switches to allow the digital SPDIF output pin to be enabled.
13499 * The ALC268 does not have an SPDIF input.
13500 */
13501 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13502
13503 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13504 * this output to turn on an external amplifier.
13505 */
13506 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13507 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13508
13509 { } /* end */
13510};
13511#endif
13512
Kailang Yanga361d842007-06-05 12:30:55 +020013513/* create input playback/capture controls for the given pin */
13514static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13515 const char *ctlname, int idx)
13516{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013517 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013518 int err;
13519
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013520 switch (nid) {
13521 case 0x14:
13522 case 0x16:
13523 dac = 0x02;
13524 break;
13525 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013526 case 0x1a: /* ALC259/269 only */
13527 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013528 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013529 dac = 0x03;
13530 break;
13531 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013532 snd_printd(KERN_WARNING "hda_codec: "
13533 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013534 return 0;
13535 }
13536 if (spec->multiout.dac_nids[0] != dac &&
13537 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013538 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013539 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013540 HDA_OUTPUT));
13541 if (err < 0)
13542 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013543 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13544 }
13545
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013546 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013547 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013548 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013549 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013550 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013551 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013552 if (err < 0)
13553 return err;
13554 return 0;
13555}
13556
13557/* add playback controls from the parsed DAC table */
13558static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13559 const struct auto_pin_cfg *cfg)
13560{
13561 hda_nid_t nid;
13562 int err;
13563
Kailang Yanga361d842007-06-05 12:30:55 +020013564 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013565
13566 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013567 if (nid) {
13568 const char *name;
13569 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13570 name = "Speaker";
13571 else
13572 name = "Front";
13573 err = alc268_new_analog_output(spec, nid, name, 0);
13574 if (err < 0)
13575 return err;
13576 }
Kailang Yanga361d842007-06-05 12:30:55 +020013577
13578 nid = cfg->speaker_pins[0];
13579 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013580 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013581 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13582 if (err < 0)
13583 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013584 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013585 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13586 if (err < 0)
13587 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013588 }
13589 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013590 if (nid) {
13591 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13592 if (err < 0)
13593 return err;
13594 }
Kailang Yanga361d842007-06-05 12:30:55 +020013595
13596 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13597 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013598 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013599 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013600 if (err < 0)
13601 return err;
13602 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013603 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013604}
13605
13606/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013607static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013608 const struct auto_pin_cfg *cfg)
13609{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013610 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013611}
13612
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013613static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13614 hda_nid_t nid, int pin_type)
13615{
13616 int idx;
13617
13618 alc_set_pin_output(codec, nid, pin_type);
13619 if (nid == 0x14 || nid == 0x16)
13620 idx = 0;
13621 else
13622 idx = 1;
13623 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13624}
13625
13626static void alc268_auto_init_multi_out(struct hda_codec *codec)
13627{
13628 struct alc_spec *spec = codec->spec;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013629 int i;
13630
13631 for (i = 0; i < spec->autocfg.line_outs; i++) {
13632 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013633 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13634 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13635 }
13636}
13637
13638static void alc268_auto_init_hp_out(struct hda_codec *codec)
13639{
13640 struct alc_spec *spec = codec->spec;
13641 hda_nid_t pin;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013642 int i;
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013643
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013644 for (i = 0; i < spec->autocfg.hp_outs; i++) {
13645 pin = spec->autocfg.hp_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013646 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013647 }
13648 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
13649 pin = spec->autocfg.speaker_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013650 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013651 }
13652 if (spec->autocfg.mono_out_pin)
13653 snd_hda_codec_write(codec, spec->autocfg.mono_out_pin, 0,
13654 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013655}
13656
Kailang Yanga361d842007-06-05 12:30:55 +020013657static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13658{
13659 struct alc_spec *spec = codec->spec;
13660 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13661 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13662 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13663 unsigned int dac_vol1, dac_vol2;
13664
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013665 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013666 snd_hda_codec_write(codec, speaker_nid, 0,
13667 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013668 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013669 snd_hda_codec_write(codec, 0x0f, 0,
13670 AC_VERB_SET_AMP_GAIN_MUTE,
13671 AMP_IN_UNMUTE(1));
13672 snd_hda_codec_write(codec, 0x10, 0,
13673 AC_VERB_SET_AMP_GAIN_MUTE,
13674 AMP_IN_UNMUTE(1));
13675 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013676 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013677 snd_hda_codec_write(codec, 0x0f, 0,
13678 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13679 snd_hda_codec_write(codec, 0x10, 0,
13680 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13681 }
13682
13683 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013684 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013685 dac_vol2 = AMP_OUT_ZERO;
13686 else if (line_nid == 0x15)
13687 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013688 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013689 dac_vol2 = AMP_OUT_ZERO;
13690 else if (hp_nid == 0x15)
13691 dac_vol1 = AMP_OUT_ZERO;
13692 if (line_nid != 0x16 || hp_nid != 0x16 ||
13693 spec->autocfg.line_out_pins[1] != 0x16 ||
13694 spec->autocfg.line_out_pins[2] != 0x16)
13695 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13696
13697 snd_hda_codec_write(codec, 0x02, 0,
13698 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13699 snd_hda_codec_write(codec, 0x03, 0,
13700 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13701}
13702
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013703/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013704#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13705#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013706#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013707#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13708
13709/*
13710 * BIOS auto configuration
13711 */
13712static int alc268_parse_auto_config(struct hda_codec *codec)
13713{
13714 struct alc_spec *spec = codec->spec;
13715 int err;
13716 static hda_nid_t alc268_ignore[] = { 0 };
13717
13718 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13719 alc268_ignore);
13720 if (err < 0)
13721 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013722 if (!spec->autocfg.line_outs) {
13723 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13724 spec->multiout.max_channels = 2;
13725 spec->no_analog = 1;
13726 goto dig_only;
13727 }
Kailang Yanga361d842007-06-05 12:30:55 +020013728 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013729 }
Kailang Yanga361d842007-06-05 12:30:55 +020013730 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13731 if (err < 0)
13732 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013733 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013734 if (err < 0)
13735 return err;
13736
13737 spec->multiout.max_channels = 2;
13738
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013739 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013740 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013741 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013742 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013743 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013744
Takashi Iwai892981f2009-03-02 08:04:35 +010013745 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013746 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013747
Takashi Iwaid88897e2008-10-31 15:01:37 +010013748 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013749 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013750 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013751
Takashi Iwai776e1842007-08-29 15:07:11 +020013752 err = alc_auto_add_mic_boost(codec);
13753 if (err < 0)
13754 return err;
13755
Kailang Yang6227cdc2010-02-25 08:36:52 +010013756 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013757
Kailang Yanga361d842007-06-05 12:30:55 +020013758 return 1;
13759}
13760
Kailang Yanga361d842007-06-05 12:30:55 +020013761#define alc268_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaiae0ebbf2011-03-10 14:11:59 +010013762#define alc268_auto_init_input_src alc882_auto_init_input_src
Kailang Yanga361d842007-06-05 12:30:55 +020013763
13764/* init callback for auto-configuration model -- overriding the default init */
13765static void alc268_auto_init(struct hda_codec *codec)
13766{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013767 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013768 alc268_auto_init_multi_out(codec);
13769 alc268_auto_init_hp_out(codec);
13770 alc268_auto_init_mono_speaker_out(codec);
13771 alc268_auto_init_analog_input(codec);
Takashi Iwaiae0ebbf2011-03-10 14:11:59 +010013772 alc268_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013773 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013774 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013775 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013776}
13777
13778/*
13779 * configuration and preset
13780 */
Takashi Iwaiea734962011-01-17 11:29:34 +010013781static const char * const alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013782 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013783 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013784 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013785 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013786 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013787 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013788 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013789 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013790#ifdef CONFIG_SND_DEBUG
13791 [ALC268_TEST] = "test",
13792#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013793 [ALC268_AUTO] = "auto",
13794};
13795
13796static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013797 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013798 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013799 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013800 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013801 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013802 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13803 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013804 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013805 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13806 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013807 /* almost compatible with toshiba but with optional digital outs;
13808 * auto-probing seems working fine
13809 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013810 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013811 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013812 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013813 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013814 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013815 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013816 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013817 {}
13818};
13819
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013820/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13821static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13822 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13823 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13824 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13825 ALC268_TOSHIBA),
13826 {}
13827};
13828
Kailang Yanga361d842007-06-05 12:30:55 +020013829static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013830 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013831 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13832 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013833 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13834 alc267_quanta_il1_verbs },
13835 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13836 .dac_nids = alc268_dac_nids,
13837 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13838 .adc_nids = alc268_adc_nids_alt,
13839 .hp_nid = 0x03,
13840 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13841 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013842 .unsol_event = alc_sku_unsol_event,
13843 .setup = alc267_quanta_il1_setup,
13844 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013845 },
Kailang Yanga361d842007-06-05 12:30:55 +020013846 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013847 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13848 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013849 .init_verbs = { alc268_base_init_verbs },
13850 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13851 .dac_nids = alc268_dac_nids,
13852 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13853 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013854 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013855 .hp_nid = 0x03,
13856 .dig_out_nid = ALC268_DIGOUT_NID,
13857 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13858 .channel_mode = alc268_modes,
13859 .input_mux = &alc268_capture_source,
13860 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013861 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013862 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013863 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013864 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13865 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013866 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13867 .dac_nids = alc268_dac_nids,
13868 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13869 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013870 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013871 .hp_nid = 0x03,
13872 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13873 .channel_mode = alc268_modes,
13874 .input_mux = &alc268_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020013875 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013876 .setup = alc268_toshiba_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020013877 .init_hook = alc_inithook,
Takashi Iwaid2738092007-08-16 14:59:45 +020013878 },
13879 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013880 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013881 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013882 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13883 alc268_acer_verbs },
13884 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13885 .dac_nids = alc268_dac_nids,
13886 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13887 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013888 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013889 .hp_nid = 0x02,
13890 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13891 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013892 .input_mux = &alc268_acer_capture_source,
Takashi Iwai0f0f3912011-04-28 16:26:24 +020013893 .unsol_event = alc_sku_unsol_event,
13894 .setup = alc268_acer_setup,
13895 .init_hook = alc_inithook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013896 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013897 [ALC268_ACER_DMIC] = {
13898 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13899 alc268_beep_mixer },
13900 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13901 alc268_acer_verbs },
13902 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13903 .dac_nids = alc268_dac_nids,
13904 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13905 .adc_nids = alc268_adc_nids_alt,
13906 .capsrc_nids = alc268_capsrc_nids,
13907 .hp_nid = 0x02,
13908 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13909 .channel_mode = alc268_modes,
13910 .input_mux = &alc268_acer_dmic_capture_source,
Takashi Iwai0f0f3912011-04-28 16:26:24 +020013911 .unsol_event = alc_sku_unsol_event,
13912 .setup = alc268_acer_setup,
13913 .init_hook = alc_inithook,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013914 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013915 [ALC268_ACER_ASPIRE_ONE] = {
13916 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013917 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013918 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013919 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13920 alc268_acer_aspire_one_verbs },
13921 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13922 .dac_nids = alc268_dac_nids,
13923 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13924 .adc_nids = alc268_adc_nids_alt,
13925 .capsrc_nids = alc268_capsrc_nids,
13926 .hp_nid = 0x03,
13927 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13928 .channel_mode = alc268_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020013929 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013930 .setup = alc268_acer_lc_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020013931 .init_hook = alc_inithook,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013932 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013933 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013934 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13935 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013936 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13937 alc268_dell_verbs },
13938 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13939 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013940 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13941 .adc_nids = alc268_adc_nids_alt,
13942 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013943 .hp_nid = 0x02,
13944 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13945 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013946 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013947 .setup = alc268_dell_setup,
13948 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013949 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013950 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013951 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13952 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013953 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13954 alc268_toshiba_verbs },
13955 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13956 .dac_nids = alc268_dac_nids,
13957 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13958 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013959 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013960 .hp_nid = 0x03,
13961 .dig_out_nid = ALC268_DIGOUT_NID,
13962 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13963 .channel_mode = alc268_modes,
13964 .input_mux = &alc268_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020013965 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013966 .setup = alc268_toshiba_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020013967 .init_hook = alc_inithook,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013968 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013969#ifdef CONFIG_SND_DEBUG
13970 [ALC268_TEST] = {
13971 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13972 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13973 alc268_volume_init_verbs },
13974 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13975 .dac_nids = alc268_dac_nids,
13976 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13977 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013978 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013979 .hp_nid = 0x03,
13980 .dig_out_nid = ALC268_DIGOUT_NID,
13981 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13982 .channel_mode = alc268_modes,
13983 .input_mux = &alc268_capture_source,
13984 },
13985#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013986};
13987
13988static int patch_alc268(struct hda_codec *codec)
13989{
13990 struct alc_spec *spec;
13991 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013992 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013993
Julia Lawallef86f582009-12-19 08:18:03 +010013994 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013995 if (spec == NULL)
13996 return -ENOMEM;
13997
13998 codec->spec = spec;
13999
14000 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
14001 alc268_models,
14002 alc268_cfg_tbl);
14003
Takashi Iwai3abf2f32009-08-19 20:05:02 +020014004 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
14005 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010014006 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020014007
Kailang Yanga361d842007-06-05 12:30:55 +020014008 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014009 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14010 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020014011 board_config = ALC268_AUTO;
14012 }
14013
14014 if (board_config == ALC268_AUTO) {
14015 /* automatic parse from the BIOS config */
14016 err = alc268_parse_auto_config(codec);
14017 if (err < 0) {
14018 alc_free(codec);
14019 return err;
14020 } else if (!err) {
14021 printk(KERN_INFO
14022 "hda_codec: Cannot set up configuration "
14023 "from BIOS. Using base mode...\n");
14024 board_config = ALC268_3ST;
14025 }
14026 }
14027
14028 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014029 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020014030
Kailang Yanga361d842007-06-05 12:30:55 +020014031 spec->stream_analog_playback = &alc268_pcm_analog_playback;
14032 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010014033 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020014034
Kailang Yanga361d842007-06-05 12:30:55 +020014035 spec->stream_digital_playback = &alc268_pcm_digital_playback;
14036
Takashi Iwai22971e32009-02-10 11:56:44 +010014037 has_beep = 0;
14038 for (i = 0; i < spec->num_mixers; i++) {
14039 if (spec->mixers[i] == alc268_beep_mixer) {
14040 has_beep = 1;
14041 break;
14042 }
14043 }
14044
14045 if (has_beep) {
14046 err = snd_hda_attach_beep_device(codec, 0x1);
14047 if (err < 0) {
14048 alc_free(codec);
14049 return err;
14050 }
14051 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
14052 /* override the amp caps for beep generator */
14053 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010014054 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
14055 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
14056 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
14057 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010014058 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010014059
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014060 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014061 /* check whether NID 0x07 is valid */
14062 unsigned int wcap = get_wcaps(codec, 0x07);
Kailang Yanga361d842007-06-05 12:30:55 +020014063
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014064 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014065 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020014066 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014067 if (spec->auto_mic ||
14068 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014069 spec->adc_nids = alc268_adc_nids_alt;
14070 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014071 if (spec->auto_mic)
14072 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014073 if (spec->auto_mic || spec->input_mux->num_items == 1)
14074 add_mixer(spec, alc268_capture_nosrc_mixer);
14075 else
14076 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014077 } else {
14078 spec->adc_nids = alc268_adc_nids;
14079 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010014080 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020014081 }
14082 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010014083
14084 spec->vmaster_nid = 0x02;
14085
Kailang Yanga361d842007-06-05 12:30:55 +020014086 codec->patch_ops = alc_patch_ops;
14087 if (board_config == ALC268_AUTO)
14088 spec->init_hook = alc268_auto_init;
Takashi Iwai1c716152011-04-07 10:37:16 +020014089 spec->shutup = alc_eapd_shutup;
Kailang Yangea1fb292008-08-26 12:58:38 +020014090
Kailang Yangbf1b0222010-10-21 08:49:56 +020014091 alc_init_jacks(codec);
14092
Kailang Yanga361d842007-06-05 12:30:55 +020014093 return 0;
14094}
14095
14096/*
Kailang Yangf6a92242007-12-13 16:52:54 +010014097 * ALC269 channel source setting (2 channel)
14098 */
14099#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
14100
14101#define alc269_dac_nids alc260_dac_nids
14102
14103static hda_nid_t alc269_adc_nids[1] = {
14104 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020014105 0x08,
14106};
14107
Takashi Iwaie01bf502008-08-21 16:25:07 +020014108static hda_nid_t alc269_capsrc_nids[1] = {
14109 0x23,
14110};
14111
Kailang Yang84898e82010-02-04 14:16:14 +010014112static hda_nid_t alc269vb_adc_nids[1] = {
14113 /* ADC1 */
14114 0x09,
14115};
14116
14117static hda_nid_t alc269vb_capsrc_nids[1] = {
14118 0x22,
14119};
14120
Takashi Iwai66946352010-03-29 17:21:45 +020014121static hda_nid_t alc269_adc_candidates[] = {
David Henningsson262ac222011-04-07 11:43:00 +020014122 0x08, 0x09, 0x07, 0x11,
Takashi Iwai66946352010-03-29 17:21:45 +020014123};
Takashi Iwaie01bf502008-08-21 16:25:07 +020014124
Kailang Yangf6a92242007-12-13 16:52:54 +010014125#define alc269_modes alc260_modes
14126#define alc269_capture_source alc880_lg_lw_capture_source
14127
14128static struct snd_kcontrol_new alc269_base_mixer[] = {
14129 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14130 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14131 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14132 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14133 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14134 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014135 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010014136 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14137 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014138 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010014139 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14140 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
14141 { } /* end */
14142};
14143
Kailang Yang60db6b52008-08-26 13:13:00 +020014144static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
14145 /* output mixer control */
14146 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14147 {
14148 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14149 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014150 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020014151 .info = snd_hda_mixer_amp_switch_info,
14152 .get = snd_hda_mixer_amp_switch_get,
14153 .put = alc268_acer_master_sw_put,
14154 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14155 },
14156 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14157 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014158 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014159 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14160 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014161 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014162 { }
14163};
14164
Tony Vroon64154832008-11-06 15:08:49 +000014165static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
14166 /* output mixer control */
14167 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14168 {
14169 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14170 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014171 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000014172 .info = snd_hda_mixer_amp_switch_info,
14173 .get = snd_hda_mixer_amp_switch_get,
14174 .put = alc268_acer_master_sw_put,
14175 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14176 },
14177 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14178 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014179 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014180 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14181 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014182 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014183 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
14184 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014185 HDA_CODEC_VOLUME("Dock Mic Boost Volume", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014186 { }
14187};
14188
Kailang Yang84898e82010-02-04 14:16:14 +010014189static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020014190 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014191 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020014192 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014193 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020014194 { } /* end */
14195};
14196
Kailang Yang84898e82010-02-04 14:16:14 +010014197static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
14198 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14199 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14200 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14201 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14202 { } /* end */
14203};
14204
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014205static struct snd_kcontrol_new alc269_asus_mixer[] = {
14206 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14207 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
14208 { } /* end */
14209};
14210
Kailang Yangf6a92242007-12-13 16:52:54 +010014211/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010014212static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
14213 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14214 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014215 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
14216 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014217 { } /* end */
14218};
14219
14220static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020014221 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14222 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014223 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010014224 { } /* end */
14225};
14226
Kailang Yang84898e82010-02-04 14:16:14 +010014227static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
14228 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14229 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014230 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
14231 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014232 { } /* end */
14233};
14234
14235static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
14236 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14237 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014238 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014239 { } /* end */
14240};
14241
Takashi Iwai26f5df22008-11-03 17:39:46 +010014242/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010014243#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020014244
Kailang Yang60db6b52008-08-26 13:13:00 +020014245static struct hda_verb alc269_quanta_fl1_verbs[] = {
14246 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14247 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14248 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14249 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14250 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14251 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14252 { }
14253};
14254
Tony Vroon64154832008-11-06 15:08:49 +000014255static struct hda_verb alc269_lifebook_verbs[] = {
14256 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14257 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
14258 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14259 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14260 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14261 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14262 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14263 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14264 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14265 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14266 { }
14267};
14268
Kailang Yang60db6b52008-08-26 13:13:00 +020014269/* toggle speaker-output according to the hp-jack state */
14270static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
14271{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014272 alc_hp_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014273
14274 snd_hda_codec_write(codec, 0x20, 0,
14275 AC_VERB_SET_COEF_INDEX, 0x0c);
14276 snd_hda_codec_write(codec, 0x20, 0,
14277 AC_VERB_SET_PROC_COEF, 0x680);
14278
14279 snd_hda_codec_write(codec, 0x20, 0,
14280 AC_VERB_SET_COEF_INDEX, 0x0c);
14281 snd_hda_codec_write(codec, 0x20, 0,
14282 AC_VERB_SET_PROC_COEF, 0x480);
14283}
14284
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014285#define alc269_lifebook_speaker_automute \
14286 alc269_quanta_fl1_speaker_automute
Tony Vroon64154832008-11-06 15:08:49 +000014287
Tony Vroon64154832008-11-06 15:08:49 +000014288static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
14289{
14290 unsigned int present_laptop;
14291 unsigned int present_dock;
14292
Wu Fengguang864f92b2009-11-18 12:38:02 +080014293 present_laptop = snd_hda_jack_detect(codec, 0x18);
14294 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000014295
14296 /* Laptop mic port overrides dock mic port, design decision */
14297 if (present_dock)
14298 snd_hda_codec_write(codec, 0x23, 0,
14299 AC_VERB_SET_CONNECT_SEL, 0x3);
14300 if (present_laptop)
14301 snd_hda_codec_write(codec, 0x23, 0,
14302 AC_VERB_SET_CONNECT_SEL, 0x0);
14303 if (!present_dock && !present_laptop)
14304 snd_hda_codec_write(codec, 0x23, 0,
14305 AC_VERB_SET_CONNECT_SEL, 0x1);
14306}
14307
Kailang Yang60db6b52008-08-26 13:13:00 +020014308static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
14309 unsigned int res)
14310{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014311 switch (res >> 26) {
14312 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014313 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014314 break;
14315 case ALC880_MIC_EVENT:
14316 alc_mic_automute(codec);
14317 break;
14318 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014319}
14320
Tony Vroon64154832008-11-06 15:08:49 +000014321static void alc269_lifebook_unsol_event(struct hda_codec *codec,
14322 unsigned int res)
14323{
14324 if ((res >> 26) == ALC880_HP_EVENT)
14325 alc269_lifebook_speaker_automute(codec);
14326 if ((res >> 26) == ALC880_MIC_EVENT)
14327 alc269_lifebook_mic_autoswitch(codec);
14328}
14329
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014330static void alc269_quanta_fl1_setup(struct hda_codec *codec)
14331{
14332 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014333 spec->autocfg.hp_pins[0] = 0x15;
14334 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014335 spec->automute_mixer_nid[0] = 0x0c;
14336 spec->automute = 1;
14337 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014338 spec->ext_mic.pin = 0x18;
14339 spec->ext_mic.mux_idx = 0;
14340 spec->int_mic.pin = 0x19;
14341 spec->int_mic.mux_idx = 1;
14342 spec->auto_mic = 1;
14343}
14344
Kailang Yang60db6b52008-08-26 13:13:00 +020014345static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
14346{
14347 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014348 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014349}
14350
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014351static void alc269_lifebook_setup(struct hda_codec *codec)
14352{
14353 struct alc_spec *spec = codec->spec;
14354 spec->autocfg.hp_pins[0] = 0x15;
14355 spec->autocfg.hp_pins[1] = 0x1a;
14356 spec->autocfg.speaker_pins[0] = 0x14;
14357 spec->automute_mixer_nid[0] = 0x0c;
14358 spec->automute = 1;
14359 spec->automute_mode = ALC_AUTOMUTE_MIXER;
14360}
14361
Tony Vroon64154832008-11-06 15:08:49 +000014362static void alc269_lifebook_init_hook(struct hda_codec *codec)
14363{
14364 alc269_lifebook_speaker_automute(codec);
14365 alc269_lifebook_mic_autoswitch(codec);
14366}
14367
Kailang Yang84898e82010-02-04 14:16:14 +010014368static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014369 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14370 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14371 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14372 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14373 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14374 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14375 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14376 {}
14377};
14378
Kailang Yang84898e82010-02-04 14:16:14 +010014379static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014380 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14381 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14382 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14383 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
14384 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14385 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14386 {}
14387};
14388
Kailang Yang84898e82010-02-04 14:16:14 +010014389static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
14390 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14391 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14392 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14393 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14394 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14395 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14396 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14397 {}
14398};
14399
14400static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
14401 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14402 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14403 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14404 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14405 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14406 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14407 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14408 {}
14409};
14410
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014411static struct hda_verb alc271_acer_dmic_verbs[] = {
14412 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14413 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14414 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14415 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14416 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14417 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14418 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14419 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14420 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14421 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14422 { }
14423};
14424
Kailang Yang226b1ec2010-04-09 11:01:20 +020014425static void alc269_laptop_amic_setup(struct hda_codec *codec)
14426{
14427 struct alc_spec *spec = codec->spec;
14428 spec->autocfg.hp_pins[0] = 0x15;
14429 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014430 spec->automute_mixer_nid[0] = 0x0c;
14431 spec->automute = 1;
14432 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014433 spec->ext_mic.pin = 0x18;
14434 spec->ext_mic.mux_idx = 0;
14435 spec->int_mic.pin = 0x19;
14436 spec->int_mic.mux_idx = 1;
14437 spec->auto_mic = 1;
14438}
14439
Kailang Yang84898e82010-02-04 14:16:14 +010014440static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014441{
14442 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014443 spec->autocfg.hp_pins[0] = 0x15;
14444 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014445 spec->automute_mixer_nid[0] = 0x0c;
14446 spec->automute = 1;
14447 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014448 spec->ext_mic.pin = 0x18;
14449 spec->ext_mic.mux_idx = 0;
14450 spec->int_mic.pin = 0x12;
14451 spec->int_mic.mux_idx = 5;
14452 spec->auto_mic = 1;
14453}
14454
Kailang Yang226b1ec2010-04-09 11:01:20 +020014455static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014456{
14457 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014458 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014459 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014460 spec->automute_mixer_nid[0] = 0x0c;
14461 spec->automute = 1;
14462 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014463 spec->ext_mic.pin = 0x18;
14464 spec->ext_mic.mux_idx = 0;
14465 spec->int_mic.pin = 0x19;
14466 spec->int_mic.mux_idx = 1;
14467 spec->auto_mic = 1;
14468}
14469
Kailang Yang226b1ec2010-04-09 11:01:20 +020014470static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14471{
14472 struct alc_spec *spec = codec->spec;
14473 spec->autocfg.hp_pins[0] = 0x21;
14474 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014475 spec->automute_mixer_nid[0] = 0x0c;
14476 spec->automute = 1;
14477 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014478 spec->ext_mic.pin = 0x18;
14479 spec->ext_mic.mux_idx = 0;
14480 spec->int_mic.pin = 0x12;
14481 spec->int_mic.mux_idx = 6;
14482 spec->auto_mic = 1;
14483}
14484
Kailang Yangf6a92242007-12-13 16:52:54 +010014485/*
14486 * generic initialization of ADC, input mixers and output mixers
14487 */
14488static struct hda_verb alc269_init_verbs[] = {
14489 /*
14490 * Unmute ADC0 and set the default input to mic-in
14491 */
Kailang Yang84898e82010-02-04 14:16:14 +010014492 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014493
14494 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014495 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014496 */
14497 /* set vol=0 to output mixers */
14498 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14499 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14500
14501 /* set up input amps for analog loopback */
14502 /* Amp Indices: DAC = 0, mixer = 1 */
14503 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14504 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14505 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14506 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14507 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14508 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14509
14510 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14511 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14512 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14513 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14514 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14515 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14516 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14517
14518 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14519 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014520
Kailang Yang84898e82010-02-04 14:16:14 +010014521 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014522 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14523 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014524 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014525
14526 /* set EAPD */
14527 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014528 { }
14529};
14530
14531static struct hda_verb alc269vb_init_verbs[] = {
14532 /*
14533 * Unmute ADC0 and set the default input to mic-in
14534 */
14535 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14536
14537 /*
14538 * Set up output mixers (0x02 - 0x03)
14539 */
14540 /* set vol=0 to output mixers */
14541 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14542 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14543
14544 /* set up input amps for analog loopback */
14545 /* Amp Indices: DAC = 0, mixer = 1 */
14546 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14547 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14548 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14549 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14550 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14551 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14552
14553 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14554 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14555 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14556 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14557 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14558 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14559 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14560
14561 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14562 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14563
14564 /* FIXME: use Mux-type input source selection */
14565 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14566 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14567 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14568
14569 /* set EAPD */
14570 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014571 { }
14572};
14573
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014574#define alc269_auto_create_multi_out_ctls \
14575 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014576#define alc269_auto_create_input_ctls \
14577 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014578
14579#ifdef CONFIG_SND_HDA_POWER_SAVE
14580#define alc269_loopbacks alc880_loopbacks
14581#endif
14582
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014583/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014584#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14585#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14586#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14587#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14588
Takashi Iwaif03d3112009-03-05 14:18:16 +010014589static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14590 .substreams = 1,
14591 .channels_min = 2,
14592 .channels_max = 8,
14593 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14594 /* NID is set in alc_build_pcms */
14595 .ops = {
14596 .open = alc880_playback_pcm_open,
14597 .prepare = alc880_playback_pcm_prepare,
14598 .cleanup = alc880_playback_pcm_cleanup
14599 },
14600};
14601
14602static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14603 .substreams = 1,
14604 .channels_min = 2,
14605 .channels_max = 2,
14606 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14607 /* NID is set in alc_build_pcms */
14608};
14609
Takashi Iwaiad358792010-03-30 18:00:59 +020014610#ifdef CONFIG_SND_HDA_POWER_SAVE
14611static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14612{
14613 switch (codec->subsystem_id) {
14614 case 0x103c1586:
14615 return 1;
14616 }
14617 return 0;
14618}
14619
14620static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14621{
14622 /* update mute-LED according to the speaker mute state */
14623 if (nid == 0x01 || nid == 0x14) {
14624 int pinval;
14625 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14626 HDA_AMP_MUTE)
14627 pinval = 0x24;
14628 else
14629 pinval = 0x20;
14630 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a52010-03-30 18:03:44 +020014631 snd_hda_codec_update_cache(codec, 0x19, 0,
14632 AC_VERB_SET_PIN_WIDGET_CONTROL,
14633 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014634 }
14635 return alc_check_power_status(codec, nid);
14636}
14637#endif /* CONFIG_SND_HDA_POWER_SAVE */
14638
Takashi Iwai840b64c2010-07-13 22:49:01 +020014639static int alc275_setup_dual_adc(struct hda_codec *codec)
14640{
14641 struct alc_spec *spec = codec->spec;
14642
14643 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14644 return 0;
14645 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14646 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14647 if (spec->ext_mic.pin <= 0x12) {
14648 spec->private_adc_nids[0] = 0x08;
14649 spec->private_adc_nids[1] = 0x11;
14650 spec->private_capsrc_nids[0] = 0x23;
14651 spec->private_capsrc_nids[1] = 0x22;
14652 } else {
14653 spec->private_adc_nids[0] = 0x11;
14654 spec->private_adc_nids[1] = 0x08;
14655 spec->private_capsrc_nids[0] = 0x22;
14656 spec->private_capsrc_nids[1] = 0x23;
14657 }
14658 spec->adc_nids = spec->private_adc_nids;
14659 spec->capsrc_nids = spec->private_capsrc_nids;
14660 spec->num_adc_nids = 2;
14661 spec->dual_adc_switch = 1;
14662 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14663 spec->adc_nids[0], spec->adc_nids[1]);
14664 return 1;
14665 }
14666 return 0;
14667}
14668
Takashi Iwaid433a672010-09-20 15:11:54 +020014669/* different alc269-variants */
14670enum {
14671 ALC269_TYPE_NORMAL,
Kailang Yang48c88e82010-11-23 08:56:16 +010014672 ALC269_TYPE_ALC258,
Takashi Iwaid433a672010-09-20 15:11:54 +020014673 ALC269_TYPE_ALC259,
Kailang Yang48c88e82010-11-23 08:56:16 +010014674 ALC269_TYPE_ALC269VB,
14675 ALC269_TYPE_ALC270,
Takashi Iwaid433a672010-09-20 15:11:54 +020014676 ALC269_TYPE_ALC271X,
14677};
14678
Kailang Yangf6a92242007-12-13 16:52:54 +010014679/*
14680 * BIOS auto configuration
14681 */
14682static int alc269_parse_auto_config(struct hda_codec *codec)
14683{
14684 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014685 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014686 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14687
14688 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14689 alc269_ignore);
14690 if (err < 0)
14691 return err;
14692
14693 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14694 if (err < 0)
14695 return err;
Takashi Iwaif3550d12010-09-20 15:09:03 +020014696 if (spec->codec_variant == ALC269_TYPE_NORMAL)
14697 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
14698 else
14699 err = alc_auto_create_input_ctls(codec, &spec->autocfg, 0,
14700 0x22, 0);
Kailang Yangf6a92242007-12-13 16:52:54 +010014701 if (err < 0)
14702 return err;
14703
14704 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14705
Takashi Iwai757899a2010-07-30 10:48:14 +020014706 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014707
Takashi Iwai603c4012008-07-30 15:01:44 +020014708 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014709 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014710
Takashi Iwaid433a672010-09-20 15:11:54 +020014711 if (spec->codec_variant != ALC269_TYPE_NORMAL) {
Kailang Yang84898e82010-02-04 14:16:14 +010014712 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014713 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014714 } else {
14715 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014716 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014717 }
14718
Kailang Yangf6a92242007-12-13 16:52:54 +010014719 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014720 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014721
14722 if (!alc275_setup_dual_adc(codec))
14723 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14724 sizeof(alc269_adc_candidates));
Takashi Iwai66946352010-03-29 17:21:45 +020014725
Kailang Yangf6a92242007-12-13 16:52:54 +010014726 err = alc_auto_add_mic_boost(codec);
14727 if (err < 0)
14728 return err;
14729
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014730 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014731 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014732
Kailang Yangf6a92242007-12-13 16:52:54 +010014733 return 1;
14734}
14735
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014736#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14737#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014738#define alc269_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaiae0ebbf2011-03-10 14:11:59 +010014739#define alc269_auto_init_input_src alc882_auto_init_input_src
Kailang Yangf6a92242007-12-13 16:52:54 +010014740
14741
14742/* init callback for auto-configuration model -- overriding the default init */
14743static void alc269_auto_init(struct hda_codec *codec)
14744{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014745 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014746 alc269_auto_init_multi_out(codec);
14747 alc269_auto_init_hp_out(codec);
14748 alc269_auto_init_analog_input(codec);
Takashi Iwaiae0ebbf2011-03-10 14:11:59 +010014749 if (!spec->dual_adc_switch)
14750 alc269_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014751 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014752 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014753 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014754}
14755
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014756static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
14757{
14758 int val = alc_read_coef_idx(codec, 0x04);
14759 if (power_up)
14760 val |= 1 << 11;
14761 else
14762 val &= ~(1 << 11);
14763 alc_write_coef_idx(codec, 0x04, val);
14764}
14765
Takashi Iwai5402e4c2011-04-07 10:39:25 +020014766static void alc269_shutup(struct hda_codec *codec)
Kailang Yang977ddd62010-09-15 10:02:29 +020014767{
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014768 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017)
14769 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014770 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014771 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014772 msleep(150);
14773 }
Kailang Yang977ddd62010-09-15 10:02:29 +020014774}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014775
Takashi Iwai5402e4c2011-04-07 10:39:25 +020014776#ifdef SND_HDA_NEEDS_RESUME
Kailang Yang977ddd62010-09-15 10:02:29 +020014777static int alc269_resume(struct hda_codec *codec)
14778{
Kailang Yang977ddd62010-09-15 10:02:29 +020014779 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014780 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014781 msleep(150);
14782 }
14783
14784 codec->patch_ops.init(codec);
14785
14786 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014787 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014788 msleep(200);
14789 }
14790
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014791 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018)
14792 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014793
14794 snd_hda_codec_resume_amp(codec);
14795 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +020014796 hda_call_check_power_status(codec, 0x01);
Kailang Yang977ddd62010-09-15 10:02:29 +020014797 return 0;
14798}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014799#endif /* SND_HDA_NEEDS_RESUME */
Kailang Yang977ddd62010-09-15 10:02:29 +020014800
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014801static void alc269_fixup_hweq(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014802 const struct alc_fixup *fix, int action)
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014803{
14804 int coef;
14805
Takashi Iwai58701122011-01-13 15:41:45 +010014806 if (action != ALC_FIXUP_ACT_INIT)
Takashi Iwai9fb1ef22011-01-13 14:40:43 +010014807 return;
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014808 coef = alc_read_coef_idx(codec, 0x1e);
14809 alc_write_coef_idx(codec, 0x1e, coef | 0x80);
14810}
14811
Takashi Iwai6981d182011-04-15 10:11:12 +020014812static void alc271_fixup_dmic(struct hda_codec *codec,
14813 const struct alc_fixup *fix, int action)
14814{
14815 static struct hda_verb verbs[] = {
14816 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14817 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14818 {}
14819 };
14820 unsigned int cfg;
14821
14822 if (strcmp(codec->chip_name, "ALC271X"))
14823 return;
14824 cfg = snd_hda_codec_get_pincfg(codec, 0x12);
14825 if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
14826 snd_hda_sequence_write(codec, verbs);
14827}
14828
Takashi Iwaiff818c22010-04-12 08:59:25 +020014829enum {
14830 ALC269_FIXUP_SONY_VAIO,
Takashi Iwai74dc8902011-01-13 14:14:41 +010014831 ALC275_FIXUP_SONY_VAIO_GPIO2,
David Henningsson145a9022010-09-16 10:07:53 +020014832 ALC269_FIXUP_DELL_M101Z,
David Henningsson022c92b2010-12-17 20:43:04 +010014833 ALC269_FIXUP_SKU_IGNORE,
David Henningssonac612402010-12-15 09:18:18 +010014834 ALC269_FIXUP_ASUS_G73JW,
Kailang Yang357f9152011-01-12 08:12:52 +010014835 ALC269_FIXUP_LENOVO_EAPD,
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014836 ALC275_FIXUP_SONY_HWEQ,
Takashi Iwai6981d182011-04-15 10:11:12 +020014837 ALC271_FIXUP_DMIC,
Takashi Iwaiff818c22010-04-12 08:59:25 +020014838};
14839
Takashi Iwaiff818c22010-04-12 08:59:25 +020014840static const struct alc_fixup alc269_fixups[] = {
14841 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014842 .type = ALC_FIXUP_VERBS,
14843 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020014844 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14845 {}
14846 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014847 },
Takashi Iwai74dc8902011-01-13 14:14:41 +010014848 [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014849 .type = ALC_FIXUP_VERBS,
14850 .v.verbs = (const struct hda_verb[]) {
Kailang Yang27855912010-12-21 09:09:53 +010014851 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
14852 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
14853 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
14854 { }
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014855 },
14856 .chained = true,
14857 .chain_id = ALC269_FIXUP_SONY_VAIO
Kailang Yang27855912010-12-21 09:09:53 +010014858 },
David Henningsson145a9022010-09-16 10:07:53 +020014859 [ALC269_FIXUP_DELL_M101Z] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014860 .type = ALC_FIXUP_VERBS,
14861 .v.verbs = (const struct hda_verb[]) {
David Henningsson145a9022010-09-16 10:07:53 +020014862 /* Enables internal speaker */
14863 {0x20, AC_VERB_SET_COEF_INDEX, 13},
14864 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
14865 {}
14866 }
14867 },
David Henningsson022c92b2010-12-17 20:43:04 +010014868 [ALC269_FIXUP_SKU_IGNORE] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014869 .type = ALC_FIXUP_SKU,
14870 .v.sku = ALC_FIXUP_SKU_IGNORE,
David Henningssonfe67b242010-12-15 08:01:46 +010014871 },
David Henningssonac612402010-12-15 09:18:18 +010014872 [ALC269_FIXUP_ASUS_G73JW] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014873 .type = ALC_FIXUP_PINS,
14874 .v.pins = (const struct alc_pincfg[]) {
David Henningssonac612402010-12-15 09:18:18 +010014875 { 0x17, 0x99130111 }, /* subwoofer */
14876 { }
14877 }
14878 },
Kailang Yang357f9152011-01-12 08:12:52 +010014879 [ALC269_FIXUP_LENOVO_EAPD] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014880 .type = ALC_FIXUP_VERBS,
14881 .v.verbs = (const struct hda_verb[]) {
Kailang Yang357f9152011-01-12 08:12:52 +010014882 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
14883 {}
14884 }
14885 },
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014886 [ALC275_FIXUP_SONY_HWEQ] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014887 .type = ALC_FIXUP_FUNC,
14888 .v.func = alc269_fixup_hweq,
14889 .chained = true,
14890 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
Takashi Iwai6981d182011-04-15 10:11:12 +020014891 },
14892 [ALC271_FIXUP_DMIC] = {
14893 .type = ALC_FIXUP_FUNC,
14894 .v.func = alc271_fixup_dmic,
14895 },
Takashi Iwaiff818c22010-04-12 08:59:25 +020014896};
14897
14898static struct snd_pci_quirk alc269_fixup_tbl[] = {
Takashi Iwai74dc8902011-01-13 14:14:41 +010014899 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014900 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
14901 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
Takashi Iwai7039c742010-12-23 16:35:34 +010014902 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningsson145a9022010-09-16 10:07:53 +020014903 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
Takashi Iwai6981d182011-04-15 10:11:12 +020014904 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
David Henningsson022c92b2010-12-17 20:43:04 +010014905 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
David Henningssonded9f522011-01-26 11:46:12 +010014906 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
14907 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
14908 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
14909 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
David Henningssonac612402010-12-15 09:18:18 +010014910 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
Kailang Yang357f9152011-01-12 08:12:52 +010014911 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014912 {}
14913};
14914
14915
Kailang Yangf6a92242007-12-13 16:52:54 +010014916/*
14917 * configuration and preset
14918 */
Takashi Iwaiea734962011-01-17 11:29:34 +010014919static const char * const alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014920 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014921 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014922 [ALC269_AMIC] = "laptop-amic",
14923 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014924 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014925 [ALC269_LIFEBOOK] = "lifebook",
14926 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014927};
14928
14929static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014930 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014931 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020014932 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014933 ALC269_AMIC),
14934 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14935 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14936 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14937 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14938 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14939 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14940 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14941 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14942 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
Chih-Wei Huangc790ad32011-02-25 11:14:31 +080014943 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269VB_AMIC),
Kailang Yang84898e82010-02-04 14:16:14 +010014944 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14945 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14946 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14947 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14948 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14949 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14950 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14951 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14952 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14953 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14954 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14955 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14956 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14957 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14958 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14959 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14960 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14961 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14962 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14963 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14964 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14965 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14966 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14967 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14968 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14969 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014970 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014971 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014972 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014973 ALC269_DMIC),
14974 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14975 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014976 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000014977 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014978 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14979 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14980 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14981 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14982 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14983 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014984 {}
14985};
14986
14987static struct alc_config_preset alc269_presets[] = {
14988 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014989 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010014990 .init_verbs = { alc269_init_verbs },
14991 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14992 .dac_nids = alc269_dac_nids,
14993 .hp_nid = 0x03,
14994 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14995 .channel_mode = alc269_modes,
14996 .input_mux = &alc269_capture_source,
14997 },
Kailang Yang60db6b52008-08-26 13:13:00 +020014998 [ALC269_QUANTA_FL1] = {
14999 .mixers = { alc269_quanta_fl1_mixer },
15000 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
15001 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15002 .dac_nids = alc269_dac_nids,
15003 .hp_nid = 0x03,
15004 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15005 .channel_mode = alc269_modes,
15006 .input_mux = &alc269_capture_source,
15007 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015008 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020015009 .init_hook = alc269_quanta_fl1_init_hook,
15010 },
Kailang Yang84898e82010-02-04 14:16:14 +010015011 [ALC269_AMIC] = {
15012 .mixers = { alc269_laptop_mixer },
15013 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020015014 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015015 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020015016 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15017 .dac_nids = alc269_dac_nids,
15018 .hp_nid = 0x03,
15019 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15020 .channel_mode = alc269_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015021 .unsol_event = alc_sku_unsol_event,
Kailang Yang84898e82010-02-04 14:16:14 +010015022 .setup = alc269_laptop_amic_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015023 .init_hook = alc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020015024 },
Kailang Yang84898e82010-02-04 14:16:14 +010015025 [ALC269_DMIC] = {
15026 .mixers = { alc269_laptop_mixer },
15027 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020015028 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015029 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020015030 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15031 .dac_nids = alc269_dac_nids,
15032 .hp_nid = 0x03,
15033 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15034 .channel_mode = alc269_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015035 .unsol_event = alc_sku_unsol_event,
Kailang Yang84898e82010-02-04 14:16:14 +010015036 .setup = alc269_laptop_dmic_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015037 .init_hook = alc_inithook,
Kailang Yang84898e82010-02-04 14:16:14 +010015038 },
15039 [ALC269VB_AMIC] = {
15040 .mixers = { alc269vb_laptop_mixer },
15041 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
15042 .init_verbs = { alc269vb_init_verbs,
15043 alc269vb_laptop_amic_init_verbs },
15044 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15045 .dac_nids = alc269_dac_nids,
15046 .hp_nid = 0x03,
15047 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15048 .channel_mode = alc269_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015049 .unsol_event = alc_sku_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020015050 .setup = alc269vb_laptop_amic_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015051 .init_hook = alc_inithook,
Kailang Yang84898e82010-02-04 14:16:14 +010015052 },
15053 [ALC269VB_DMIC] = {
15054 .mixers = { alc269vb_laptop_mixer },
15055 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
15056 .init_verbs = { alc269vb_init_verbs,
15057 alc269vb_laptop_dmic_init_verbs },
15058 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15059 .dac_nids = alc269_dac_nids,
15060 .hp_nid = 0x03,
15061 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15062 .channel_mode = alc269_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015063 .unsol_event = alc_sku_unsol_event,
Kailang Yang84898e82010-02-04 14:16:14 +010015064 .setup = alc269vb_laptop_dmic_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015065 .init_hook = alc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020015066 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010015067 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015068 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010015069 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010015070 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015071 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010015072 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15073 .dac_nids = alc269_dac_nids,
15074 .hp_nid = 0x03,
15075 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15076 .channel_mode = alc269_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015077 .unsol_event = alc_sku_unsol_event,
Kailang Yang84898e82010-02-04 14:16:14 +010015078 .setup = alc269_laptop_dmic_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015079 .init_hook = alc_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010015080 },
Tony Vroon64154832008-11-06 15:08:49 +000015081 [ALC269_LIFEBOOK] = {
15082 .mixers = { alc269_lifebook_mixer },
15083 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
15084 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15085 .dac_nids = alc269_dac_nids,
15086 .hp_nid = 0x03,
15087 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15088 .channel_mode = alc269_modes,
15089 .input_mux = &alc269_capture_source,
15090 .unsol_event = alc269_lifebook_unsol_event,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015091 .setup = alc269_lifebook_setup,
Tony Vroon64154832008-11-06 15:08:49 +000015092 .init_hook = alc269_lifebook_init_hook,
15093 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020015094 [ALC271_ACER] = {
15095 .mixers = { alc269_asus_mixer },
15096 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
15097 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
15098 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15099 .dac_nids = alc269_dac_nids,
15100 .adc_nids = alc262_dmic_adc_nids,
15101 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
15102 .capsrc_nids = alc262_dmic_capsrc_nids,
15103 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15104 .channel_mode = alc269_modes,
15105 .input_mux = &alc269_capture_source,
15106 .dig_out_nid = ALC880_DIGOUT_NID,
15107 .unsol_event = alc_sku_unsol_event,
15108 .setup = alc269vb_laptop_dmic_setup,
15109 .init_hook = alc_inithook,
15110 },
Kailang Yangf6a92242007-12-13 16:52:54 +010015111};
15112
Kailang Yang977ddd62010-09-15 10:02:29 +020015113static int alc269_fill_coef(struct hda_codec *codec)
15114{
15115 int val;
15116
15117 if ((alc_read_coef_idx(codec, 0) & 0x00ff) < 0x015) {
15118 alc_write_coef_idx(codec, 0xf, 0x960b);
15119 alc_write_coef_idx(codec, 0xe, 0x8817);
15120 }
15121
15122 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x016) {
15123 alc_write_coef_idx(codec, 0xf, 0x960b);
15124 alc_write_coef_idx(codec, 0xe, 0x8814);
15125 }
15126
15127 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
15128 val = alc_read_coef_idx(codec, 0x04);
15129 /* Power up output pin */
15130 alc_write_coef_idx(codec, 0x04, val | (1<<11));
15131 }
15132
15133 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
15134 val = alc_read_coef_idx(codec, 0xd);
15135 if ((val & 0x0c00) >> 10 != 0x1) {
15136 /* Capless ramp up clock control */
15137 alc_write_coef_idx(codec, 0xd, val | 1<<10);
15138 }
15139 val = alc_read_coef_idx(codec, 0x17);
15140 if ((val & 0x01c0) >> 6 != 0x4) {
15141 /* Class D power on reset */
15142 alc_write_coef_idx(codec, 0x17, val | 1<<7);
15143 }
15144 }
15145 return 0;
15146}
15147
Kailang Yangf6a92242007-12-13 16:52:54 +010015148static int patch_alc269(struct hda_codec *codec)
15149{
15150 struct alc_spec *spec;
Kailang Yang48c88e82010-11-23 08:56:16 +010015151 int board_config, coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010015152 int err;
15153
15154 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15155 if (spec == NULL)
15156 return -ENOMEM;
15157
15158 codec->spec = spec;
15159
Kailang Yangda00c242010-03-19 11:23:45 +010015160 alc_auto_parse_customize_define(codec);
15161
Kailang Yangc793bec2010-12-21 09:14:13 +010015162 if (codec->vendor_id == 0x10ec0269) {
15163 coef = alc_read_coef_idx(codec, 0);
15164 if ((coef & 0x00f0) == 0x0010) {
15165 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
15166 spec->cdefine.platform_type == 1) {
15167 alc_codec_rename(codec, "ALC271X");
15168 spec->codec_variant = ALC269_TYPE_ALC271X;
15169 } else if ((coef & 0xf000) == 0x1000) {
15170 spec->codec_variant = ALC269_TYPE_ALC270;
15171 } else if ((coef & 0xf000) == 0x2000) {
15172 alc_codec_rename(codec, "ALC259");
15173 spec->codec_variant = ALC269_TYPE_ALC259;
15174 } else if ((coef & 0xf000) == 0x3000) {
15175 alc_codec_rename(codec, "ALC258");
15176 spec->codec_variant = ALC269_TYPE_ALC258;
15177 } else {
15178 alc_codec_rename(codec, "ALC269VB");
15179 spec->codec_variant = ALC269_TYPE_ALC269VB;
15180 }
15181 } else
15182 alc_fix_pll_init(codec, 0x20, 0x04, 15);
15183 alc269_fill_coef(codec);
15184 }
Kailang Yang977ddd62010-09-15 10:02:29 +020015185
Kailang Yangf6a92242007-12-13 16:52:54 +010015186 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
15187 alc269_models,
15188 alc269_cfg_tbl);
15189
15190 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015191 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15192 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010015193 board_config = ALC269_AUTO;
15194 }
15195
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010015196 if (board_config == ALC269_AUTO) {
15197 alc_pick_fixup(codec, NULL, alc269_fixup_tbl, alc269_fixups);
15198 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
15199 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020015200
Kailang Yangf6a92242007-12-13 16:52:54 +010015201 if (board_config == ALC269_AUTO) {
15202 /* automatic parse from the BIOS config */
15203 err = alc269_parse_auto_config(codec);
15204 if (err < 0) {
15205 alc_free(codec);
15206 return err;
15207 } else if (!err) {
15208 printk(KERN_INFO
15209 "hda_codec: Cannot set up configuration "
15210 "from BIOS. Using base mode...\n");
15211 board_config = ALC269_BASIC;
15212 }
15213 }
15214
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015215 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020015216 err = snd_hda_attach_beep_device(codec, 0x1);
15217 if (err < 0) {
15218 alc_free(codec);
15219 return err;
15220 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015221 }
15222
Kailang Yangf6a92242007-12-13 16:52:54 +010015223 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015224 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010015225
Kailang Yang84898e82010-02-04 14:16:14 +010015226 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010015227 /* Due to a hardware problem on Lenovo Ideadpad, we need to
15228 * fix the sample rate of analog I/O to 44.1kHz
15229 */
15230 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
15231 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020015232 } else if (spec->dual_adc_switch) {
15233 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15234 /* switch ADC dynamically */
15235 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010015236 } else {
15237 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15238 spec->stream_analog_capture = &alc269_pcm_analog_capture;
15239 }
Kailang Yangf6a92242007-12-13 16:52:54 +010015240 spec->stream_digital_playback = &alc269_pcm_digital_playback;
15241 spec->stream_digital_capture = &alc269_pcm_digital_capture;
15242
Takashi Iwai66946352010-03-29 17:21:45 +020015243 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
Kailang Yang1657cbd2010-11-23 08:53:32 +010015244 if (spec->codec_variant == ALC269_TYPE_NORMAL) {
Takashi Iwai66946352010-03-29 17:21:45 +020015245 spec->adc_nids = alc269_adc_nids;
15246 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
15247 spec->capsrc_nids = alc269_capsrc_nids;
15248 } else {
15249 spec->adc_nids = alc269vb_adc_nids;
15250 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
15251 spec->capsrc_nids = alc269vb_capsrc_nids;
15252 }
Kailang Yang84898e82010-02-04 14:16:14 +010015253 }
15254
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015255 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015256 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015257 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010015258 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010015259
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010015260 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwaiff818c22010-04-12 08:59:25 +020015261
Takashi Iwai100d5eb2009-08-10 11:55:51 +020015262 spec->vmaster_nid = 0x02;
15263
Kailang Yangf6a92242007-12-13 16:52:54 +010015264 codec->patch_ops = alc_patch_ops;
Kailang Yang977ddd62010-09-15 10:02:29 +020015265#ifdef SND_HDA_NEEDS_RESUME
15266 codec->patch_ops.resume = alc269_resume;
15267#endif
Kailang Yangf6a92242007-12-13 16:52:54 +010015268 if (board_config == ALC269_AUTO)
15269 spec->init_hook = alc269_auto_init;
Takashi Iwai5402e4c2011-04-07 10:39:25 +020015270 spec->shutup = alc269_shutup;
Kailang Yangbf1b0222010-10-21 08:49:56 +020015271
15272 alc_init_jacks(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010015273#ifdef CONFIG_SND_HDA_POWER_SAVE
15274 if (!spec->loopback.amplist)
15275 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020015276 if (alc269_mic2_for_mute_led(codec))
15277 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010015278#endif
15279
15280 return 0;
15281}
15282
15283/*
Kailang Yangdf694da2005-12-05 19:42:22 +010015284 * ALC861 channel source setting (2/6 channel selection for 3-stack)
15285 */
15286
15287/*
15288 * set the path ways for 2 channel output
15289 * need to set the codec line out and mic 1 pin widgets to inputs
15290 */
15291static struct hda_verb alc861_threestack_ch2_init[] = {
15292 /* set pin widget 1Ah (line in) for input */
15293 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015294 /* set pin widget 18h (mic1/2) for input, for mic also enable
15295 * the vref
15296 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015297 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15298
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015299 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15300#if 0
15301 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15302 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15303#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015304 { } /* end */
15305};
15306/*
15307 * 6ch mode
15308 * need to set the codec line out and mic 1 pin widgets to outputs
15309 */
15310static struct hda_verb alc861_threestack_ch6_init[] = {
15311 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15312 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15313 /* set pin widget 18h (mic1) for output (CLFE)*/
15314 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15315
15316 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015317 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015318
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015319 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15320#if 0
15321 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15322 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15323#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015324 { } /* end */
15325};
15326
15327static struct hda_channel_mode alc861_threestack_modes[2] = {
15328 { 2, alc861_threestack_ch2_init },
15329 { 6, alc861_threestack_ch6_init },
15330};
Takashi Iwai22309c32006-08-09 16:57:28 +020015331/* Set mic1 as input and unmute the mixer */
15332static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
15333 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15334 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15335 { } /* end */
15336};
15337/* Set mic1 as output and mute mixer */
15338static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
15339 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15340 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15341 { } /* end */
15342};
15343
15344static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
15345 { 2, alc861_uniwill_m31_ch2_init },
15346 { 4, alc861_uniwill_m31_ch4_init },
15347};
Kailang Yangdf694da2005-12-05 19:42:22 +010015348
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015349/* Set mic1 and line-in as input and unmute the mixer */
15350static struct hda_verb alc861_asus_ch2_init[] = {
15351 /* set pin widget 1Ah (line in) for input */
15352 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015353 /* set pin widget 18h (mic1/2) for input, for mic also enable
15354 * the vref
15355 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015356 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15357
15358 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15359#if 0
15360 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15361 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15362#endif
15363 { } /* end */
15364};
15365/* Set mic1 nad line-in as output and mute mixer */
15366static struct hda_verb alc861_asus_ch6_init[] = {
15367 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15368 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15369 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15370 /* set pin widget 18h (mic1) for output (CLFE)*/
15371 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15372 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15373 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
15374 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
15375
15376 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15377#if 0
15378 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15379 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15380#endif
15381 { } /* end */
15382};
15383
15384static struct hda_channel_mode alc861_asus_modes[2] = {
15385 { 2, alc861_asus_ch2_init },
15386 { 6, alc861_asus_ch6_init },
15387};
15388
Kailang Yangdf694da2005-12-05 19:42:22 +010015389/* patch-ALC861 */
15390
15391static struct snd_kcontrol_new alc861_base_mixer[] = {
15392 /* output mixer control */
15393 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15394 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15395 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15396 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15397 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15398
15399 /*Input mixer control */
15400 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15401 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15402 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15403 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15404 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15405 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15406 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15407 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15408 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15409 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015410
Kailang Yangdf694da2005-12-05 19:42:22 +010015411 { } /* end */
15412};
15413
15414static struct snd_kcontrol_new alc861_3ST_mixer[] = {
15415 /* output mixer control */
15416 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15417 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15418 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15419 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15420 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15421
15422 /* Input mixer control */
15423 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15424 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15425 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15426 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15427 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15428 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15429 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15430 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15431 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15432 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015433
Kailang Yangdf694da2005-12-05 19:42:22 +010015434 {
15435 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15436 .name = "Channel Mode",
15437 .info = alc_ch_mode_info,
15438 .get = alc_ch_mode_get,
15439 .put = alc_ch_mode_put,
15440 .private_value = ARRAY_SIZE(alc861_threestack_modes),
15441 },
15442 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015443};
15444
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015445static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015446 /* output mixer control */
15447 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15448 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15449 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015450
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015451 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015452};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015453
Takashi Iwai22309c32006-08-09 16:57:28 +020015454static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
15455 /* output mixer control */
15456 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15457 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15458 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15459 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15460 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15461
15462 /* Input mixer control */
15463 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15464 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15465 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15466 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15467 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15468 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15469 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15470 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15471 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15472 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015473
Takashi Iwai22309c32006-08-09 16:57:28 +020015474 {
15475 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15476 .name = "Channel Mode",
15477 .info = alc_ch_mode_info,
15478 .get = alc_ch_mode_get,
15479 .put = alc_ch_mode_put,
15480 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
15481 },
15482 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015483};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015484
15485static struct snd_kcontrol_new alc861_asus_mixer[] = {
15486 /* output mixer control */
15487 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15488 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15489 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15490 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15491 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15492
15493 /* Input mixer control */
15494 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15495 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15496 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15497 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15498 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15499 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15500 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15501 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15502 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015503 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
15504
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015505 {
15506 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15507 .name = "Channel Mode",
15508 .info = alc_ch_mode_info,
15509 .get = alc_ch_mode_get,
15510 .put = alc_ch_mode_put,
15511 .private_value = ARRAY_SIZE(alc861_asus_modes),
15512 },
15513 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015514};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015515
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015516/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015517static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015518 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15519 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015520 { }
15521};
15522
Kailang Yangdf694da2005-12-05 19:42:22 +010015523/*
15524 * generic initialization of ADC, input mixers and output mixers
15525 */
15526static struct hda_verb alc861_base_init_verbs[] = {
15527 /*
15528 * Unmute ADC0 and set the default input to mic-in
15529 */
15530 /* port-A for surround (rear panel) */
15531 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15532 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
15533 /* port-B for mic-in (rear panel) with vref */
15534 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15535 /* port-C for line-in (rear panel) */
15536 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15537 /* port-D for Front */
15538 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15539 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15540 /* port-E for HP out (front panel) */
15541 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15542 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015543 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015544 /* port-F for mic-in (front panel) with vref */
15545 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15546 /* port-G for CLFE (rear panel) */
15547 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15548 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15549 /* port-H for side (rear panel) */
15550 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15551 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15552 /* CD-in */
15553 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15554 /* route front mic to ADC1*/
15555 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15556 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015557
Kailang Yangdf694da2005-12-05 19:42:22 +010015558 /* Unmute DAC0~3 & spdif out*/
15559 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15560 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15561 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15562 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15563 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015564
Kailang Yangdf694da2005-12-05 19:42:22 +010015565 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15566 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15567 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15568 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15569 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015570
Kailang Yangdf694da2005-12-05 19:42:22 +010015571 /* Unmute Stereo Mixer 15 */
15572 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15573 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15574 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015575 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015576
15577 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15578 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15579 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15580 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15581 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15582 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15583 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15584 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015585 /* hp used DAC 3 (Front) */
15586 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015587 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15588
15589 { }
15590};
15591
15592static struct hda_verb alc861_threestack_init_verbs[] = {
15593 /*
15594 * Unmute ADC0 and set the default input to mic-in
15595 */
15596 /* port-A for surround (rear panel) */
15597 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15598 /* port-B for mic-in (rear panel) with vref */
15599 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15600 /* port-C for line-in (rear panel) */
15601 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15602 /* port-D for Front */
15603 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15604 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15605 /* port-E for HP out (front panel) */
15606 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15607 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015608 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015609 /* port-F for mic-in (front panel) with vref */
15610 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15611 /* port-G for CLFE (rear panel) */
15612 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15613 /* port-H for side (rear panel) */
15614 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15615 /* CD-in */
15616 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15617 /* route front mic to ADC1*/
15618 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15619 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15620 /* Unmute DAC0~3 & spdif out*/
15621 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15622 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15623 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15624 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15625 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015626
Kailang Yangdf694da2005-12-05 19:42:22 +010015627 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15628 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15629 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15630 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15631 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015632
Kailang Yangdf694da2005-12-05 19:42:22 +010015633 /* Unmute Stereo Mixer 15 */
15634 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15635 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15636 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015637 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015638
15639 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15640 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15641 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15642 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15643 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15644 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15645 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15646 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015647 /* hp used DAC 3 (Front) */
15648 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015649 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15650 { }
15651};
Takashi Iwai22309c32006-08-09 16:57:28 +020015652
15653static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
15654 /*
15655 * Unmute ADC0 and set the default input to mic-in
15656 */
15657 /* port-A for surround (rear panel) */
15658 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15659 /* port-B for mic-in (rear panel) with vref */
15660 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15661 /* port-C for line-in (rear panel) */
15662 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15663 /* port-D for Front */
15664 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15665 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15666 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015667 /* this has to be set to VREF80 */
15668 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015669 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015670 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015671 /* port-F for mic-in (front panel) with vref */
15672 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15673 /* port-G for CLFE (rear panel) */
15674 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15675 /* port-H for side (rear panel) */
15676 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15677 /* CD-in */
15678 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15679 /* route front mic to ADC1*/
15680 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15681 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15682 /* Unmute DAC0~3 & spdif out*/
15683 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15684 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15685 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15686 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15687 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015688
Takashi Iwai22309c32006-08-09 16:57:28 +020015689 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15690 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15691 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15692 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15693 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015694
Takashi Iwai22309c32006-08-09 16:57:28 +020015695 /* Unmute Stereo Mixer 15 */
15696 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15697 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15698 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015699 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015700
15701 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15702 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15703 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15704 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15705 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15706 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15707 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15708 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015709 /* hp used DAC 3 (Front) */
15710 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015711 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15712 { }
15713};
15714
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015715static struct hda_verb alc861_asus_init_verbs[] = {
15716 /*
15717 * Unmute ADC0 and set the default input to mic-in
15718 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015719 /* port-A for surround (rear panel)
15720 * according to codec#0 this is the HP jack
15721 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015722 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15723 /* route front PCM to HP */
15724 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15725 /* port-B for mic-in (rear panel) with vref */
15726 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15727 /* port-C for line-in (rear panel) */
15728 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15729 /* port-D for Front */
15730 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15731 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15732 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015733 /* this has to be set to VREF80 */
15734 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015735 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015736 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015737 /* port-F for mic-in (front panel) with vref */
15738 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15739 /* port-G for CLFE (rear panel) */
15740 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15741 /* port-H for side (rear panel) */
15742 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15743 /* CD-in */
15744 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15745 /* route front mic to ADC1*/
15746 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15747 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15748 /* Unmute DAC0~3 & spdif out*/
15749 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15750 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15751 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15752 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15753 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15754 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15755 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15756 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15757 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15758 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015759
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015760 /* Unmute Stereo Mixer 15 */
15761 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15762 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15763 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015764 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015765
15766 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15767 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15768 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15769 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15770 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15771 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15772 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15773 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015774 /* hp used DAC 3 (Front) */
15775 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015776 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15777 { }
15778};
15779
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015780/* additional init verbs for ASUS laptops */
15781static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15782 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15783 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15784 { }
15785};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015786
Kailang Yangdf694da2005-12-05 19:42:22 +010015787/*
15788 * generic initialization of ADC, input mixers and output mixers
15789 */
15790static struct hda_verb alc861_auto_init_verbs[] = {
15791 /*
15792 * Unmute ADC0 and set the default input to mic-in
15793 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015794 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015795 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015796
Kailang Yangdf694da2005-12-05 19:42:22 +010015797 /* Unmute DAC0~3 & spdif out*/
15798 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15799 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15800 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15801 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15802 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015803
Kailang Yangdf694da2005-12-05 19:42:22 +010015804 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15805 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15806 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15807 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15808 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015809
Kailang Yangdf694da2005-12-05 19:42:22 +010015810 /* Unmute Stereo Mixer 15 */
15811 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15812 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15813 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15814 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15815
Takashi Iwai1c209302009-07-22 15:17:45 +020015816 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15817 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15818 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15819 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15820 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15821 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15822 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15823 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015824
15825 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15826 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015827 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15828 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015829 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15830 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015831 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15832 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015833
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015834 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015835
15836 { }
15837};
15838
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015839static struct hda_verb alc861_toshiba_init_verbs[] = {
15840 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015841
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015842 { }
15843};
15844
15845/* toggle speaker-output according to the hp-jack state */
15846static void alc861_toshiba_automute(struct hda_codec *codec)
15847{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015848 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015849
Takashi Iwai47fd8302007-08-10 17:11:07 +020015850 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15851 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15852 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15853 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015854}
15855
15856static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15857 unsigned int res)
15858{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015859 if ((res >> 26) == ALC880_HP_EVENT)
15860 alc861_toshiba_automute(codec);
15861}
15862
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015863/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015864#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15865#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15866#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15867#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15868
15869
15870#define ALC861_DIGOUT_NID 0x07
15871
15872static struct hda_channel_mode alc861_8ch_modes[1] = {
15873 { 8, NULL }
15874};
15875
15876static hda_nid_t alc861_dac_nids[4] = {
15877 /* front, surround, clfe, side */
15878 0x03, 0x06, 0x05, 0x04
15879};
15880
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015881static hda_nid_t alc660_dac_nids[3] = {
15882 /* front, clfe, surround */
15883 0x03, 0x05, 0x06
15884};
15885
Kailang Yangdf694da2005-12-05 19:42:22 +010015886static hda_nid_t alc861_adc_nids[1] = {
15887 /* ADC0-2 */
15888 0x08,
15889};
15890
15891static struct hda_input_mux alc861_capture_source = {
15892 .num_items = 5,
15893 .items = {
15894 { "Mic", 0x0 },
15895 { "Front Mic", 0x3 },
15896 { "Line", 0x1 },
15897 { "CD", 0x4 },
15898 { "Mixer", 0x5 },
15899 },
15900};
15901
Takashi Iwai1c209302009-07-22 15:17:45 +020015902static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15903{
15904 struct alc_spec *spec = codec->spec;
15905 hda_nid_t mix, srcs[5];
15906 int i, j, num;
15907
15908 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15909 return 0;
15910 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15911 if (num < 0)
15912 return 0;
15913 for (i = 0; i < num; i++) {
15914 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015915 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015916 if (type != AC_WID_AUD_OUT)
15917 continue;
15918 for (j = 0; j < spec->multiout.num_dacs; j++)
15919 if (spec->multiout.dac_nids[j] == srcs[i])
15920 break;
15921 if (j >= spec->multiout.num_dacs)
15922 return srcs[i];
15923 }
15924 return 0;
15925}
15926
Kailang Yangdf694da2005-12-05 19:42:22 +010015927/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015928static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015929 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015930{
Takashi Iwai1c209302009-07-22 15:17:45 +020015931 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015932 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015933 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015934
15935 spec->multiout.dac_nids = spec->private_dac_nids;
15936 for (i = 0; i < cfg->line_outs; i++) {
15937 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015938 dac = alc861_look_for_dac(codec, nid);
15939 if (!dac)
15940 continue;
15941 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015942 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015943 return 0;
15944}
15945
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015946static int __alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15947 hda_nid_t nid, int idx, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015948{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015949 return __add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx, idx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015950 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15951}
15952
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015953#define alc861_create_out_sw(codec, pfx, nid, chs) \
15954 __alc861_create_out_sw(codec, pfx, nid, 0, chs)
15955
Takashi Iwai1c209302009-07-22 15:17:45 +020015956/* add playback controls from the parsed DAC table */
15957static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15958 const struct auto_pin_cfg *cfg)
15959{
15960 struct alc_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +010015961 static const char * const chname[4] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015962 "Front", "Surround", NULL /*CLFE*/, "Side"
15963 };
Takashi Iwaice764ab2011-04-27 16:35:23 +020015964 const char *pfx = alc_get_line_out_pfx(spec, true);
Kailang Yangdf694da2005-12-05 19:42:22 +010015965 hda_nid_t nid;
Takashi Iwaice764ab2011-04-27 16:35:23 +020015966 int i, err, noutputs;
Takashi Iwai1c209302009-07-22 15:17:45 +020015967
Takashi Iwaice764ab2011-04-27 16:35:23 +020015968 noutputs = cfg->line_outs;
15969 if (spec->multi_ios > 0)
15970 noutputs += spec->multi_ios;
15971
15972 for (i = 0; i < noutputs; i++) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015973 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015974 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015975 continue;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015976 if (!pfx && i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015977 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015978 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015979 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015980 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015981 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015982 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015983 return err;
15984 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015985 const char *name = pfx;
David Henningsson5a882642011-03-23 08:35:07 +010015986 int index = i;
15987 if (!name) {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015988 name = chname[i];
David Henningsson5a882642011-03-23 08:35:07 +010015989 index = 0;
15990 }
15991 err = __alc861_create_out_sw(codec, name, nid, index, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015992 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015993 return err;
15994 }
15995 }
15996 return 0;
15997}
15998
Takashi Iwai1c209302009-07-22 15:17:45 +020015999static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010016000{
Takashi Iwai1c209302009-07-22 15:17:45 +020016001 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016002 int err;
16003 hda_nid_t nid;
16004
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016005 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010016006 return 0;
16007
16008 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020016009 nid = alc861_look_for_dac(codec, pin);
16010 if (nid) {
16011 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
16012 if (err < 0)
16013 return err;
16014 spec->multiout.hp_nid = nid;
16015 }
Kailang Yangdf694da2005-12-05 19:42:22 +010016016 }
16017 return 0;
16018}
16019
16020/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016021static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016022 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010016023{
Takashi Iwai05f5f472009-08-25 13:10:18 +020016024 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010016025}
16026
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016027static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
16028 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020016029 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010016030{
Takashi Iwai1c209302009-07-22 15:17:45 +020016031 hda_nid_t mix, srcs[5];
16032 int i, num;
16033
Jacek Luczak564c5be2008-05-03 18:41:23 +020016034 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
16035 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020016036 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020016037 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020016038 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
16039 return;
16040 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
16041 if (num < 0)
16042 return;
16043 for (i = 0; i < num; i++) {
16044 unsigned int mute;
16045 if (srcs[i] == dac || srcs[i] == 0x15)
16046 mute = AMP_IN_UNMUTE(i);
16047 else
16048 mute = AMP_IN_MUTE(i);
16049 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16050 mute);
16051 }
Kailang Yangdf694da2005-12-05 19:42:22 +010016052}
16053
16054static void alc861_auto_init_multi_out(struct hda_codec *codec)
16055{
16056 struct alc_spec *spec = codec->spec;
16057 int i;
16058
16059 for (i = 0; i < spec->autocfg.line_outs; i++) {
16060 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016061 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010016062 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016063 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016064 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016065 }
16066}
16067
16068static void alc861_auto_init_hp_out(struct hda_codec *codec)
16069{
16070 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016071
Takashi Iwai15870f02009-10-05 08:25:13 +020016072 if (spec->autocfg.hp_outs)
16073 alc861_auto_set_output_and_unmute(codec,
16074 spec->autocfg.hp_pins[0],
16075 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020016076 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020016077 if (spec->autocfg.speaker_outs)
16078 alc861_auto_set_output_and_unmute(codec,
16079 spec->autocfg.speaker_pins[0],
16080 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020016081 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016082}
16083
16084static void alc861_auto_init_analog_input(struct hda_codec *codec)
16085{
16086 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016087 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +010016088 int i;
16089
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016090 for (i = 0; i < cfg->num_inputs; i++) {
16091 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai23f0c042009-02-26 13:03:58 +010016092 if (nid >= 0x0c && nid <= 0x11)
Takashi Iwai30ea0982010-09-16 18:47:56 +020016093 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Kailang Yangdf694da2005-12-05 19:42:22 +010016094 }
16095}
16096
16097/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016098/* return 1 if successful, 0 if the proper config is not found,
16099 * or a negative error code
16100 */
Kailang Yangdf694da2005-12-05 19:42:22 +010016101static int alc861_parse_auto_config(struct hda_codec *codec)
16102{
16103 struct alc_spec *spec = codec->spec;
16104 int err;
16105 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
16106
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016107 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16108 alc861_ignore);
16109 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016110 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016111 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010016112 return 0; /* can't find valid BIOS pin config */
16113
Takashi Iwai1c209302009-07-22 15:17:45 +020016114 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016115 if (err < 0)
16116 return err;
Takashi Iwaice764ab2011-04-27 16:35:23 +020016117 err = alc_auto_add_multi_channel_mode(codec);
16118 if (err < 0)
16119 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016120 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016121 if (err < 0)
16122 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016123 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016124 if (err < 0)
16125 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016126 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016127 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016128 return err;
16129
16130 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16131
Takashi Iwai757899a2010-07-30 10:48:14 +020016132 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016133
Takashi Iwai603c4012008-07-30 15:01:44 +020016134 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016135 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010016136
Takashi Iwaid88897e2008-10-31 15:01:37 +010016137 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010016138
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020016139 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016140 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010016141
16142 spec->adc_nids = alc861_adc_nids;
16143 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016144 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016145
Kailang Yang6227cdc2010-02-25 08:36:52 +010016146 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016147
Kailang Yangdf694da2005-12-05 19:42:22 +010016148 return 1;
16149}
16150
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016151/* additional initialization for auto-configuration model */
16152static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010016153{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016154 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016155 alc861_auto_init_multi_out(codec);
16156 alc861_auto_init_hp_out(codec);
16157 alc861_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020016158 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016159 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016160 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016161}
16162
Takashi Iwaicb53c622007-08-10 17:21:45 +020016163#ifdef CONFIG_SND_HDA_POWER_SAVE
16164static struct hda_amp_list alc861_loopbacks[] = {
16165 { 0x15, HDA_INPUT, 0 },
16166 { 0x15, HDA_INPUT, 1 },
16167 { 0x15, HDA_INPUT, 2 },
16168 { 0x15, HDA_INPUT, 3 },
16169 { } /* end */
16170};
16171#endif
16172
Kailang Yangdf694da2005-12-05 19:42:22 +010016173
16174/*
16175 * configuration and preset
16176 */
Takashi Iwaiea734962011-01-17 11:29:34 +010016177static const char * const alc861_models[ALC861_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016178 [ALC861_3ST] = "3stack",
16179 [ALC660_3ST] = "3stack-660",
16180 [ALC861_3ST_DIG] = "3stack-dig",
16181 [ALC861_6ST_DIG] = "6stack-dig",
16182 [ALC861_UNIWILL_M31] = "uniwill-m31",
16183 [ALC861_TOSHIBA] = "toshiba",
16184 [ALC861_ASUS] = "asus",
16185 [ALC861_ASUS_LAPTOP] = "asus-laptop",
16186 [ALC861_AUTO] = "auto",
16187};
16188
16189static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010016190 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016191 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16192 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16193 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016194 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020016195 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010016196 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020016197 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
16198 * Any other models that need this preset?
16199 */
16200 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020016201 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
16202 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016203 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
16204 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
16205 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
16206 /* FIXME: the below seems conflict */
16207 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
16208 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
16209 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010016210 {}
16211};
16212
16213static struct alc_config_preset alc861_presets[] = {
16214 [ALC861_3ST] = {
16215 .mixers = { alc861_3ST_mixer },
16216 .init_verbs = { alc861_threestack_init_verbs },
16217 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16218 .dac_nids = alc861_dac_nids,
16219 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16220 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016221 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016222 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16223 .adc_nids = alc861_adc_nids,
16224 .input_mux = &alc861_capture_source,
16225 },
16226 [ALC861_3ST_DIG] = {
16227 .mixers = { alc861_base_mixer },
16228 .init_verbs = { alc861_threestack_init_verbs },
16229 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16230 .dac_nids = alc861_dac_nids,
16231 .dig_out_nid = ALC861_DIGOUT_NID,
16232 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16233 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016234 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016235 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16236 .adc_nids = alc861_adc_nids,
16237 .input_mux = &alc861_capture_source,
16238 },
16239 [ALC861_6ST_DIG] = {
16240 .mixers = { alc861_base_mixer },
16241 .init_verbs = { alc861_base_init_verbs },
16242 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16243 .dac_nids = alc861_dac_nids,
16244 .dig_out_nid = ALC861_DIGOUT_NID,
16245 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
16246 .channel_mode = alc861_8ch_modes,
16247 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16248 .adc_nids = alc861_adc_nids,
16249 .input_mux = &alc861_capture_source,
16250 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016251 [ALC660_3ST] = {
16252 .mixers = { alc861_3ST_mixer },
16253 .init_verbs = { alc861_threestack_init_verbs },
16254 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
16255 .dac_nids = alc660_dac_nids,
16256 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16257 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016258 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016259 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16260 .adc_nids = alc861_adc_nids,
16261 .input_mux = &alc861_capture_source,
16262 },
Takashi Iwai22309c32006-08-09 16:57:28 +020016263 [ALC861_UNIWILL_M31] = {
16264 .mixers = { alc861_uniwill_m31_mixer },
16265 .init_verbs = { alc861_uniwill_m31_init_verbs },
16266 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16267 .dac_nids = alc861_dac_nids,
16268 .dig_out_nid = ALC861_DIGOUT_NID,
16269 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
16270 .channel_mode = alc861_uniwill_m31_modes,
16271 .need_dac_fix = 1,
16272 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16273 .adc_nids = alc861_adc_nids,
16274 .input_mux = &alc861_capture_source,
16275 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016276 [ALC861_TOSHIBA] = {
16277 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016278 .init_verbs = { alc861_base_init_verbs,
16279 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016280 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16281 .dac_nids = alc861_dac_nids,
16282 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16283 .channel_mode = alc883_3ST_2ch_modes,
16284 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16285 .adc_nids = alc861_adc_nids,
16286 .input_mux = &alc861_capture_source,
16287 .unsol_event = alc861_toshiba_unsol_event,
16288 .init_hook = alc861_toshiba_automute,
16289 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020016290 [ALC861_ASUS] = {
16291 .mixers = { alc861_asus_mixer },
16292 .init_verbs = { alc861_asus_init_verbs },
16293 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16294 .dac_nids = alc861_dac_nids,
16295 .dig_out_nid = ALC861_DIGOUT_NID,
16296 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
16297 .channel_mode = alc861_asus_modes,
16298 .need_dac_fix = 1,
16299 .hp_nid = 0x06,
16300 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16301 .adc_nids = alc861_adc_nids,
16302 .input_mux = &alc861_capture_source,
16303 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010016304 [ALC861_ASUS_LAPTOP] = {
16305 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
16306 .init_verbs = { alc861_asus_init_verbs,
16307 alc861_asus_laptop_init_verbs },
16308 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16309 .dac_nids = alc861_dac_nids,
16310 .dig_out_nid = ALC861_DIGOUT_NID,
16311 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16312 .channel_mode = alc883_3ST_2ch_modes,
16313 .need_dac_fix = 1,
16314 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16315 .adc_nids = alc861_adc_nids,
16316 .input_mux = &alc861_capture_source,
16317 },
16318};
Kailang Yangdf694da2005-12-05 19:42:22 +010016319
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016320/* Pin config fixes */
16321enum {
16322 PINFIX_FSC_AMILO_PI1505,
16323};
16324
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016325static const struct alc_fixup alc861_fixups[] = {
16326 [PINFIX_FSC_AMILO_PI1505] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016327 .type = ALC_FIXUP_PINS,
16328 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020016329 { 0x0b, 0x0221101f }, /* HP */
16330 { 0x0f, 0x90170310 }, /* speaker */
16331 { }
16332 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016333 },
16334};
16335
16336static struct snd_pci_quirk alc861_fixup_tbl[] = {
16337 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
16338 {}
16339};
Kailang Yangdf694da2005-12-05 19:42:22 +010016340
16341static int patch_alc861(struct hda_codec *codec)
16342{
16343 struct alc_spec *spec;
16344 int board_config;
16345 int err;
16346
Robert P. J. Daydc041e02006-12-19 14:44:15 +010016347 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010016348 if (spec == NULL)
16349 return -ENOMEM;
16350
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016351 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016352
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016353 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
16354 alc861_models,
16355 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016356
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016357 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016358 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16359 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010016360 board_config = ALC861_AUTO;
16361 }
16362
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016363 if (board_config == ALC861_AUTO) {
16364 alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
16365 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
16366 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016367
Kailang Yangdf694da2005-12-05 19:42:22 +010016368 if (board_config == ALC861_AUTO) {
16369 /* automatic parse from the BIOS config */
16370 err = alc861_parse_auto_config(codec);
16371 if (err < 0) {
16372 alc_free(codec);
16373 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016374 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016375 printk(KERN_INFO
16376 "hda_codec: Cannot set up configuration "
16377 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010016378 board_config = ALC861_3ST_DIG;
16379 }
16380 }
16381
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016382 err = snd_hda_attach_beep_device(codec, 0x23);
16383 if (err < 0) {
16384 alc_free(codec);
16385 return err;
16386 }
16387
Kailang Yangdf694da2005-12-05 19:42:22 +010016388 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016389 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016390
Kailang Yangdf694da2005-12-05 19:42:22 +010016391 spec->stream_analog_playback = &alc861_pcm_analog_playback;
16392 spec->stream_analog_capture = &alc861_pcm_analog_capture;
16393
Kailang Yangdf694da2005-12-05 19:42:22 +010016394 spec->stream_digital_playback = &alc861_pcm_digital_playback;
16395 spec->stream_digital_capture = &alc861_pcm_digital_capture;
16396
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010016397 if (!spec->cap_mixer)
16398 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016399 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
16400
Takashi Iwai2134ea42008-01-10 16:53:55 +010016401 spec->vmaster_nid = 0x03;
16402
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016403 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016404
Kailang Yangdf694da2005-12-05 19:42:22 +010016405 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050016406 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016407 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016408#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050016409 spec->power_hook = alc_power_eapd;
16410#endif
16411 }
16412#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020016413 if (!spec->loopback.amplist)
16414 spec->loopback.amplist = alc861_loopbacks;
16415#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020016416
Kailang Yangdf694da2005-12-05 19:42:22 +010016417 return 0;
16418}
16419
16420/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016421 * ALC861-VD support
16422 *
16423 * Based on ALC882
16424 *
16425 * In addition, an independent DAC
16426 */
16427#define ALC861VD_DIGOUT_NID 0x06
16428
16429static hda_nid_t alc861vd_dac_nids[4] = {
16430 /* front, surr, clfe, side surr */
16431 0x02, 0x03, 0x04, 0x05
16432};
16433
16434/* dac_nids for ALC660vd are in a different order - according to
16435 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016436 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016437 * of ALC660vd codecs, but for now there is only 3stack mixer
16438 * - and it is the same as in 861vd.
16439 * adc_nids in ALC660vd are (is) the same as in 861vd
16440 */
16441static hda_nid_t alc660vd_dac_nids[3] = {
16442 /* front, rear, clfe, rear_surr */
16443 0x02, 0x04, 0x03
16444};
16445
16446static hda_nid_t alc861vd_adc_nids[1] = {
16447 /* ADC0 */
16448 0x09,
16449};
16450
Takashi Iwaie1406342008-02-11 18:32:32 +010016451static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
16452
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016453/* input MUX */
16454/* FIXME: should be a matrix-type input source selection */
16455static struct hda_input_mux alc861vd_capture_source = {
16456 .num_items = 4,
16457 .items = {
16458 { "Mic", 0x0 },
16459 { "Front Mic", 0x1 },
16460 { "Line", 0x2 },
16461 { "CD", 0x4 },
16462 },
16463};
16464
Kailang Yang272a5272007-05-14 11:00:38 +020016465static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010016466 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020016467 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +010016468 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +010016469 { "Internal Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020016470 },
16471};
16472
Kailang Yangd1a991a2007-08-15 16:21:59 +020016473static struct hda_input_mux alc861vd_hp_capture_source = {
16474 .num_items = 2,
16475 .items = {
16476 { "Front Mic", 0x0 },
16477 { "ATAPI Mic", 0x1 },
16478 },
16479};
16480
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016481/*
16482 * 2ch mode
16483 */
16484static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
16485 { 2, NULL }
16486};
16487
16488/*
16489 * 6ch mode
16490 */
16491static struct hda_verb alc861vd_6stack_ch6_init[] = {
16492 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16493 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16494 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16495 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16496 { } /* end */
16497};
16498
16499/*
16500 * 8ch mode
16501 */
16502static struct hda_verb alc861vd_6stack_ch8_init[] = {
16503 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16504 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16505 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16506 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16507 { } /* end */
16508};
16509
16510static struct hda_channel_mode alc861vd_6stack_modes[2] = {
16511 { 6, alc861vd_6stack_ch6_init },
16512 { 8, alc861vd_6stack_ch8_init },
16513};
16514
16515static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
16516 {
16517 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16518 .name = "Channel Mode",
16519 .info = alc_ch_mode_info,
16520 .get = alc_ch_mode_get,
16521 .put = alc_ch_mode_put,
16522 },
16523 { } /* end */
16524};
16525
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016526/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16527 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16528 */
16529static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
16530 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16531 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16532
16533 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16534 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16535
16536 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16537 HDA_OUTPUT),
16538 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16539 HDA_OUTPUT),
16540 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16541 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16542
16543 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16544 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16545
16546 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16547
David Henningsson5f99f862011-01-04 15:24:24 +010016548 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016549 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16550 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16551
David Henningsson5f99f862011-01-04 15:24:24 +010016552 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016553 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16554 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16555
16556 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16557 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16558
16559 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16560 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16561
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016562 { } /* end */
16563};
16564
16565static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
16566 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16567 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16568
16569 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16570
David Henningsson5f99f862011-01-04 15:24:24 +010016571 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016572 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16573 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16574
David Henningsson5f99f862011-01-04 15:24:24 +010016575 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016576 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16577 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16578
16579 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16580 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16581
16582 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16583 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16584
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016585 { } /* end */
16586};
16587
Kailang Yangbdd148a2007-05-08 15:19:08 +020016588static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
16589 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16590 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16591 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16592
16593 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16594
David Henningsson5f99f862011-01-04 15:24:24 +010016595 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +020016596 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16597 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16598
David Henningsson5f99f862011-01-04 15:24:24 +010016599 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +020016600 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16601 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16602
16603 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16604 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16605
16606 { } /* end */
16607};
16608
Tobin Davisb419f342008-03-07 11:57:51 +010016609/* Pin assignment: Speaker=0x14, HP = 0x15,
David Henningsson8607f7c2010-12-20 14:43:54 +010016610 * Mic=0x18, Internal Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016611 */
16612static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016613 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16614 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016615 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16616 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010016617 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson8607f7c2010-12-20 14:43:54 +010016618 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16619 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010016620 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010016621 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16622 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016623 { } /* end */
16624};
16625
Kailang Yangd1a991a2007-08-15 16:21:59 +020016626/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16627 * Front Mic=0x18, ATAPI Mic = 0x19,
16628 */
16629static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
16630 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16631 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16632 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16633 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16634 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16635 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16636 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16637 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016638
Kailang Yangd1a991a2007-08-15 16:21:59 +020016639 { } /* end */
16640};
16641
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016642/*
16643 * generic initialization of ADC, input mixers and output mixers
16644 */
16645static struct hda_verb alc861vd_volume_init_verbs[] = {
16646 /*
16647 * Unmute ADC0 and set the default input to mic-in
16648 */
16649 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16650 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16651
16652 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16653 * the analog-loopback mixer widget
16654 */
16655 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016656 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16657 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16658 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16659 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16660 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016661
16662 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016663 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16664 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16665 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016666 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016667
16668 /*
16669 * Set up output mixers (0x02 - 0x05)
16670 */
16671 /* set vol=0 to output mixers */
16672 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16673 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16674 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16675 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16676
16677 /* set up input amps for analog loopback */
16678 /* Amp Indices: DAC = 0, mixer = 1 */
16679 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16680 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16681 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16682 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16683 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16684 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16685 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16686 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16687
16688 { }
16689};
16690
16691/*
16692 * 3-stack pin configuration:
16693 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16694 */
16695static struct hda_verb alc861vd_3stack_init_verbs[] = {
16696 /*
16697 * Set pin mode and muting
16698 */
16699 /* set front pin widgets 0x14 for output */
16700 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16701 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16702 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16703
16704 /* Mic (rear) pin: input vref at 80% */
16705 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16706 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16707 /* Front Mic pin: input vref at 80% */
16708 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16709 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16710 /* Line In pin: input */
16711 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16712 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16713 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16714 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16715 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16716 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16717 /* CD pin widget for input */
16718 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16719
16720 { }
16721};
16722
16723/*
16724 * 6-stack pin configuration:
16725 */
16726static struct hda_verb alc861vd_6stack_init_verbs[] = {
16727 /*
16728 * Set pin mode and muting
16729 */
16730 /* set front pin widgets 0x14 for output */
16731 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16732 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16733 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16734
16735 /* Rear Pin: output 1 (0x0d) */
16736 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16737 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16738 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16739 /* CLFE Pin: output 2 (0x0e) */
16740 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16741 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16742 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16743 /* Side Pin: output 3 (0x0f) */
16744 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16745 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16746 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16747
16748 /* Mic (rear) pin: input vref at 80% */
16749 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16750 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16751 /* Front Mic pin: input vref at 80% */
16752 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16753 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16754 /* Line In pin: input */
16755 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16756 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16757 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16758 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16759 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16760 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16761 /* CD pin widget for input */
16762 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16763
16764 { }
16765};
16766
Kailang Yangbdd148a2007-05-08 15:19:08 +020016767static struct hda_verb alc861vd_eapd_verbs[] = {
16768 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16769 { }
16770};
16771
Kailang Yangf9423e72008-05-27 12:32:25 +020016772static struct hda_verb alc660vd_eapd_verbs[] = {
16773 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16774 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16775 { }
16776};
16777
Kailang Yangbdd148a2007-05-08 15:19:08 +020016778static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16779 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16780 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16781 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16782 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016783 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016784 {}
16785};
16786
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016787static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016788{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016789 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016790 spec->autocfg.hp_pins[0] = 0x1b;
16791 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +020016792 spec->automute = 1;
16793 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016794}
16795
16796static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16797{
Takashi Iwaid922b512011-04-28 12:18:53 +020016798 alc_hp_automute(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +010016799 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016800}
16801
16802static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16803 unsigned int res)
16804{
16805 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016806 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +010016807 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016808 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016809 default:
Takashi Iwaid922b512011-04-28 12:18:53 +020016810 alc_sku_unsol_event(codec, res);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016811 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016812 }
16813}
16814
Kailang Yang272a5272007-05-14 11:00:38 +020016815static struct hda_verb alc861vd_dallas_verbs[] = {
16816 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16817 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16818 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16819 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16820
16821 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16822 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16823 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16824 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16825 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16826 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16827 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16828 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016829
Kailang Yang272a5272007-05-14 11:00:38 +020016830 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16831 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16832 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16833 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16834 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16835 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16836 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16837 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16838
16839 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16840 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16841 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16842 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16843 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16844 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16845 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16846 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16847
16848 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16849 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16850 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16851 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16852
16853 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016854 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016855 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16856
16857 { } /* end */
16858};
16859
16860/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016861static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016862{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016863 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016864
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016865 spec->autocfg.hp_pins[0] = 0x15;
16866 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +020016867 spec->automute = 1;
16868 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yang272a5272007-05-14 11:00:38 +020016869}
16870
Takashi Iwaicb53c622007-08-10 17:21:45 +020016871#ifdef CONFIG_SND_HDA_POWER_SAVE
16872#define alc861vd_loopbacks alc880_loopbacks
16873#endif
16874
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016875/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016876#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16877#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16878#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16879#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16880
16881/*
16882 * configuration and preset
16883 */
Takashi Iwaiea734962011-01-17 11:29:34 +010016884static const char * const alc861vd_models[ALC861VD_MODEL_LAST] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016885 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016886 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016887 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016888 [ALC861VD_3ST] = "3stack",
16889 [ALC861VD_3ST_DIG] = "3stack-digout",
16890 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016891 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016892 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016893 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016894 [ALC861VD_AUTO] = "auto",
16895};
16896
16897static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016898 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16899 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016900 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016901 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016902 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016903 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016904 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016905 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016906 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016907 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016908 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016909 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016910 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016911 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016912 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016913 {}
16914};
16915
16916static struct alc_config_preset alc861vd_presets[] = {
16917 [ALC660VD_3ST] = {
16918 .mixers = { alc861vd_3st_mixer },
16919 .init_verbs = { alc861vd_volume_init_verbs,
16920 alc861vd_3stack_init_verbs },
16921 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16922 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016923 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16924 .channel_mode = alc861vd_3stack_2ch_modes,
16925 .input_mux = &alc861vd_capture_source,
16926 },
Mike Crash6963f842007-06-25 12:12:51 +020016927 [ALC660VD_3ST_DIG] = {
16928 .mixers = { alc861vd_3st_mixer },
16929 .init_verbs = { alc861vd_volume_init_verbs,
16930 alc861vd_3stack_init_verbs },
16931 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16932 .dac_nids = alc660vd_dac_nids,
16933 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016934 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16935 .channel_mode = alc861vd_3stack_2ch_modes,
16936 .input_mux = &alc861vd_capture_source,
16937 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016938 [ALC861VD_3ST] = {
16939 .mixers = { alc861vd_3st_mixer },
16940 .init_verbs = { alc861vd_volume_init_verbs,
16941 alc861vd_3stack_init_verbs },
16942 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16943 .dac_nids = alc861vd_dac_nids,
16944 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16945 .channel_mode = alc861vd_3stack_2ch_modes,
16946 .input_mux = &alc861vd_capture_source,
16947 },
16948 [ALC861VD_3ST_DIG] = {
16949 .mixers = { alc861vd_3st_mixer },
16950 .init_verbs = { alc861vd_volume_init_verbs,
16951 alc861vd_3stack_init_verbs },
16952 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16953 .dac_nids = alc861vd_dac_nids,
16954 .dig_out_nid = ALC861VD_DIGOUT_NID,
16955 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16956 .channel_mode = alc861vd_3stack_2ch_modes,
16957 .input_mux = &alc861vd_capture_source,
16958 },
16959 [ALC861VD_6ST_DIG] = {
16960 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16961 .init_verbs = { alc861vd_volume_init_verbs,
16962 alc861vd_6stack_init_verbs },
16963 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16964 .dac_nids = alc861vd_dac_nids,
16965 .dig_out_nid = ALC861VD_DIGOUT_NID,
16966 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16967 .channel_mode = alc861vd_6stack_modes,
16968 .input_mux = &alc861vd_capture_source,
16969 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016970 [ALC861VD_LENOVO] = {
16971 .mixers = { alc861vd_lenovo_mixer },
16972 .init_verbs = { alc861vd_volume_init_verbs,
16973 alc861vd_3stack_init_verbs,
16974 alc861vd_eapd_verbs,
16975 alc861vd_lenovo_unsol_verbs },
16976 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16977 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016978 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16979 .channel_mode = alc861vd_3stack_2ch_modes,
16980 .input_mux = &alc861vd_capture_source,
16981 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016982 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016983 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016984 },
Kailang Yang272a5272007-05-14 11:00:38 +020016985 [ALC861VD_DALLAS] = {
16986 .mixers = { alc861vd_dallas_mixer },
16987 .init_verbs = { alc861vd_dallas_verbs },
16988 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16989 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016990 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16991 .channel_mode = alc861vd_3stack_2ch_modes,
16992 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020016993 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016994 .setup = alc861vd_dallas_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020016995 .init_hook = alc_hp_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016996 },
16997 [ALC861VD_HP] = {
16998 .mixers = { alc861vd_hp_mixer },
16999 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
17000 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
17001 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020017002 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020017003 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17004 .channel_mode = alc861vd_3stack_2ch_modes,
17005 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020017006 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017007 .setup = alc861vd_dallas_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020017008 .init_hook = alc_hp_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020017009 },
Takashi Iwai13c94742008-11-05 08:06:08 +010017010 [ALC660VD_ASUS_V1S] = {
17011 .mixers = { alc861vd_lenovo_mixer },
17012 .init_verbs = { alc861vd_volume_init_verbs,
17013 alc861vd_3stack_init_verbs,
17014 alc861vd_eapd_verbs,
17015 alc861vd_lenovo_unsol_verbs },
17016 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
17017 .dac_nids = alc660vd_dac_nids,
17018 .dig_out_nid = ALC861VD_DIGOUT_NID,
17019 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17020 .channel_mode = alc861vd_3stack_2ch_modes,
17021 .input_mux = &alc861vd_capture_source,
17022 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017023 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020017024 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010017025 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017026};
17027
17028/*
17029 * BIOS auto configuration
17030 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020017031static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
17032 const struct auto_pin_cfg *cfg)
17033{
Herton Ronaldo Krzesinski71675942010-11-25 00:08:01 -020017034 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x22, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020017035}
17036
17037
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017038static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
17039 hda_nid_t nid, int pin_type, int dac_idx)
17040{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017041 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017042}
17043
17044static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
17045{
17046 struct alc_spec *spec = codec->spec;
17047 int i;
17048
17049 for (i = 0; i <= HDA_SIDE; i++) {
17050 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017051 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017052 if (nid)
17053 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017054 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017055 }
17056}
17057
17058
17059static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
17060{
17061 struct alc_spec *spec = codec->spec;
17062 hda_nid_t pin;
17063
17064 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017065 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017066 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017067 pin = spec->autocfg.speaker_pins[0];
17068 if (pin)
17069 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017070}
17071
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017072#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
17073
17074static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
17075{
17076 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020017077 struct auto_pin_cfg *cfg = &spec->autocfg;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017078 int i;
17079
Takashi Iwai66ceeb62010-08-30 13:05:52 +020017080 for (i = 0; i < cfg->num_inputs; i++) {
17081 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017082 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020017083 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +010017084 if (nid != ALC861VD_PIN_CD_NID &&
17085 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017086 snd_hda_codec_write(codec, nid, 0,
17087 AC_VERB_SET_AMP_GAIN_MUTE,
17088 AMP_OUT_MUTE);
17089 }
17090 }
17091}
17092
Takashi Iwaif511b012008-08-15 16:46:42 +020017093#define alc861vd_auto_init_input_src alc882_auto_init_input_src
17094
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017095#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
17096#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
17097
17098/* add playback controls from the parsed DAC table */
Takashi Iwai569ed342011-01-19 10:14:46 +010017099/* Based on ALC880 version. But ALC861VD has separate,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017100 * different NIDs for mute/unmute switch and volume control */
17101static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
17102 const struct auto_pin_cfg *cfg)
17103{
Takashi Iwaiea734962011-01-17 11:29:34 +010017104 static const char * const chname[4] = {
17105 "Front", "Surround", "CLFE", "Side"
17106 };
Takashi Iwaice764ab2011-04-27 16:35:23 +020017107 const char *pfx = alc_get_line_out_pfx(spec, true);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017108 hda_nid_t nid_v, nid_s;
Takashi Iwaice764ab2011-04-27 16:35:23 +020017109 int i, err, noutputs;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017110
Takashi Iwaice764ab2011-04-27 16:35:23 +020017111 noutputs = cfg->line_outs;
17112 if (spec->multi_ios > 0)
17113 noutputs += spec->multi_ios;
17114
17115 for (i = 0; i < noutputs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017116 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017117 continue;
17118 nid_v = alc861vd_idx_to_mixer_vol(
17119 alc880_dac_to_idx(
17120 spec->multiout.dac_nids[i]));
17121 nid_s = alc861vd_idx_to_mixer_switch(
17122 alc880_dac_to_idx(
17123 spec->multiout.dac_nids[i]));
17124
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017125 if (!pfx && i == 2) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017126 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017127 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17128 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017129 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
17130 HDA_OUTPUT));
17131 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017132 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017133 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17134 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017135 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
17136 HDA_OUTPUT));
17137 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017138 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017139 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17140 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017141 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
17142 HDA_INPUT));
17143 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017144 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017145 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17146 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017147 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
17148 HDA_INPUT));
17149 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017150 return err;
17151 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017152 const char *name = pfx;
David Henningsson5a882642011-03-23 08:35:07 +010017153 int index = i;
17154 if (!name) {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017155 name = chname[i];
David Henningsson5a882642011-03-23 08:35:07 +010017156 index = 0;
17157 }
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017158 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
David Henningsson5a882642011-03-23 08:35:07 +010017159 name, index,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017160 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
17161 HDA_OUTPUT));
17162 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017163 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017164 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
David Henningsson5a882642011-03-23 08:35:07 +010017165 name, index,
Kailang Yangbdd148a2007-05-08 15:19:08 +020017166 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017167 HDA_INPUT));
17168 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017169 return err;
17170 }
17171 }
17172 return 0;
17173}
17174
17175/* add playback controls for speaker and HP outputs */
17176/* Based on ALC880 version. But ALC861VD has separate,
17177 * different NIDs for mute/unmute switch and volume control */
17178static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
17179 hda_nid_t pin, const char *pfx)
17180{
17181 hda_nid_t nid_v, nid_s;
17182 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017183
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017184 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017185 return 0;
17186
17187 if (alc880_is_fixed_pin(pin)) {
17188 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17189 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017190 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017191 spec->multiout.hp_nid = nid_v;
17192 else
17193 spec->multiout.extra_out_nid[0] = nid_v;
17194 /* control HP volume/switch on the output mixer amp */
17195 nid_v = alc861vd_idx_to_mixer_vol(
17196 alc880_fixed_pin_idx(pin));
17197 nid_s = alc861vd_idx_to_mixer_switch(
17198 alc880_fixed_pin_idx(pin));
17199
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017200 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017201 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
17202 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017203 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017204 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017205 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
17206 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017207 return err;
17208 } else if (alc880_is_multi_pin(pin)) {
17209 /* set manual connection */
17210 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017211 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017212 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17213 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017214 return err;
17215 }
17216 return 0;
17217}
17218
17219/* parse the BIOS configuration and set up the alc_spec
17220 * return 1 if successful, 0 if the proper config is not found,
17221 * or a negative error code
17222 * Based on ALC880 version - had to change it to override
17223 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
17224static int alc861vd_parse_auto_config(struct hda_codec *codec)
17225{
17226 struct alc_spec *spec = codec->spec;
17227 int err;
17228 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
17229
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017230 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17231 alc861vd_ignore);
17232 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017233 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017234 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017235 return 0; /* can't find valid BIOS pin config */
17236
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017237 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17238 if (err < 0)
17239 return err;
Takashi Iwaice764ab2011-04-27 16:35:23 +020017240 err = alc_auto_add_multi_channel_mode(codec);
17241 if (err < 0)
17242 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017243 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
17244 if (err < 0)
17245 return err;
17246 err = alc861vd_auto_create_extra_out(spec,
17247 spec->autocfg.speaker_pins[0],
17248 "Speaker");
17249 if (err < 0)
17250 return err;
17251 err = alc861vd_auto_create_extra_out(spec,
17252 spec->autocfg.hp_pins[0],
17253 "Headphone");
17254 if (err < 0)
17255 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017256 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017257 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017258 return err;
17259
17260 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17261
Takashi Iwai757899a2010-07-30 10:48:14 +020017262 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017263
Takashi Iwai603c4012008-07-30 15:01:44 +020017264 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017265 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017266
Takashi Iwaid88897e2008-10-31 15:01:37 +010017267 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017268
17269 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017270 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017271
Takashi Iwai776e1842007-08-29 15:07:11 +020017272 err = alc_auto_add_mic_boost(codec);
17273 if (err < 0)
17274 return err;
17275
Kailang Yang6227cdc2010-02-25 08:36:52 +010017276 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017277
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017278 return 1;
17279}
17280
17281/* additional initialization for auto-configuration model */
17282static void alc861vd_auto_init(struct hda_codec *codec)
17283{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017284 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017285 alc861vd_auto_init_multi_out(codec);
17286 alc861vd_auto_init_hp_out(codec);
17287 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017288 alc861vd_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020017289 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017290 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017291 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017292}
17293
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017294enum {
17295 ALC660VD_FIX_ASUS_GPIO1
17296};
17297
17298/* reset GPIO1 */
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017299static const struct alc_fixup alc861vd_fixups[] = {
17300 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017301 .type = ALC_FIXUP_VERBS,
17302 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020017303 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
17304 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
17305 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
17306 { }
17307 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017308 },
17309};
17310
17311static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
17312 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
17313 {}
17314};
17315
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017316static int patch_alc861vd(struct hda_codec *codec)
17317{
17318 struct alc_spec *spec;
17319 int err, board_config;
17320
17321 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17322 if (spec == NULL)
17323 return -ENOMEM;
17324
17325 codec->spec = spec;
17326
17327 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
17328 alc861vd_models,
17329 alc861vd_cfg_tbl);
17330
17331 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017332 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17333 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017334 board_config = ALC861VD_AUTO;
17335 }
17336
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017337 if (board_config == ALC861VD_AUTO) {
17338 alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
17339 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
17340 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017341
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017342 if (board_config == ALC861VD_AUTO) {
17343 /* automatic parse from the BIOS config */
17344 err = alc861vd_parse_auto_config(codec);
17345 if (err < 0) {
17346 alc_free(codec);
17347 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017348 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017349 printk(KERN_INFO
17350 "hda_codec: Cannot set up configuration "
17351 "from BIOS. Using base mode...\n");
17352 board_config = ALC861VD_3ST;
17353 }
17354 }
17355
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017356 err = snd_hda_attach_beep_device(codec, 0x23);
17357 if (err < 0) {
17358 alc_free(codec);
17359 return err;
17360 }
17361
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017362 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017363 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017364
Kailang Yang2f893282008-05-27 12:14:47 +020017365 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020017366 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010017367 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020017368 }
17369
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017370 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
17371 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
17372
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017373 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
17374 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
17375
Takashi Iwaidd704692009-08-11 08:45:11 +020017376 if (!spec->adc_nids) {
17377 spec->adc_nids = alc861vd_adc_nids;
17378 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
17379 }
17380 if (!spec->capsrc_nids)
17381 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017382
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017383 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010017384 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017385
Takashi Iwai2134ea42008-01-10 16:53:55 +010017386 spec->vmaster_nid = 0x02;
17387
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017388 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017389
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017390 codec->patch_ops = alc_patch_ops;
17391
17392 if (board_config == ALC861VD_AUTO)
17393 spec->init_hook = alc861vd_auto_init;
Takashi Iwai1c716152011-04-07 10:37:16 +020017394 spec->shutup = alc_eapd_shutup;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017395#ifdef CONFIG_SND_HDA_POWER_SAVE
17396 if (!spec->loopback.amplist)
17397 spec->loopback.amplist = alc861vd_loopbacks;
17398#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017399
17400 return 0;
17401}
17402
17403/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017404 * ALC662 support
17405 *
17406 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
17407 * configuration. Each pin widget can choose any input DACs and a mixer.
17408 * Each ADC is connected from a mixer of all inputs. This makes possible
17409 * 6-channel independent captures.
17410 *
17411 * In addition, an independent DAC for the multi-playback (not used in this
17412 * driver yet).
17413 */
17414#define ALC662_DIGOUT_NID 0x06
17415#define ALC662_DIGIN_NID 0x0a
17416
Raymond Yau4bf4a6c2011-04-05 22:47:15 +080017417static hda_nid_t alc662_dac_nids[3] = {
17418 /* front, rear, clfe */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017419 0x02, 0x03, 0x04
17420};
17421
Kailang Yang622e84c2009-04-21 07:39:04 +020017422static hda_nid_t alc272_dac_nids[2] = {
17423 0x02, 0x03
17424};
17425
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017426static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017427 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017428 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017429};
Takashi Iwaie1406342008-02-11 18:32:32 +010017430
Kailang Yang622e84c2009-04-21 07:39:04 +020017431static hda_nid_t alc272_adc_nids[1] = {
17432 /* ADC1-2 */
17433 0x08,
17434};
17435
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017436static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020017437static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
17438
Takashi Iwaie1406342008-02-11 18:32:32 +010017439
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017440/* input MUX */
17441/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017442static struct hda_input_mux alc662_capture_source = {
17443 .num_items = 4,
17444 .items = {
17445 { "Mic", 0x0 },
17446 { "Front Mic", 0x1 },
17447 { "Line", 0x2 },
17448 { "CD", 0x4 },
17449 },
17450};
17451
17452static struct hda_input_mux alc662_lenovo_101e_capture_source = {
17453 .num_items = 2,
17454 .items = {
17455 { "Mic", 0x1 },
17456 { "Line", 0x2 },
17457 },
17458};
Kailang Yang291702f2007-10-16 14:28:03 +020017459
Kailang Yang6dda9f42008-05-27 12:05:31 +020017460static struct hda_input_mux alc663_capture_source = {
17461 .num_items = 3,
17462 .items = {
17463 { "Mic", 0x0 },
17464 { "Front Mic", 0x1 },
17465 { "Line", 0x2 },
17466 },
17467};
17468
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017469#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020017470static struct hda_input_mux alc272_nc10_capture_source = {
17471 .num_items = 16,
17472 .items = {
17473 { "Autoselect Mic", 0x0 },
17474 { "Internal Mic", 0x1 },
17475 { "In-0x02", 0x2 },
17476 { "In-0x03", 0x3 },
17477 { "In-0x04", 0x4 },
17478 { "In-0x05", 0x5 },
17479 { "In-0x06", 0x6 },
17480 { "In-0x07", 0x7 },
17481 { "In-0x08", 0x8 },
17482 { "In-0x09", 0x9 },
17483 { "In-0x0a", 0x0a },
17484 { "In-0x0b", 0x0b },
17485 { "In-0x0c", 0x0c },
17486 { "In-0x0d", 0x0d },
17487 { "In-0x0e", 0x0e },
17488 { "In-0x0f", 0x0f },
17489 },
17490};
17491#endif
17492
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017493/*
17494 * 2ch mode
17495 */
17496static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
17497 { 2, NULL }
17498};
17499
17500/*
17501 * 2ch mode
17502 */
17503static struct hda_verb alc662_3ST_ch2_init[] = {
17504 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
17505 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17506 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
17507 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17508 { } /* end */
17509};
17510
17511/*
17512 * 6ch mode
17513 */
17514static struct hda_verb alc662_3ST_ch6_init[] = {
17515 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17516 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17517 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17518 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17519 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17520 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17521 { } /* end */
17522};
17523
17524static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
17525 { 2, alc662_3ST_ch2_init },
17526 { 6, alc662_3ST_ch6_init },
17527};
17528
17529/*
17530 * 2ch mode
17531 */
17532static struct hda_verb alc662_sixstack_ch6_init[] = {
17533 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17534 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17535 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17536 { } /* end */
17537};
17538
17539/*
17540 * 6ch mode
17541 */
17542static struct hda_verb alc662_sixstack_ch8_init[] = {
17543 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17544 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17545 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17546 { } /* end */
17547};
17548
17549static struct hda_channel_mode alc662_5stack_modes[2] = {
17550 { 2, alc662_sixstack_ch6_init },
17551 { 6, alc662_sixstack_ch8_init },
17552};
17553
17554/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17555 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17556 */
17557
17558static struct snd_kcontrol_new alc662_base_mixer[] = {
17559 /* output mixer control */
17560 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017561 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017562 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017563 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017564 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17565 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017566 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17567 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017568 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17569
17570 /*Input mixer control */
17571 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17572 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17573 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17574 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17575 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17576 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17577 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17578 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017579 { } /* end */
17580};
17581
17582static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
17583 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017584 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017585 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17586 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17587 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17588 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17589 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17590 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17591 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17592 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17593 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017594 { } /* end */
17595};
17596
17597static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
17598 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017599 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017600 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017601 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017602 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17603 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017604 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17605 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017606 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17607 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17608 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17609 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17610 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17611 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17612 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17613 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17614 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017615 { } /* end */
17616};
17617
17618static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
17619 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17620 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017621 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17622 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017623 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17624 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17625 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17626 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17627 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017628 { } /* end */
17629};
17630
Kailang Yang291702f2007-10-16 14:28:03 +020017631static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017632 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17633 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017634
David Henningsson5f99f862011-01-04 15:24:24 +010017635 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017636 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17637 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020017638
David Henningsson5f99f862011-01-04 15:24:24 +010017639 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017640 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17641 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020017642 { } /* end */
17643};
17644
Kailang Yang8c427222008-01-10 13:03:59 +010017645static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017646 ALC262_HIPPO_MASTER_SWITCH,
17647 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017648 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017649 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17650 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017651 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17652 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17653 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17654 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17655 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17656 { } /* end */
17657};
17658
Kailang Yangf1d4e282008-08-26 14:03:29 +020017659static struct hda_bind_ctls alc663_asus_bind_master_vol = {
17660 .ops = &snd_hda_bind_vol,
17661 .values = {
17662 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17663 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17664 0
17665 },
17666};
17667
17668static struct hda_bind_ctls alc663_asus_one_bind_switch = {
17669 .ops = &snd_hda_bind_sw,
17670 .values = {
17671 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17672 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17673 0
17674 },
17675};
17676
Kailang Yang6dda9f42008-05-27 12:05:31 +020017677static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017678 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17679 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17680 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17681 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17682 { } /* end */
17683};
17684
17685static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
17686 .ops = &snd_hda_bind_sw,
17687 .values = {
17688 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17689 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17690 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17691 0
17692 },
17693};
17694
17695static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
17696 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17697 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17698 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17699 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17700 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17701 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17702
17703 { } /* end */
17704};
17705
17706static struct hda_bind_ctls alc663_asus_four_bind_switch = {
17707 .ops = &snd_hda_bind_sw,
17708 .values = {
17709 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17710 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17711 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17712 0
17713 },
17714};
17715
17716static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
17717 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17718 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17719 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17720 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17721 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17722 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17723 { } /* end */
17724};
17725
17726static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017727 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17728 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017729 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17730 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17731 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17732 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17733 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17734 { } /* end */
17735};
17736
17737static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
17738 .ops = &snd_hda_bind_vol,
17739 .values = {
17740 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17741 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17742 0
17743 },
17744};
17745
17746static struct hda_bind_ctls alc663_asus_two_bind_switch = {
17747 .ops = &snd_hda_bind_sw,
17748 .values = {
17749 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17750 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17751 0
17752 },
17753};
17754
17755static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17756 HDA_BIND_VOL("Master Playback Volume",
17757 &alc663_asus_two_bind_master_vol),
17758 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17759 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017760 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17761 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17762 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017763 { } /* end */
17764};
17765
17766static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17767 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17768 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17769 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17770 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17771 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17772 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017773 { } /* end */
17774};
17775
17776static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17777 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17778 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17779 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17780 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17781 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17782
17783 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17784 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017785 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17786 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017787 { } /* end */
17788};
17789
17790static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17791 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17792 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17793 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17794
17795 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17796 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017797 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17798 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017799 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17800 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17801 { } /* end */
17802};
17803
Kailang Yangebb83ee2009-12-17 12:23:00 +010017804static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17805 .ops = &snd_hda_bind_sw,
17806 .values = {
17807 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17808 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17809 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17810 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17811 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17812 0
17813 },
17814};
17815
17816static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17817 .ops = &snd_hda_bind_sw,
17818 .values = {
17819 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17820 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17821 0
17822 },
17823};
17824
17825static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17826 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17827 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17828 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17829 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17830 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17831 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17832 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17833 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17834 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17835 { } /* end */
17836};
17837
17838static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17839 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17840 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17841 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17842 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17843 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17844 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17845 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17846 { } /* end */
17847};
17848
17849
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017850static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17851 {
17852 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17853 .name = "Channel Mode",
17854 .info = alc_ch_mode_info,
17855 .get = alc_ch_mode_get,
17856 .put = alc_ch_mode_put,
17857 },
17858 { } /* end */
17859};
17860
17861static struct hda_verb alc662_init_verbs[] = {
17862 /* ADC: mute amp left and right */
17863 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17864 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017865
Kailang Yangb60dd392007-09-20 12:50:29 +020017866 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17867 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17868 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17869 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17870 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17871 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017872
17873 /* Front Pin: output 0 (0x0c) */
17874 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17875 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17876
17877 /* Rear Pin: output 1 (0x0d) */
17878 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17879 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17880
17881 /* CLFE Pin: output 2 (0x0e) */
17882 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17883 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17884
17885 /* Mic (rear) pin: input vref at 80% */
17886 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17887 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17888 /* Front Mic pin: input vref at 80% */
17889 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17890 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17891 /* Line In pin: input */
17892 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17893 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17894 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17895 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17896 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17897 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17898 /* CD pin widget for input */
17899 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17900
17901 /* FIXME: use matrix-type input source selection */
17902 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17903 /* Input mixer */
17904 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017905 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017906
Takashi Iwaia7f23712011-04-07 10:24:23 +020017907 { }
17908};
17909
17910static struct hda_verb alc662_eapd_init_verbs[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017911 /* always trun on EAPD */
17912 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17913 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017914 { }
17915};
17916
17917static struct hda_verb alc662_sue_init_verbs[] = {
17918 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17919 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017920 {}
17921};
17922
17923static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17924 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17925 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17926 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017927};
17928
Kailang Yang8c427222008-01-10 13:03:59 +010017929/* Set Unsolicited Event*/
17930static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17931 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17932 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17933 {}
17934};
17935
Kailang Yang6dda9f42008-05-27 12:05:31 +020017936static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017937 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17938 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017939 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17940 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017941 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17942 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17943 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017944 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17945 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17946 {}
17947};
17948
Kailang Yangf1d4e282008-08-26 14:03:29 +020017949static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17950 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17951 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17952 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17953 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17954 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17955 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17956 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17957 {}
17958};
17959
17960static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17961 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17962 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17963 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17964 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17965 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17966 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17967 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17968 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17969 {}
17970};
17971
17972static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17973 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17974 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17975 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17976 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17977 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17978 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17979 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17980 {}
17981};
17982
17983static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
17984 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17985 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17986 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17987 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17988 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17989 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17990 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17991 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17992 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17993 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17994 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17995 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17996 {}
17997};
17998
17999static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
18000 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18001 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18002 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18003 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18004 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18005 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18006 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18007 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18008 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18009 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18010 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18011 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18012 {}
18013};
18014
Kailang Yang6dda9f42008-05-27 12:05:31 +020018015static struct hda_verb alc663_g71v_init_verbs[] = {
18016 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18017 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
18018 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
18019
18020 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18021 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18022 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
18023
18024 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
18025 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
18026 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
18027 {}
18028};
18029
18030static struct hda_verb alc663_g50v_init_verbs[] = {
18031 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18032 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18033 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
18034
18035 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18036 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18037 {}
18038};
18039
Kailang Yangf1d4e282008-08-26 14:03:29 +020018040static struct hda_verb alc662_ecs_init_verbs[] = {
18041 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
18042 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18043 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18044 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18045 {}
18046};
18047
Kailang Yang622e84c2009-04-21 07:39:04 +020018048static struct hda_verb alc272_dell_zm1_init_verbs[] = {
18049 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18050 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18051 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18052 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18053 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18054 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18055 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18056 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18057 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18058 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18059 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18060 {}
18061};
18062
18063static struct hda_verb alc272_dell_init_verbs[] = {
18064 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18065 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18066 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18067 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18068 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18069 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18070 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18071 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18072 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18073 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18074 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18075 {}
18076};
18077
Kailang Yangebb83ee2009-12-17 12:23:00 +010018078static struct hda_verb alc663_mode7_init_verbs[] = {
18079 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18080 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18081 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18082 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18083 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18084 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18085 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
18086 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18087 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18088 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18089 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18090 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18091 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18092 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18093 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18094 {}
18095};
18096
18097static struct hda_verb alc663_mode8_init_verbs[] = {
18098 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18099 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18100 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18101 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
18102 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18103 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18104 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18105 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18106 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18107 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18108 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18109 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18110 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18111 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18112 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18113 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18114 {}
18115};
18116
Kailang Yangf1d4e282008-08-26 14:03:29 +020018117static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
18118 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
18119 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
18120 { } /* end */
18121};
18122
Kailang Yang622e84c2009-04-21 07:39:04 +020018123static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
18124 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
18125 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
18126 { } /* end */
18127};
18128
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020018129static void alc662_lenovo_101e_setup(struct hda_codec *codec)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018130{
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020018131 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018132
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020018133 spec->autocfg.hp_pins[0] = 0x1b;
18134 spec->autocfg.line_out_pins[0] = 0x14;
18135 spec->autocfg.speaker_pins[0] = 0x15;
18136 spec->automute = 1;
18137 spec->detect_line = 1;
18138 spec->automute_lines = 1;
18139 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018140}
18141
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018142static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020018143{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018144 struct alc_spec *spec = codec->spec;
18145
18146 alc262_hippo1_setup(codec);
18147 spec->ext_mic.pin = 0x18;
18148 spec->ext_mic.mux_idx = 0;
18149 spec->int_mic.pin = 0x19;
18150 spec->int_mic.mux_idx = 1;
18151 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020018152}
18153
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018154static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010018155{
Takashi Iwai42171c12009-05-08 14:11:43 +020018156 struct alc_spec *spec = codec->spec;
18157
18158 spec->autocfg.hp_pins[0] = 0x14;
18159 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaie9427962011-04-28 15:46:07 +020018160 spec->automute = 1;
18161 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yang8c427222008-01-10 13:03:59 +010018162}
18163
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018164static void alc663_m51va_setup(struct hda_codec *codec)
18165{
18166 struct alc_spec *spec = codec->spec;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018167 spec->autocfg.hp_pins[0] = 0x21;
18168 spec->autocfg.speaker_pins[0] = 0x14;
18169 spec->automute_mixer_nid[0] = 0x0c;
18170 spec->automute = 1;
18171 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018172 spec->ext_mic.pin = 0x18;
18173 spec->ext_mic.mux_idx = 0;
18174 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018175 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018176 spec->auto_mic = 1;
18177}
18178
Kailang Yangf1d4e282008-08-26 14:03:29 +020018179/* ***************** Mode1 ******************************/
Kailang Yangebb83ee2009-12-17 12:23:00 +010018180static void alc663_mode1_setup(struct hda_codec *codec)
18181{
18182 struct alc_spec *spec = codec->spec;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018183 spec->autocfg.hp_pins[0] = 0x21;
18184 spec->autocfg.speaker_pins[0] = 0x14;
18185 spec->automute_mixer_nid[0] = 0x0c;
18186 spec->automute = 1;
18187 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018188 spec->ext_mic.pin = 0x18;
18189 spec->ext_mic.mux_idx = 0;
18190 spec->int_mic.pin = 0x19;
18191 spec->int_mic.mux_idx = 1;
18192 spec->auto_mic = 1;
18193}
18194
Kailang Yangf1d4e282008-08-26 14:03:29 +020018195/* ***************** Mode2 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018196static void alc662_mode2_setup(struct hda_codec *codec)
Kailang Yangf1d4e282008-08-26 14:03:29 +020018197{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018198 struct alc_spec *spec = codec->spec;
18199 spec->autocfg.hp_pins[0] = 0x1b;
18200 spec->autocfg.speaker_pins[0] = 0x14;
18201 spec->automute = 1;
18202 spec->automute_mode = ALC_AUTOMUTE_PIN;
18203 spec->ext_mic.pin = 0x18;
18204 spec->ext_mic.mux_idx = 0;
18205 spec->int_mic.pin = 0x19;
18206 spec->int_mic.mux_idx = 1;
18207 spec->auto_mic = 1;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018208}
18209
Kailang Yangf1d4e282008-08-26 14:03:29 +020018210/* ***************** Mode3 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018211static void alc663_mode3_setup(struct hda_codec *codec)
Kailang Yangf1d4e282008-08-26 14:03:29 +020018212{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018213 struct alc_spec *spec = codec->spec;
18214 spec->autocfg.hp_pins[0] = 0x21;
18215 spec->autocfg.hp_pins[0] = 0x15;
18216 spec->autocfg.speaker_pins[0] = 0x14;
18217 spec->automute = 1;
18218 spec->automute_mode = ALC_AUTOMUTE_PIN;
18219 spec->ext_mic.pin = 0x18;
18220 spec->ext_mic.mux_idx = 0;
18221 spec->int_mic.pin = 0x19;
18222 spec->int_mic.mux_idx = 1;
18223 spec->auto_mic = 1;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018224}
18225
Kailang Yangf1d4e282008-08-26 14:03:29 +020018226/* ***************** Mode4 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018227static void alc663_mode4_setup(struct hda_codec *codec)
Kailang Yangf1d4e282008-08-26 14:03:29 +020018228{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018229 struct alc_spec *spec = codec->spec;
18230 spec->autocfg.hp_pins[0] = 0x21;
18231 spec->autocfg.speaker_pins[0] = 0x14;
18232 spec->autocfg.speaker_pins[1] = 0x16;
18233 spec->automute_mixer_nid[0] = 0x0c;
18234 spec->automute_mixer_nid[1] = 0x0e;
18235 spec->automute = 1;
18236 spec->automute_mode = ALC_AUTOMUTE_MIXER;
18237 spec->ext_mic.pin = 0x18;
18238 spec->ext_mic.mux_idx = 0;
18239 spec->int_mic.pin = 0x19;
18240 spec->int_mic.mux_idx = 1;
18241 spec->auto_mic = 1;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018242}
18243
Kailang Yangf1d4e282008-08-26 14:03:29 +020018244/* ***************** Mode5 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018245static void alc663_mode5_setup(struct hda_codec *codec)
Kailang Yangf1d4e282008-08-26 14:03:29 +020018246{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018247 struct alc_spec *spec = codec->spec;
18248 spec->autocfg.hp_pins[0] = 0x15;
18249 spec->autocfg.speaker_pins[0] = 0x14;
18250 spec->autocfg.speaker_pins[1] = 0x16;
18251 spec->automute_mixer_nid[0] = 0x0c;
18252 spec->automute_mixer_nid[1] = 0x0e;
18253 spec->automute = 1;
18254 spec->automute_mode = ALC_AUTOMUTE_MIXER;
18255 spec->ext_mic.pin = 0x18;
18256 spec->ext_mic.mux_idx = 0;
18257 spec->int_mic.pin = 0x19;
18258 spec->int_mic.mux_idx = 1;
18259 spec->auto_mic = 1;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018260}
18261
Kailang Yangf1d4e282008-08-26 14:03:29 +020018262/* ***************** Mode6 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018263static void alc663_mode6_setup(struct hda_codec *codec)
Kailang Yangf1d4e282008-08-26 14:03:29 +020018264{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018265 struct alc_spec *spec = codec->spec;
18266 spec->autocfg.hp_pins[0] = 0x1b;
18267 spec->autocfg.hp_pins[0] = 0x15;
18268 spec->autocfg.speaker_pins[0] = 0x14;
18269 spec->automute_mixer_nid[0] = 0x0c;
18270 spec->automute = 1;
18271 spec->automute_mode = ALC_AUTOMUTE_MIXER;
18272 spec->ext_mic.pin = 0x18;
18273 spec->ext_mic.mux_idx = 0;
18274 spec->int_mic.pin = 0x19;
18275 spec->int_mic.mux_idx = 1;
18276 spec->auto_mic = 1;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018277}
18278
Kailang Yangebb83ee2009-12-17 12:23:00 +010018279/* ***************** Mode7 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018280static void alc663_mode7_setup(struct hda_codec *codec)
Kailang Yangebb83ee2009-12-17 12:23:00 +010018281{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018282 struct alc_spec *spec = codec->spec;
18283 spec->autocfg.hp_pins[0] = 0x1b;
18284 spec->autocfg.hp_pins[0] = 0x21;
18285 spec->autocfg.speaker_pins[0] = 0x14;
18286 spec->autocfg.speaker_pins[0] = 0x17;
18287 spec->automute = 1;
18288 spec->automute_mode = ALC_AUTOMUTE_PIN;
18289 spec->ext_mic.pin = 0x18;
18290 spec->ext_mic.mux_idx = 0;
18291 spec->int_mic.pin = 0x19;
18292 spec->int_mic.mux_idx = 1;
18293 spec->auto_mic = 1;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018294}
18295
18296/* ***************** Mode8 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018297static void alc663_mode8_setup(struct hda_codec *codec)
Kailang Yangebb83ee2009-12-17 12:23:00 +010018298{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018299 struct alc_spec *spec = codec->spec;
18300 spec->autocfg.hp_pins[0] = 0x21;
18301 spec->autocfg.hp_pins[1] = 0x15;
18302 spec->autocfg.speaker_pins[0] = 0x14;
18303 spec->autocfg.speaker_pins[0] = 0x17;
18304 spec->automute = 1;
18305 spec->automute_mode = ALC_AUTOMUTE_PIN;
18306 spec->ext_mic.pin = 0x18;
18307 spec->ext_mic.mux_idx = 0;
18308 spec->int_mic.pin = 0x12;
18309 spec->int_mic.mux_idx = 9;
18310 spec->auto_mic = 1;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018311}
18312
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020018313static void alc663_g71v_setup(struct hda_codec *codec)
Kailang Yang6dda9f42008-05-27 12:05:31 +020018314{
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020018315 struct alc_spec *spec = codec->spec;
18316 spec->autocfg.hp_pins[0] = 0x21;
18317 spec->autocfg.line_out_pins[0] = 0x15;
18318 spec->autocfg.speaker_pins[0] = 0x14;
18319 spec->automute = 1;
18320 spec->automute_mode = ALC_AUTOMUTE_AMP;
18321 spec->detect_line = 1;
18322 spec->automute_lines = 1;
18323 spec->ext_mic.pin = 0x18;
18324 spec->ext_mic.mux_idx = 0;
18325 spec->int_mic.pin = 0x12;
18326 spec->int_mic.mux_idx = 9;
18327 spec->auto_mic = 1;
Kailang Yang6dda9f42008-05-27 12:05:31 +020018328}
18329
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018330#define alc663_g50v_setup alc663_m51va_setup
18331
Kailang Yangf1d4e282008-08-26 14:03:29 +020018332static struct snd_kcontrol_new alc662_ecs_mixer[] = {
18333 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020018334 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018335
David Henningsson5f99f862011-01-04 15:24:24 +010018336 HDA_CODEC_VOLUME("Mic/LineIn Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010018337 HDA_CODEC_VOLUME("Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
18338 HDA_CODEC_MUTE("Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020018339
David Henningsson5f99f862011-01-04 15:24:24 +010018340 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010018341 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18342 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020018343 { } /* end */
18344};
18345
Chris Pockelé9541ba12009-05-12 08:08:53 +020018346static struct snd_kcontrol_new alc272_nc10_mixer[] = {
18347 /* Master Playback automatically created from Speaker and Headphone */
18348 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18349 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18350 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
18351 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
18352
David Henningsson8607f7c2010-12-20 14:43:54 +010018353 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
18354 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010018355 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018356
David Henningsson28c4edb2010-12-20 14:24:29 +010018357 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18358 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010018359 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018360 { } /* end */
18361};
18362
Takashi Iwaicb53c622007-08-10 17:21:45 +020018363#ifdef CONFIG_SND_HDA_POWER_SAVE
18364#define alc662_loopbacks alc880_loopbacks
18365#endif
18366
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018367
Sasha Alexandrdef319f2009-06-16 16:00:15 -040018368/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018369#define alc662_pcm_analog_playback alc880_pcm_analog_playback
18370#define alc662_pcm_analog_capture alc880_pcm_analog_capture
18371#define alc662_pcm_digital_playback alc880_pcm_digital_playback
18372#define alc662_pcm_digital_capture alc880_pcm_digital_capture
18373
18374/*
18375 * configuration and preset
18376 */
Takashi Iwaiea734962011-01-17 11:29:34 +010018377static const char * const alc662_models[ALC662_MODEL_LAST] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018378 [ALC662_3ST_2ch_DIG] = "3stack-dig",
18379 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
18380 [ALC662_3ST_6ch] = "3stack-6ch",
Raymond Yau4bf4a6c2011-04-05 22:47:15 +080018381 [ALC662_5ST_DIG] = "5stack-dig",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018382 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020018383 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010018384 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018385 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020018386 [ALC663_ASUS_M51VA] = "m51va",
18387 [ALC663_ASUS_G71V] = "g71v",
18388 [ALC663_ASUS_H13] = "h13",
18389 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018390 [ALC663_ASUS_MODE1] = "asus-mode1",
18391 [ALC662_ASUS_MODE2] = "asus-mode2",
18392 [ALC663_ASUS_MODE3] = "asus-mode3",
18393 [ALC663_ASUS_MODE4] = "asus-mode4",
18394 [ALC663_ASUS_MODE5] = "asus-mode5",
18395 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010018396 [ALC663_ASUS_MODE7] = "asus-mode7",
18397 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020018398 [ALC272_DELL] = "dell",
18399 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020018400 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018401 [ALC662_AUTO] = "auto",
18402};
18403
18404static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010018405 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020018406 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18407 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018408 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
18409 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010018410 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018411 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
18412 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
18413 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
18414 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018415 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
18416 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018417 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018418 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
18419 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
18420 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
18421 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
18422 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018423 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018424 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
18425 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018426 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
18427 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
18428 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
18429 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018430 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018431 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
18432 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
18433 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018434 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
18435 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
18436 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
18437 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018438 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018439 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
18440 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020018441 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018442 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
18443 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
18444 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018445 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010018446 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018447 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
18448 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018449 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
18450 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
18451 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018452 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018453 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
18454 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018455 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018456 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018457 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018458 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18459 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18460 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018461 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018462 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18463 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018464 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018465 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018466 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018467 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018468 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18469 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018470 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018471 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018472 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018473 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018474 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018475 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018476 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018477 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018478 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18479 ALC663_ASUS_H13),
Anisse Astier965b76d2011-02-10 13:14:44 +010018480 SND_PCI_QUIRK(0x1991, 0x5628, "Ordissimo EVE", ALC662_LENOVO_101E),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018481 {}
18482};
18483
18484static struct alc_config_preset alc662_presets[] = {
18485 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018486 .mixers = { alc662_3ST_2ch_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018487 .init_verbs = { alc662_init_verbs, alc662_eapd_init_verbs },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018488 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18489 .dac_nids = alc662_dac_nids,
18490 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018491 .dig_in_nid = ALC662_DIGIN_NID,
18492 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18493 .channel_mode = alc662_3ST_2ch_modes,
18494 .input_mux = &alc662_capture_source,
18495 },
18496 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018497 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018498 .init_verbs = { alc662_init_verbs, alc662_eapd_init_verbs },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018499 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18500 .dac_nids = alc662_dac_nids,
18501 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018502 .dig_in_nid = ALC662_DIGIN_NID,
18503 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18504 .channel_mode = alc662_3ST_6ch_modes,
18505 .need_dac_fix = 1,
18506 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018507 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018508 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018509 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018510 .init_verbs = { alc662_init_verbs, alc662_eapd_init_verbs },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018511 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18512 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018513 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18514 .channel_mode = alc662_3ST_6ch_modes,
18515 .need_dac_fix = 1,
18516 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018517 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018518 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018519 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018520 .init_verbs = { alc662_init_verbs, alc662_eapd_init_verbs },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018521 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18522 .dac_nids = alc662_dac_nids,
18523 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018524 .dig_in_nid = ALC662_DIGIN_NID,
18525 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18526 .channel_mode = alc662_5stack_modes,
18527 .input_mux = &alc662_capture_source,
18528 },
18529 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018530 .mixers = { alc662_lenovo_101e_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018531 .init_verbs = { alc662_init_verbs,
18532 alc662_eapd_init_verbs,
18533 alc662_sue_init_verbs },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018534 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18535 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018536 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18537 .channel_mode = alc662_3ST_2ch_modes,
18538 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020018539 .unsol_event = alc_sku_unsol_event,
18540 .setup = alc662_lenovo_101e_setup,
18541 .init_hook = alc_inithook,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018542 },
Kailang Yang291702f2007-10-16 14:28:03 +020018543 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018544 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018545 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018546 alc662_eapd_init_verbs,
Kailang Yang291702f2007-10-16 14:28:03 +020018547 alc662_eeepc_sue_init_verbs },
18548 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18549 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018550 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18551 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwaie9427962011-04-28 15:46:07 +020018552 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018553 .setup = alc662_eeepc_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020018554 .init_hook = alc_inithook,
Kailang Yang291702f2007-10-16 14:28:03 +020018555 },
Kailang Yang8c427222008-01-10 13:03:59 +010018556 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018557 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018558 alc662_chmode_mixer },
18559 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018560 alc662_eapd_init_verbs,
Kailang Yang8c427222008-01-10 13:03:59 +010018561 alc662_eeepc_ep20_sue_init_verbs },
18562 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18563 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018564 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18565 .channel_mode = alc662_3ST_6ch_modes,
18566 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020018567 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018568 .setup = alc662_eeepc_ep20_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020018569 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010018570 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018571 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018572 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018573 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018574 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018575 alc662_ecs_init_verbs },
18576 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18577 .dac_nids = alc662_dac_nids,
18578 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18579 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwaie9427962011-04-28 15:46:07 +020018580 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018581 .setup = alc662_eeepc_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020018582 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018583 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018584 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018585 .mixers = { alc663_m51va_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018586 .init_verbs = { alc662_init_verbs,
18587 alc662_eapd_init_verbs,
18588 alc663_m51va_init_verbs },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018589 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18590 .dac_nids = alc662_dac_nids,
18591 .dig_out_nid = ALC662_DIGOUT_NID,
18592 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18593 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018594 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018595 .setup = alc663_m51va_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018596 .init_hook = alc_inithook,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018597 },
18598 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018599 .mixers = { alc663_g71v_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018600 .init_verbs = { alc662_init_verbs,
18601 alc662_eapd_init_verbs,
18602 alc663_g71v_init_verbs },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018603 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18604 .dac_nids = alc662_dac_nids,
18605 .dig_out_nid = ALC662_DIGOUT_NID,
18606 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18607 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020018608 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018609 .setup = alc663_g71v_setup,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020018610 .init_hook = alc_inithook,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018611 },
18612 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018613 .mixers = { alc663_m51va_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018614 .init_verbs = { alc662_init_verbs,
18615 alc662_eapd_init_verbs,
18616 alc663_m51va_init_verbs },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018617 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18618 .dac_nids = alc662_dac_nids,
18619 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18620 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018621 .setup = alc663_m51va_setup,
18622 .unsol_event = alc_sku_unsol_event,
18623 .init_hook = alc_inithook,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018624 },
18625 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018626 .mixers = { alc663_g50v_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018627 .init_verbs = { alc662_init_verbs,
18628 alc662_eapd_init_verbs,
18629 alc663_g50v_init_verbs },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018630 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18631 .dac_nids = alc662_dac_nids,
18632 .dig_out_nid = ALC662_DIGOUT_NID,
18633 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18634 .channel_mode = alc662_3ST_6ch_modes,
18635 .input_mux = &alc663_capture_source,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018636 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018637 .setup = alc663_g50v_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018638 .init_hook = alc_inithook,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018639 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018640 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018641 .mixers = { alc663_m51va_mixer },
18642 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018643 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018644 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018645 alc663_21jd_amic_init_verbs },
18646 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18647 .hp_nid = 0x03,
18648 .dac_nids = alc662_dac_nids,
18649 .dig_out_nid = ALC662_DIGOUT_NID,
18650 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18651 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018652 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018653 .setup = alc663_mode1_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018654 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018655 },
18656 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018657 .mixers = { alc662_1bjd_mixer },
18658 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018659 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018660 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018661 alc662_1bjd_amic_init_verbs },
18662 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18663 .dac_nids = alc662_dac_nids,
18664 .dig_out_nid = ALC662_DIGOUT_NID,
18665 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18666 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018667 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018668 .setup = alc662_mode2_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018669 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018670 },
18671 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018672 .mixers = { alc663_two_hp_m1_mixer },
18673 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018674 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018675 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018676 alc663_two_hp_amic_m1_init_verbs },
18677 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18678 .hp_nid = 0x03,
18679 .dac_nids = alc662_dac_nids,
18680 .dig_out_nid = ALC662_DIGOUT_NID,
18681 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18682 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018683 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018684 .setup = alc663_mode3_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018685 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018686 },
18687 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018688 .mixers = { alc663_asus_21jd_clfe_mixer },
18689 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018690 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018691 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018692 alc663_21jd_amic_init_verbs},
18693 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18694 .hp_nid = 0x03,
18695 .dac_nids = alc662_dac_nids,
18696 .dig_out_nid = ALC662_DIGOUT_NID,
18697 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18698 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018699 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018700 .setup = alc663_mode4_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018701 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018702 },
18703 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018704 .mixers = { alc663_asus_15jd_clfe_mixer },
18705 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018706 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018707 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018708 alc663_15jd_amic_init_verbs },
18709 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18710 .hp_nid = 0x03,
18711 .dac_nids = alc662_dac_nids,
18712 .dig_out_nid = ALC662_DIGOUT_NID,
18713 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18714 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018715 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018716 .setup = alc663_mode5_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018717 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018718 },
18719 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018720 .mixers = { alc663_two_hp_m2_mixer },
18721 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018722 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018723 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018724 alc663_two_hp_amic_m2_init_verbs },
18725 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18726 .hp_nid = 0x03,
18727 .dac_nids = alc662_dac_nids,
18728 .dig_out_nid = ALC662_DIGOUT_NID,
18729 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18730 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018731 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018732 .setup = alc663_mode6_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018733 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018734 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018735 [ALC663_ASUS_MODE7] = {
18736 .mixers = { alc663_mode7_mixer },
18737 .cap_mixer = alc662_auto_capture_mixer,
18738 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018739 alc662_eapd_init_verbs,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018740 alc663_mode7_init_verbs },
18741 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18742 .hp_nid = 0x03,
18743 .dac_nids = alc662_dac_nids,
18744 .dig_out_nid = ALC662_DIGOUT_NID,
18745 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18746 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018747 .unsol_event = alc_sku_unsol_event,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018748 .setup = alc663_mode7_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018749 .init_hook = alc_inithook,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018750 },
18751 [ALC663_ASUS_MODE8] = {
18752 .mixers = { alc663_mode8_mixer },
18753 .cap_mixer = alc662_auto_capture_mixer,
18754 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018755 alc662_eapd_init_verbs,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018756 alc663_mode8_init_verbs },
18757 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18758 .hp_nid = 0x03,
18759 .dac_nids = alc662_dac_nids,
18760 .dig_out_nid = ALC662_DIGOUT_NID,
18761 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18762 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018763 .unsol_event = alc_sku_unsol_event,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018764 .setup = alc663_mode8_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018765 .init_hook = alc_inithook,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018766 },
Kailang Yang622e84c2009-04-21 07:39:04 +020018767 [ALC272_DELL] = {
18768 .mixers = { alc663_m51va_mixer },
18769 .cap_mixer = alc272_auto_capture_mixer,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018770 .init_verbs = { alc662_init_verbs,
18771 alc662_eapd_init_verbs,
18772 alc272_dell_init_verbs },
Kailang Yang622e84c2009-04-21 07:39:04 +020018773 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
Takashi Iwai1bc7cf92011-04-06 09:42:29 +020018774 .dac_nids = alc272_dac_nids,
Kailang Yang622e84c2009-04-21 07:39:04 +020018775 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18776 .adc_nids = alc272_adc_nids,
18777 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
18778 .capsrc_nids = alc272_capsrc_nids,
18779 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018780 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018781 .setup = alc663_m51va_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018782 .init_hook = alc_inithook,
Kailang Yang622e84c2009-04-21 07:39:04 +020018783 },
18784 [ALC272_DELL_ZM1] = {
18785 .mixers = { alc663_m51va_mixer },
18786 .cap_mixer = alc662_auto_capture_mixer,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018787 .init_verbs = { alc662_init_verbs,
18788 alc662_eapd_init_verbs,
18789 alc272_dell_zm1_init_verbs },
Kailang Yang622e84c2009-04-21 07:39:04 +020018790 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
Takashi Iwai1bc7cf92011-04-06 09:42:29 +020018791 .dac_nids = alc272_dac_nids,
Kailang Yang622e84c2009-04-21 07:39:04 +020018792 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18793 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018794 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020018795 .capsrc_nids = alc662_capsrc_nids,
18796 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018797 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018798 .setup = alc663_m51va_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018799 .init_hook = alc_inithook,
Kailang Yang622e84c2009-04-21 07:39:04 +020018800 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020018801 [ALC272_SAMSUNG_NC10] = {
18802 .mixers = { alc272_nc10_mixer },
18803 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018804 alc662_eapd_init_verbs,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018805 alc663_21jd_amic_init_verbs },
18806 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18807 .dac_nids = alc272_dac_nids,
18808 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18809 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018810 /*.input_mux = &alc272_nc10_capture_source,*/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018811 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018812 .setup = alc663_mode4_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018813 .init_hook = alc_inithook,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018814 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018815};
18816
18817
18818/*
18819 * BIOS auto configuration
18820 */
18821
Takashi Iwai7085ec12009-10-02 09:03:58 +020018822/* convert from MIX nid to DAC */
Takashi Iwai604401a2011-04-27 15:14:23 +020018823static hda_nid_t alc_auto_mix_to_dac(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018824{
Takashi Iwai604401a2011-04-27 15:14:23 +020018825 hda_nid_t list[5];
Takashi Iwai1304ac82011-04-06 15:16:21 +020018826 int i, num;
18827
18828 num = snd_hda_get_connections(codec, nid, list, ARRAY_SIZE(list));
18829 for (i = 0; i < num; i++) {
18830 if (get_wcaps_type(get_wcaps(codec, list[i])) == AC_WID_AUD_OUT)
18831 return list[i];
18832 }
18833 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018834}
18835
Takashi Iwai604401a2011-04-27 15:14:23 +020018836/* go down to the selector widget before the mixer */
18837static hda_nid_t alc_go_down_to_selector(struct hda_codec *codec, hda_nid_t pin)
18838{
18839 hda_nid_t srcs[5];
18840 int num = snd_hda_get_connections(codec, pin, srcs,
18841 ARRAY_SIZE(srcs));
18842 if (num != 1 ||
18843 get_wcaps_type(get_wcaps(codec, srcs[0])) != AC_WID_AUD_SEL)
18844 return pin;
18845 return srcs[0];
18846}
18847
Takashi Iwai7085ec12009-10-02 09:03:58 +020018848/* get MIX nid connected to the given pin targeted to DAC */
Takashi Iwai604401a2011-04-27 15:14:23 +020018849static hda_nid_t alc_auto_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018850 hda_nid_t dac)
18851{
David Henningssoncc1c4522010-11-24 14:17:47 +010018852 hda_nid_t mix[5];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018853 int i, num;
18854
Takashi Iwai604401a2011-04-27 15:14:23 +020018855 pin = alc_go_down_to_selector(codec, pin);
Takashi Iwai7085ec12009-10-02 09:03:58 +020018856 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
18857 for (i = 0; i < num; i++) {
Takashi Iwai604401a2011-04-27 15:14:23 +020018858 if (alc_auto_mix_to_dac(codec, mix[i]) == dac)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018859 return mix[i];
18860 }
18861 return 0;
18862}
18863
Takashi Iwaice764ab2011-04-27 16:35:23 +020018864/* select the connection from pin to DAC if needed */
18865static int alc_auto_select_dac(struct hda_codec *codec, hda_nid_t pin,
18866 hda_nid_t dac)
18867{
18868 hda_nid_t mix[5];
18869 int i, num;
18870
18871 pin = alc_go_down_to_selector(codec, pin);
18872 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
18873 if (num < 2)
18874 return 0;
18875 for (i = 0; i < num; i++) {
18876 if (alc_auto_mix_to_dac(codec, mix[i]) == dac) {
18877 snd_hda_codec_update_cache(codec, pin, 0,
18878 AC_VERB_SET_CONNECT_SEL, i);
18879 return 0;
18880 }
18881 }
18882 return 0;
18883}
18884
Takashi Iwai7085ec12009-10-02 09:03:58 +020018885/* look for an empty DAC slot */
Takashi Iwai604401a2011-04-27 15:14:23 +020018886static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018887{
18888 struct alc_spec *spec = codec->spec;
18889 hda_nid_t srcs[5];
18890 int i, j, num;
18891
Takashi Iwai604401a2011-04-27 15:14:23 +020018892 pin = alc_go_down_to_selector(codec, pin);
Takashi Iwai7085ec12009-10-02 09:03:58 +020018893 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
Takashi Iwai7085ec12009-10-02 09:03:58 +020018894 for (i = 0; i < num; i++) {
Takashi Iwai604401a2011-04-27 15:14:23 +020018895 hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]);
Takashi Iwai7085ec12009-10-02 09:03:58 +020018896 if (!nid)
18897 continue;
18898 for (j = 0; j < spec->multiout.num_dacs; j++)
18899 if (spec->multiout.dac_nids[j] == nid)
18900 break;
18901 if (j >= spec->multiout.num_dacs)
18902 return nid;
18903 }
18904 return 0;
18905}
18906
18907/* fill in the dac_nids table from the parsed pin configuration */
18908static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
18909 const struct auto_pin_cfg *cfg)
18910{
18911 struct alc_spec *spec = codec->spec;
18912 int i;
18913 hda_nid_t dac;
18914
18915 spec->multiout.dac_nids = spec->private_dac_nids;
18916 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai604401a2011-04-27 15:14:23 +020018917 dac = alc_auto_look_for_dac(codec, cfg->line_out_pins[i]);
Takashi Iwai7085ec12009-10-02 09:03:58 +020018918 if (!dac)
18919 continue;
18920 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
18921 }
18922 return 0;
18923}
18924
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010018925static inline int __alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
18926 hda_nid_t nid, int idx, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018927{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010018928 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018929 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
18930}
18931
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010018932static inline int __alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
18933 hda_nid_t nid, int idx, unsigned int chs)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018934{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010018935 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018936 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
18937}
18938
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010018939#define alc662_add_vol_ctl(spec, pfx, nid, chs) \
18940 __alc662_add_vol_ctl(spec, pfx, nid, 0, chs)
18941#define alc662_add_sw_ctl(spec, pfx, nid, chs) \
18942 __alc662_add_sw_ctl(spec, pfx, nid, 0, chs)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018943#define alc662_add_stereo_vol(spec, pfx, nid) \
18944 alc662_add_vol_ctl(spec, pfx, nid, 3)
18945#define alc662_add_stereo_sw(spec, pfx, nid) \
18946 alc662_add_sw_ctl(spec, pfx, nid, 3)
18947
18948/* add playback controls from the parsed DAC table */
18949static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
18950 const struct auto_pin_cfg *cfg)
18951{
18952 struct alc_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +010018953 static const char * const chname[4] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018954 "Front", "Surround", NULL /*CLFE*/, "Side"
18955 };
Takashi Iwaice764ab2011-04-27 16:35:23 +020018956 const char *pfx = alc_get_line_out_pfx(spec, true);
18957 hda_nid_t nid, mix, pin;
18958 int i, err, noutputs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018959
Takashi Iwaice764ab2011-04-27 16:35:23 +020018960 noutputs = cfg->line_outs;
18961 if (spec->multi_ios > 0)
18962 noutputs += spec->multi_ios;
18963
18964 for (i = 0; i < noutputs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018965 nid = spec->multiout.dac_nids[i];
18966 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018967 continue;
Takashi Iwaice764ab2011-04-27 16:35:23 +020018968 if (i >= cfg->line_outs)
18969 pin = spec->multi_io[i - 1].pin;
18970 else
18971 pin = cfg->line_out_pins[i];
18972 mix = alc_auto_dac_to_mix(codec, pin, nid);
Takashi Iwai7085ec12009-10-02 09:03:58 +020018973 if (!mix)
18974 continue;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010018975 if (!pfx && i == 2) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018976 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018977 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018978 if (err < 0)
18979 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018980 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018981 if (err < 0)
18982 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018983 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018984 if (err < 0)
18985 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018986 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018987 if (err < 0)
18988 return err;
18989 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010018990 const char *name = pfx;
David Henningsson5a882642011-03-23 08:35:07 +010018991 int index = i;
18992 if (!name) {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010018993 name = chname[i];
David Henningsson5a882642011-03-23 08:35:07 +010018994 index = 0;
18995 }
18996 err = __alc662_add_vol_ctl(spec, name, nid, index, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018997 if (err < 0)
18998 return err;
David Henningsson5a882642011-03-23 08:35:07 +010018999 err = __alc662_add_sw_ctl(spec, name, mix, index, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019000 if (err < 0)
19001 return err;
19002 }
19003 }
19004 return 0;
19005}
19006
19007/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019008/* return DAC nid if any new DAC is assigned */
19009static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019010 const char *pfx)
19011{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019012 struct alc_spec *spec = codec->spec;
19013 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019014 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019015
19016 if (!pin)
19017 return 0;
Takashi Iwai604401a2011-04-27 15:14:23 +020019018 nid = alc_auto_look_for_dac(codec, pin);
Takashi Iwai7085ec12009-10-02 09:03:58 +020019019 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019020 /* the corresponding DAC is already occupied */
19021 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
19022 return 0; /* no way */
19023 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019024 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019025 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
19026 }
19027
Takashi Iwai604401a2011-04-27 15:14:23 +020019028 mix = alc_auto_dac_to_mix(codec, pin, nid);
Takashi Iwai7085ec12009-10-02 09:03:58 +020019029 if (!mix)
19030 return 0;
19031 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
19032 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020019033 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019034 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
19035 if (err < 0)
19036 return err;
19037 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019038}
19039
19040/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020019041#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020019042 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019043
19044static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
19045 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019046 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019047{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019048 int i, num;
Takashi Iwaice503f32010-07-30 10:37:29 +020019049 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019050
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019051 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai7085ec12009-10-02 09:03:58 +020019052 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
Takashi Iwai7085ec12009-10-02 09:03:58 +020019053 for (i = 0; i < num; i++) {
Takashi Iwai604401a2011-04-27 15:14:23 +020019054 if (alc_auto_mix_to_dac(codec, srcs[i]) != dac)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019055 continue;
Takashi Iwai0e53f342011-04-07 12:27:32 +020019056 /* need the manual connection? */
19057 if (num > 1)
19058 snd_hda_codec_write(codec, nid, 0,
19059 AC_VERB_SET_CONNECT_SEL, i);
19060 /* unmute mixer widget inputs */
19061 snd_hda_codec_write(codec, srcs[i], 0,
19062 AC_VERB_SET_AMP_GAIN_MUTE,
19063 AMP_IN_UNMUTE(0));
19064 snd_hda_codec_write(codec, srcs[i], 0,
19065 AC_VERB_SET_AMP_GAIN_MUTE,
19066 AMP_IN_UNMUTE(1));
Takashi Iwai7085ec12009-10-02 09:03:58 +020019067 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019068 }
19069}
19070
19071static void alc662_auto_init_multi_out(struct hda_codec *codec)
19072{
19073 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019074 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019075 int i;
19076
19077 for (i = 0; i <= HDA_SIDE; i++) {
19078 hda_nid_t nid = spec->autocfg.line_out_pins[i];
19079 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020019080 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019081 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019082 }
19083}
19084
19085static void alc662_auto_init_hp_out(struct hda_codec *codec)
19086{
19087 struct alc_spec *spec = codec->spec;
19088 hda_nid_t pin;
19089
19090 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019091 if (pin)
19092 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
19093 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019094 pin = spec->autocfg.speaker_pins[0];
19095 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019096 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
19097 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019098}
19099
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019100#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
19101
19102static void alc662_auto_init_analog_input(struct hda_codec *codec)
19103{
19104 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019105 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019106 int i;
19107
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019108 for (i = 0; i < cfg->num_inputs; i++) {
19109 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019110 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020019111 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010019112 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010019113 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019114 snd_hda_codec_write(codec, nid, 0,
19115 AC_VERB_SET_AMP_GAIN_MUTE,
19116 AMP_OUT_MUTE);
19117 }
19118 }
19119}
19120
Takashi Iwaif511b012008-08-15 16:46:42 +020019121#define alc662_auto_init_input_src alc882_auto_init_input_src
19122
Takashi Iwaice764ab2011-04-27 16:35:23 +020019123/*
19124 * multi-io helper
19125 */
19126static int alc_auto_fill_multi_ios(struct hda_codec *codec,
19127 unsigned int location)
19128{
19129 struct alc_spec *spec = codec->spec;
19130 struct auto_pin_cfg *cfg = &spec->autocfg;
19131 int type, i, num_pins = 0;
19132
19133 for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) {
19134 for (i = 0; i < cfg->num_inputs; i++) {
19135 hda_nid_t nid = cfg->inputs[i].pin;
19136 hda_nid_t dac;
19137 unsigned int defcfg, caps;
19138 if (cfg->inputs[i].type != type)
19139 continue;
19140 defcfg = snd_hda_codec_get_pincfg(codec, nid);
19141 if (get_defcfg_connect(defcfg) != AC_JACK_PORT_COMPLEX)
19142 continue;
19143 if (location && get_defcfg_location(defcfg) != location)
19144 continue;
19145 caps = snd_hda_query_pin_caps(codec, nid);
19146 if (!(caps & AC_PINCAP_OUT))
19147 continue;
19148 dac = alc_auto_look_for_dac(codec, nid);
19149 if (!dac)
19150 continue;
19151 spec->multi_io[num_pins].pin = nid;
19152 spec->multi_io[num_pins].dac = dac;
19153 num_pins++;
19154 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19155 }
19156 }
19157 spec->multiout.num_dacs = 1;
19158 if (num_pins < 2)
19159 return 0;
19160 return num_pins;
19161}
19162
19163static int alc_auto_ch_mode_info(struct snd_kcontrol *kcontrol,
19164 struct snd_ctl_elem_info *uinfo)
19165{
19166 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
19167 struct alc_spec *spec = codec->spec;
19168
19169 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
19170 uinfo->count = 1;
19171 uinfo->value.enumerated.items = spec->multi_ios + 1;
19172 if (uinfo->value.enumerated.item > spec->multi_ios)
19173 uinfo->value.enumerated.item = spec->multi_ios;
19174 sprintf(uinfo->value.enumerated.name, "%dch",
19175 (uinfo->value.enumerated.item + 1) * 2);
19176 return 0;
19177}
19178
19179static int alc_auto_ch_mode_get(struct snd_kcontrol *kcontrol,
19180 struct snd_ctl_elem_value *ucontrol)
19181{
19182 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
19183 struct alc_spec *spec = codec->spec;
19184 ucontrol->value.enumerated.item[0] = (spec->ext_channel_count - 1) / 2;
19185 return 0;
19186}
19187
19188static int alc_set_multi_io(struct hda_codec *codec, int idx, bool output)
19189{
19190 struct alc_spec *spec = codec->spec;
19191 hda_nid_t nid = spec->multi_io[idx].pin;
19192
19193 if (!spec->multi_io[idx].ctl_in)
19194 spec->multi_io[idx].ctl_in =
19195 snd_hda_codec_read(codec, nid, 0,
19196 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
19197 if (output) {
19198 snd_hda_codec_update_cache(codec, nid, 0,
19199 AC_VERB_SET_PIN_WIDGET_CONTROL,
19200 PIN_OUT);
19201 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
19202 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
19203 HDA_AMP_MUTE, 0);
19204 alc_auto_select_dac(codec, nid, spec->multi_io[idx].dac);
19205 } else {
19206 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
19207 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
19208 HDA_AMP_MUTE, HDA_AMP_MUTE);
19209 snd_hda_codec_update_cache(codec, nid, 0,
19210 AC_VERB_SET_PIN_WIDGET_CONTROL,
19211 spec->multi_io[idx].ctl_in);
19212 }
19213 return 0;
19214}
19215
19216static int alc_auto_ch_mode_put(struct snd_kcontrol *kcontrol,
19217 struct snd_ctl_elem_value *ucontrol)
19218{
19219 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
19220 struct alc_spec *spec = codec->spec;
19221 int i, ch;
19222
19223 ch = ucontrol->value.enumerated.item[0];
19224 if (ch < 0 || ch > spec->multi_ios)
19225 return -EINVAL;
19226 if (ch == (spec->ext_channel_count - 1) / 2)
19227 return 0;
19228 spec->ext_channel_count = (ch + 1) * 2;
19229 for (i = 0; i < spec->multi_ios; i++)
19230 alc_set_multi_io(codec, i, i < ch);
19231 spec->multiout.max_channels = spec->ext_channel_count;
19232 return 1;
19233}
19234
19235static struct snd_kcontrol_new alc_auto_channel_mode_enum = {
19236 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
19237 .name = "Channel Mode",
19238 .info = alc_auto_ch_mode_info,
19239 .get = alc_auto_ch_mode_get,
19240 .put = alc_auto_ch_mode_put,
19241};
19242
19243static int alc_auto_add_multi_channel_mode(struct hda_codec *codec)
19244{
19245 struct alc_spec *spec = codec->spec;
19246 struct auto_pin_cfg *cfg = &spec->autocfg;
19247 unsigned int location, defcfg;
19248 int num_pins;
19249
19250 if (cfg->line_outs != 1 ||
19251 cfg->line_out_type != AUTO_PIN_LINE_OUT)
19252 return 0;
19253
19254 defcfg = snd_hda_codec_get_pincfg(codec, cfg->line_out_pins[0]);
19255 location = get_defcfg_location(defcfg);
19256
19257 num_pins = alc_auto_fill_multi_ios(codec, location);
19258 if (num_pins > 0) {
19259 struct snd_kcontrol_new *knew;
19260
19261 knew = alc_kcontrol_new(spec);
19262 if (!knew)
19263 return -ENOMEM;
19264 *knew = alc_auto_channel_mode_enum;
19265 knew->name = kstrdup("Channel Mode", GFP_KERNEL);
19266 if (!knew->name)
19267 return -ENOMEM;
19268
19269 spec->multi_ios = num_pins;
19270 spec->ext_channel_count = 2;
19271 spec->multiout.num_dacs = num_pins + 1;
19272 }
19273 return 0;
19274}
19275
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019276static int alc662_parse_auto_config(struct hda_codec *codec)
19277{
19278 struct alc_spec *spec = codec->spec;
19279 int err;
19280 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
19281
19282 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19283 alc662_ignore);
19284 if (err < 0)
19285 return err;
19286 if (!spec->autocfg.line_outs)
19287 return 0; /* can't find valid BIOS pin config */
19288
Takashi Iwai7085ec12009-10-02 09:03:58 +020019289 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019290 if (err < 0)
19291 return err;
Takashi Iwaice764ab2011-04-27 16:35:23 +020019292 err = alc_auto_add_multi_channel_mode(codec);
19293 if (err < 0)
19294 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019295 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019296 if (err < 0)
19297 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019298 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019299 spec->autocfg.speaker_pins[0],
19300 "Speaker");
19301 if (err < 0)
19302 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019303 if (err)
19304 spec->multiout.extra_out_nid[0] = err;
19305 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019306 "Headphone");
19307 if (err < 0)
19308 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019309 if (err)
19310 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019311 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019312 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019313 return err;
19314
19315 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
19316
Takashi Iwai757899a2010-07-30 10:48:14 +020019317 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019318
Takashi Iwai603c4012008-07-30 15:01:44 +020019319 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010019320 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019321
19322 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020019323 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020019324
Takashi Iwaiee979a142008-09-02 15:42:20 +020019325 err = alc_auto_add_mic_boost(codec);
19326 if (err < 0)
19327 return err;
19328
Kailang Yang6227cdc2010-02-25 08:36:52 +010019329 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
19330 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
19331 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
19332 else
19333 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020019334
Takashi Iwai8c872862007-06-19 12:11:16 +020019335 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019336}
19337
19338/* additional initialization for auto-configuration model */
19339static void alc662_auto_init(struct hda_codec *codec)
19340{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019341 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019342 alc662_auto_init_multi_out(codec);
19343 alc662_auto_init_hp_out(codec);
19344 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020019345 alc662_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019346 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019347 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020019348 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019349}
19350
Todd Broch6be79482010-12-07 16:51:05 -080019351static void alc272_fixup_mario(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019352 const struct alc_fixup *fix, int action)
Takashi Iwai6fc398c2011-01-13 14:36:37 +010019353{
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019354 if (action != ALC_FIXUP_ACT_PROBE)
Takashi Iwai6fc398c2011-01-13 14:36:37 +010019355 return;
Todd Broch6be79482010-12-07 16:51:05 -080019356 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
19357 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
19358 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
19359 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
19360 (0 << AC_AMPCAP_MUTE_SHIFT)))
19361 printk(KERN_WARNING
19362 "hda_codec: failed to override amp caps for NID 0x2\n");
19363}
19364
David Henningsson6cb3b702010-09-09 08:51:44 +020019365enum {
Daniel T Chen2df03512010-10-10 22:39:28 -040019366 ALC662_FIXUP_ASPIRE,
David Henningsson6cb3b702010-09-09 08:51:44 +020019367 ALC662_FIXUP_IDEAPAD,
Todd Broch6be79482010-12-07 16:51:05 -080019368 ALC272_FIXUP_MARIO,
Anisse Astierd2ebd472011-01-20 12:36:21 +010019369 ALC662_FIXUP_CZC_P10T,
Takashi Iwaic6b35872011-03-28 12:05:31 +020019370 ALC662_FIXUP_GIGABYTE,
David Henningsson6cb3b702010-09-09 08:51:44 +020019371};
19372
19373static const struct alc_fixup alc662_fixups[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -040019374 [ALC662_FIXUP_ASPIRE] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019375 .type = ALC_FIXUP_PINS,
19376 .v.pins = (const struct alc_pincfg[]) {
Daniel T Chen2df03512010-10-10 22:39:28 -040019377 { 0x15, 0x99130112 }, /* subwoofer */
19378 { }
19379 }
19380 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019381 [ALC662_FIXUP_IDEAPAD] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019382 .type = ALC_FIXUP_PINS,
19383 .v.pins = (const struct alc_pincfg[]) {
David Henningsson6cb3b702010-09-09 08:51:44 +020019384 { 0x17, 0x99130112 }, /* subwoofer */
19385 { }
19386 }
19387 },
Todd Broch6be79482010-12-07 16:51:05 -080019388 [ALC272_FIXUP_MARIO] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019389 .type = ALC_FIXUP_FUNC,
19390 .v.func = alc272_fixup_mario,
Anisse Astierd2ebd472011-01-20 12:36:21 +010019391 },
19392 [ALC662_FIXUP_CZC_P10T] = {
19393 .type = ALC_FIXUP_VERBS,
19394 .v.verbs = (const struct hda_verb[]) {
19395 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
19396 {}
19397 }
19398 },
Takashi Iwaic6b35872011-03-28 12:05:31 +020019399 [ALC662_FIXUP_GIGABYTE] = {
19400 .type = ALC_FIXUP_PINS,
19401 .v.pins = (const struct alc_pincfg[]) {
19402 { 0x14, 0x1114410 }, /* set as speaker */
19403 { }
19404 }
19405 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019406};
19407
19408static struct snd_pci_quirk alc662_fixup_tbl[] = {
David Henningssona6c47a82011-02-10 15:39:19 +010019409 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
Daniel T Chen2df03512010-10-10 22:39:28 -040019410 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
Daniel T Chena0e90ac2010-11-20 10:20:35 -050019411 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
Takashi Iwaic6b35872011-03-28 12:05:31 +020019412 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte", ALC662_FIXUP_GIGABYTE),
Valentine Sinitsynd4118582010-10-01 22:24:08 +060019413 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
David Henningsson6cb3b702010-09-09 08:51:44 +020019414 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
Anisse Astierd2ebd472011-01-20 12:36:21 +010019415 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
David Henningsson6cb3b702010-09-09 08:51:44 +020019416 {}
19417};
19418
Todd Broch6be79482010-12-07 16:51:05 -080019419static const struct alc_model_fixup alc662_fixup_models[] = {
19420 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
19421 {}
19422};
David Henningsson6cb3b702010-09-09 08:51:44 +020019423
19424
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019425static int patch_alc662(struct hda_codec *codec)
19426{
19427 struct alc_spec *spec;
19428 int err, board_config;
Kailang Yang693194f2010-10-21 08:51:48 +020019429 int coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019430
19431 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19432 if (!spec)
19433 return -ENOMEM;
19434
19435 codec->spec = spec;
19436
Kailang Yangda00c242010-03-19 11:23:45 +010019437 alc_auto_parse_customize_define(codec);
19438
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020019439 alc_fix_pll_init(codec, 0x20, 0x04, 15);
19440
Kailang Yang693194f2010-10-21 08:51:48 +020019441 coef = alc_read_coef_idx(codec, 0);
19442 if (coef == 0x8020 || coef == 0x8011)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019443 alc_codec_rename(codec, "ALC661");
Kailang Yang693194f2010-10-21 08:51:48 +020019444 else if (coef & (1 << 14) &&
19445 codec->bus->pci->subsystem_vendor == 0x1025 &&
19446 spec->cdefine.platform_type == 1)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019447 alc_codec_rename(codec, "ALC272X");
Kailang Yang693194f2010-10-21 08:51:48 +020019448 else if (coef == 0x4011)
19449 alc_codec_rename(codec, "ALC656");
Kailang Yang274693f2009-12-03 10:07:50 +010019450
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019451 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
19452 alc662_models,
19453 alc662_cfg_tbl);
19454 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020019455 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19456 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019457 board_config = ALC662_AUTO;
19458 }
19459
19460 if (board_config == ALC662_AUTO) {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019461 alc_pick_fixup(codec, alc662_fixup_models,
19462 alc662_fixup_tbl, alc662_fixups);
19463 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019464 /* automatic parse from the BIOS config */
19465 err = alc662_parse_auto_config(codec);
19466 if (err < 0) {
19467 alc_free(codec);
19468 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020019469 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019470 printk(KERN_INFO
19471 "hda_codec: Cannot set up configuration "
19472 "from BIOS. Using base mode...\n");
19473 board_config = ALC662_3ST_2ch_DIG;
19474 }
19475 }
19476
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019477 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020019478 err = snd_hda_attach_beep_device(codec, 0x1);
19479 if (err < 0) {
19480 alc_free(codec);
19481 return err;
19482 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090019483 }
19484
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019485 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020019486 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019487
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019488 spec->stream_analog_playback = &alc662_pcm_analog_playback;
19489 spec->stream_analog_capture = &alc662_pcm_analog_capture;
19490
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019491 spec->stream_digital_playback = &alc662_pcm_digital_playback;
19492 spec->stream_digital_capture = &alc662_pcm_digital_capture;
19493
Takashi Iwaidd704692009-08-11 08:45:11 +020019494 if (!spec->adc_nids) {
19495 spec->adc_nids = alc662_adc_nids;
19496 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
19497 }
19498 if (!spec->capsrc_nids)
19499 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019500
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019501 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019502 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019503
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019504 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010019505 switch (codec->vendor_id) {
19506 case 0x10ec0662:
19507 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
19508 break;
19509 case 0x10ec0272:
19510 case 0x10ec0663:
19511 case 0x10ec0665:
19512 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
19513 break;
19514 case 0x10ec0273:
19515 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
19516 break;
19517 }
Kailang Yangcec27c82010-02-04 14:18:18 +010019518 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010019519 spec->vmaster_nid = 0x02;
19520
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019521 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
19522
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019523 codec->patch_ops = alc_patch_ops;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019524 if (board_config == ALC662_AUTO)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019525 spec->init_hook = alc662_auto_init;
Takashi Iwai1c716152011-04-07 10:37:16 +020019526 spec->shutup = alc_eapd_shutup;
David Henningsson6cb3b702010-09-09 08:51:44 +020019527
Kailang Yangbf1b0222010-10-21 08:49:56 +020019528 alc_init_jacks(codec);
19529
Takashi Iwaicb53c622007-08-10 17:21:45 +020019530#ifdef CONFIG_SND_HDA_POWER_SAVE
19531 if (!spec->loopback.amplist)
19532 spec->loopback.amplist = alc662_loopbacks;
19533#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019534
19535 return 0;
19536}
19537
Kailang Yang274693f2009-12-03 10:07:50 +010019538static int patch_alc888(struct hda_codec *codec)
19539{
19540 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19541 kfree(codec->chip_name);
Kailang Yang01e0f132010-11-22 10:59:36 +010019542 if (codec->vendor_id == 0x10ec0887)
19543 codec->chip_name = kstrdup("ALC887-VD", GFP_KERNEL);
19544 else
19545 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019546 if (!codec->chip_name) {
19547 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019548 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019549 }
19550 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019551 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019552 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019553}
19554
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019555/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019556 * ALC680 support
19557 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019558#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019559#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19560#define alc680_modes alc260_modes
19561
19562static hda_nid_t alc680_dac_nids[3] = {
19563 /* Lout1, Lout2, hp */
19564 0x02, 0x03, 0x04
19565};
19566
19567static hda_nid_t alc680_adc_nids[3] = {
19568 /* ADC0-2 */
19569 /* DMIC, MIC, Line-in*/
19570 0x07, 0x08, 0x09
19571};
19572
Kailang Yangc69aefa2010-08-17 10:39:22 +020019573/*
19574 * Analog capture ADC cgange
19575 */
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019576static void alc680_rec_autoswitch(struct hda_codec *codec)
19577{
19578 struct alc_spec *spec = codec->spec;
19579 struct auto_pin_cfg *cfg = &spec->autocfg;
19580 int pin_found = 0;
19581 int type_found = AUTO_PIN_LAST;
19582 hda_nid_t nid;
19583 int i;
19584
19585 for (i = 0; i < cfg->num_inputs; i++) {
19586 nid = cfg->inputs[i].pin;
19587 if (!(snd_hda_query_pin_caps(codec, nid) &
19588 AC_PINCAP_PRES_DETECT))
19589 continue;
19590 if (snd_hda_jack_detect(codec, nid)) {
19591 if (cfg->inputs[i].type < type_found) {
19592 type_found = cfg->inputs[i].type;
19593 pin_found = nid;
19594 }
19595 }
19596 }
19597
19598 nid = 0x07;
19599 if (pin_found)
19600 snd_hda_get_connections(codec, pin_found, &nid, 1);
19601
19602 if (nid != spec->cur_adc)
19603 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
19604 spec->cur_adc = nid;
19605 snd_hda_codec_setup_stream(codec, nid, spec->cur_adc_stream_tag, 0,
19606 spec->cur_adc_format);
19607}
19608
Kailang Yangc69aefa2010-08-17 10:39:22 +020019609static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19610 struct hda_codec *codec,
19611 unsigned int stream_tag,
19612 unsigned int format,
19613 struct snd_pcm_substream *substream)
19614{
19615 struct alc_spec *spec = codec->spec;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019616
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019617 spec->cur_adc = 0x07;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019618 spec->cur_adc_stream_tag = stream_tag;
19619 spec->cur_adc_format = format;
19620
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019621 alc680_rec_autoswitch(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019622 return 0;
19623}
19624
19625static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19626 struct hda_codec *codec,
19627 struct snd_pcm_substream *substream)
19628{
19629 snd_hda_codec_cleanup_stream(codec, 0x07);
19630 snd_hda_codec_cleanup_stream(codec, 0x08);
19631 snd_hda_codec_cleanup_stream(codec, 0x09);
19632 return 0;
19633}
19634
19635static struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
19636 .substreams = 1, /* can be overridden */
19637 .channels_min = 2,
19638 .channels_max = 2,
19639 /* NID is set in alc_build_pcms */
19640 .ops = {
19641 .prepare = alc680_capture_pcm_prepare,
19642 .cleanup = alc680_capture_pcm_cleanup
19643 },
19644};
19645
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019646static struct snd_kcontrol_new alc680_base_mixer[] = {
19647 /* output mixer control */
19648 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19649 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19650 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19651 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010019652 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x12, 0, HDA_INPUT),
19653 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
19654 HDA_CODEC_VOLUME("Line In Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019655 { }
19656};
19657
Kailang Yangc69aefa2010-08-17 10:39:22 +020019658static struct hda_bind_ctls alc680_bind_cap_vol = {
19659 .ops = &snd_hda_bind_vol,
19660 .values = {
19661 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19662 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19663 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19664 0
19665 },
19666};
19667
19668static struct hda_bind_ctls alc680_bind_cap_switch = {
19669 .ops = &snd_hda_bind_sw,
19670 .values = {
19671 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19672 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19673 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19674 0
19675 },
19676};
19677
19678static struct snd_kcontrol_new alc680_master_capture_mixer[] = {
19679 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19680 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019681 { } /* end */
19682};
19683
19684/*
19685 * generic initialization of ADC, input mixers and output mixers
19686 */
19687static struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019688 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19689 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19690 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019691
Kailang Yangc69aefa2010-08-17 10:39:22 +020019692 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19693 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19694 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19695 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19696 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19697 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019698
19699 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19700 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19701 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19702 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19703 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019704
19705 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19706 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019707 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019708
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019709 { }
19710};
19711
Kailang Yangc69aefa2010-08-17 10:39:22 +020019712/* toggle speaker-output according to the hp-jack state */
19713static void alc680_base_setup(struct hda_codec *codec)
19714{
19715 struct alc_spec *spec = codec->spec;
19716
19717 spec->autocfg.hp_pins[0] = 0x16;
19718 spec->autocfg.speaker_pins[0] = 0x14;
19719 spec->autocfg.speaker_pins[1] = 0x15;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019720 spec->autocfg.num_inputs = 2;
19721 spec->autocfg.inputs[0].pin = 0x18;
19722 spec->autocfg.inputs[0].type = AUTO_PIN_MIC;
19723 spec->autocfg.inputs[1].pin = 0x19;
Takashi Iwai86e29592010-09-09 14:50:17 +020019724 spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN;
Takashi Iwaid922b512011-04-28 12:18:53 +020019725 spec->automute = 1;
19726 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019727}
19728
19729static void alc680_unsol_event(struct hda_codec *codec,
19730 unsigned int res)
19731{
19732 if ((res >> 26) == ALC880_HP_EVENT)
Takashi Iwaid922b512011-04-28 12:18:53 +020019733 alc_hp_automute(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019734 if ((res >> 26) == ALC880_MIC_EVENT)
19735 alc680_rec_autoswitch(codec);
19736}
19737
19738static void alc680_inithook(struct hda_codec *codec)
19739{
Takashi Iwaid922b512011-04-28 12:18:53 +020019740 alc_hp_automute(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019741 alc680_rec_autoswitch(codec);
19742}
19743
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019744/* create input playback/capture controls for the given pin */
19745static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19746 const char *ctlname, int idx)
19747{
19748 hda_nid_t dac;
19749 int err;
19750
19751 switch (nid) {
19752 case 0x14:
19753 dac = 0x02;
19754 break;
19755 case 0x15:
19756 dac = 0x03;
19757 break;
19758 case 0x16:
19759 dac = 0x04;
19760 break;
19761 default:
19762 return 0;
19763 }
19764 if (spec->multiout.dac_nids[0] != dac &&
19765 spec->multiout.dac_nids[1] != dac) {
19766 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19767 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19768 HDA_OUTPUT));
19769 if (err < 0)
19770 return err;
19771
19772 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19773 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19774
19775 if (err < 0)
19776 return err;
19777 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19778 }
19779
19780 return 0;
19781}
19782
19783/* add playback controls from the parsed DAC table */
19784static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19785 const struct auto_pin_cfg *cfg)
19786{
19787 hda_nid_t nid;
19788 int err;
19789
19790 spec->multiout.dac_nids = spec->private_dac_nids;
19791
19792 nid = cfg->line_out_pins[0];
19793 if (nid) {
19794 const char *name;
19795 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19796 name = "Speaker";
19797 else
19798 name = "Front";
19799 err = alc680_new_analog_output(spec, nid, name, 0);
19800 if (err < 0)
19801 return err;
19802 }
19803
19804 nid = cfg->speaker_pins[0];
19805 if (nid) {
19806 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19807 if (err < 0)
19808 return err;
19809 }
19810 nid = cfg->hp_pins[0];
19811 if (nid) {
19812 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19813 if (err < 0)
19814 return err;
19815 }
19816
19817 return 0;
19818}
19819
19820static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19821 hda_nid_t nid, int pin_type)
19822{
19823 alc_set_pin_output(codec, nid, pin_type);
19824}
19825
19826static void alc680_auto_init_multi_out(struct hda_codec *codec)
19827{
19828 struct alc_spec *spec = codec->spec;
19829 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19830 if (nid) {
19831 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19832 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19833 }
19834}
19835
19836static void alc680_auto_init_hp_out(struct hda_codec *codec)
19837{
19838 struct alc_spec *spec = codec->spec;
19839 hda_nid_t pin;
19840
19841 pin = spec->autocfg.hp_pins[0];
19842 if (pin)
19843 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
19844 pin = spec->autocfg.speaker_pins[0];
19845 if (pin)
19846 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
19847}
19848
19849/* pcm configuration: identical with ALC880 */
19850#define alc680_pcm_analog_playback alc880_pcm_analog_playback
19851#define alc680_pcm_analog_capture alc880_pcm_analog_capture
19852#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
19853#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020019854#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019855
19856/*
19857 * BIOS auto configuration
19858 */
19859static int alc680_parse_auto_config(struct hda_codec *codec)
19860{
19861 struct alc_spec *spec = codec->spec;
19862 int err;
19863 static hda_nid_t alc680_ignore[] = { 0 };
19864
19865 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19866 alc680_ignore);
19867 if (err < 0)
19868 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019869
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019870 if (!spec->autocfg.line_outs) {
19871 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
19872 spec->multiout.max_channels = 2;
19873 spec->no_analog = 1;
19874 goto dig_only;
19875 }
19876 return 0; /* can't find valid BIOS pin config */
19877 }
19878 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
19879 if (err < 0)
19880 return err;
19881
19882 spec->multiout.max_channels = 2;
19883
19884 dig_only:
19885 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020019886 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019887 if (spec->kctls.list)
19888 add_mixer(spec, spec->kctls.list);
19889
19890 add_verb(spec, alc680_init_verbs);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019891
19892 err = alc_auto_add_mic_boost(codec);
19893 if (err < 0)
19894 return err;
19895
19896 return 1;
19897}
19898
19899#define alc680_auto_init_analog_input alc882_auto_init_analog_input
19900
19901/* init callback for auto-configuration model -- overriding the default init */
19902static void alc680_auto_init(struct hda_codec *codec)
19903{
19904 struct alc_spec *spec = codec->spec;
19905 alc680_auto_init_multi_out(codec);
19906 alc680_auto_init_hp_out(codec);
19907 alc680_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019908 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019909 if (spec->unsol_event)
19910 alc_inithook(codec);
19911}
19912
19913/*
19914 * configuration and preset
19915 */
Takashi Iwaiea734962011-01-17 11:29:34 +010019916static const char * const alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020019917 [ALC680_BASE] = "base",
19918 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019919};
19920
19921static struct snd_pci_quirk alc680_cfg_tbl[] = {
19922 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
19923 {}
19924};
19925
19926static struct alc_config_preset alc680_presets[] = {
19927 [ALC680_BASE] = {
19928 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020019929 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019930 .init_verbs = { alc680_init_verbs },
19931 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
19932 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019933 .dig_out_nid = ALC680_DIGOUT_NID,
19934 .num_channel_mode = ARRAY_SIZE(alc680_modes),
19935 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020019936 .unsol_event = alc680_unsol_event,
19937 .setup = alc680_base_setup,
19938 .init_hook = alc680_inithook,
19939
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019940 },
19941};
19942
19943static int patch_alc680(struct hda_codec *codec)
19944{
19945 struct alc_spec *spec;
19946 int board_config;
19947 int err;
19948
19949 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19950 if (spec == NULL)
19951 return -ENOMEM;
19952
19953 codec->spec = spec;
19954
19955 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
19956 alc680_models,
19957 alc680_cfg_tbl);
19958
19959 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
19960 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19961 codec->chip_name);
19962 board_config = ALC680_AUTO;
19963 }
19964
19965 if (board_config == ALC680_AUTO) {
19966 /* automatic parse from the BIOS config */
19967 err = alc680_parse_auto_config(codec);
19968 if (err < 0) {
19969 alc_free(codec);
19970 return err;
19971 } else if (!err) {
19972 printk(KERN_INFO
19973 "hda_codec: Cannot set up configuration "
19974 "from BIOS. Using base mode...\n");
19975 board_config = ALC680_BASE;
19976 }
19977 }
19978
19979 if (board_config != ALC680_AUTO)
19980 setup_preset(codec, &alc680_presets[board_config]);
19981
19982 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019983 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019984 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019985 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019986
19987 if (!spec->adc_nids) {
19988 spec->adc_nids = alc680_adc_nids;
19989 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids);
19990 }
19991
19992 if (!spec->cap_mixer)
19993 set_capture_mixer(codec);
19994
19995 spec->vmaster_nid = 0x02;
19996
19997 codec->patch_ops = alc_patch_ops;
19998 if (board_config == ALC680_AUTO)
19999 spec->init_hook = alc680_auto_init;
20000
20001 return 0;
20002}
20003
20004/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070020005 * patch entries
20006 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010020007static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070020008 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010020009 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010020010 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020020011 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010020012 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010020013 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020020014 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010020015 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020016 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020017 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020018 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
20019 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
20020 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020021 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020022 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020023 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
20024 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020020025 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010020026 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010020027 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020028 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020029 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070020030 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020020031 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020020032 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020033 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020020034 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020035 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010020036 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yang01e0f132010-11-22 10:59:36 +010020037 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc888 },
Kailang Yang44426082008-10-15 11:18:05 +020020038 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020039 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010020040 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020020041 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010020042 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070020043 {} /* terminator */
20044};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010020045
20046MODULE_ALIAS("snd-hda-codec-id:10ec*");
20047
20048MODULE_LICENSE("GPL");
20049MODULE_DESCRIPTION("Realtek HD-audio codec");
20050
20051static struct hda_codec_preset_list realtek_list = {
20052 .preset = snd_hda_preset_realtek,
20053 .owner = THIS_MODULE,
20054};
20055
20056static int __init patch_realtek_init(void)
20057{
20058 return snd_hda_add_codec_preset(&realtek_list);
20059}
20060
20061static void __exit patch_realtek_exit(void)
20062{
20063 snd_hda_delete_codec_preset(&realtek_list);
20064}
20065
20066module_init(patch_realtek_init)
20067module_exit(patch_realtek_exit)