blob: a97e4602741260403366568c55a117d073ed0023 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
Kailang Yang9ad0e492010-09-14 23:22:00 +020031#include <sound/jack.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include "hda_codec.h"
33#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090034#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
Kailang Yangccc656c2006-10-17 12:32:26 +020036#define ALC880_FRONT_EVENT 0x01
37#define ALC880_DCVOL_EVENT 0x02
38#define ALC880_HP_EVENT 0x04
39#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
41/* ALC880 board config type */
42enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 ALC880_3ST,
44 ALC880_3ST_DIG,
45 ALC880_5ST,
46 ALC880_5ST_DIG,
47 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020048 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020049 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020050 ALC880_6ST_DIG,
51 ALC880_F1734,
52 ALC880_ASUS,
53 ALC880_ASUS_DIG,
54 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010055 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010056 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020057 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020058 ALC880_UNIWILL,
59 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010060 ALC880_CLEVO,
61 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010062 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010063 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020064 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020065#ifdef CONFIG_SND_DEBUG
66 ALC880_TEST,
67#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010068 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020069 ALC880_MODEL_LAST /* last tag */
70};
71
72/* ALC260 models */
73enum {
74 ALC260_BASIC,
75 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020076 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010077 ALC260_HP_3013,
78 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010079 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020080 ALC260_WILL,
81 ALC260_REPLACER_672V,
Michael Schwingencc959482009-02-22 18:58:45 +010082 ALC260_FAVORIT100,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010083#ifdef CONFIG_SND_DEBUG
84 ALC260_TEST,
85#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010086 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020087 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070088};
89
Kailang Yangdf694da2005-12-05 19:42:22 +010090/* ALC262 models */
91enum {
92 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020093 ALC262_HIPPO,
94 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010095 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020096 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010097 ALC262_HP_BPC_D7000_WL,
98 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010099 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +0100100 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +0200101 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200102 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200103 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200104 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100105 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200106 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200107 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200108 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000109 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100110 ALC262_AUTO,
111 ALC262_MODEL_LAST /* last tag */
112};
113
Kailang Yanga361d842007-06-05 12:30:55 +0200114/* ALC268 models */
115enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200116 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200117 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200118 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200119 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100120 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200121 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100122 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100123 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100124#ifdef CONFIG_SND_DEBUG
125 ALC268_TEST,
126#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200127 ALC268_AUTO,
128 ALC268_MODEL_LAST /* last tag */
129};
130
Kailang Yangf6a92242007-12-13 16:52:54 +0100131/* ALC269 models */
132enum {
133 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200134 ALC269_QUANTA_FL1,
Kailang Yang84898e82010-02-04 14:16:14 +0100135 ALC269_AMIC,
136 ALC269_DMIC,
137 ALC269VB_AMIC,
138 ALC269VB_DMIC,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100139 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000140 ALC269_LIFEBOOK,
Kailang Yangfe3eb0a2010-08-06 10:02:57 +0200141 ALC271_ACER,
Kailang Yangf6a92242007-12-13 16:52:54 +0100142 ALC269_AUTO,
143 ALC269_MODEL_LAST /* last tag */
144};
145
Kailang Yangdf694da2005-12-05 19:42:22 +0100146/* ALC861 models */
147enum {
148 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200149 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100150 ALC861_3ST_DIG,
151 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200152 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200153 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200154 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100155 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100156 ALC861_AUTO,
157 ALC861_MODEL_LAST,
158};
159
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100160/* ALC861-VD models */
161enum {
162 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200163 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100164 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100165 ALC861VD_3ST,
166 ALC861VD_3ST_DIG,
167 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200168 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200169 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200170 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100171 ALC861VD_AUTO,
172 ALC861VD_MODEL_LAST,
173};
174
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200175/* ALC662 models */
176enum {
177 ALC662_3ST_2ch_DIG,
178 ALC662_3ST_6ch_DIG,
179 ALC662_3ST_6ch,
180 ALC662_5ST_DIG,
181 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200182 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100183 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200184 ALC663_ASUS_M51VA,
185 ALC663_ASUS_G71V,
186 ALC663_ASUS_H13,
187 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200188 ALC662_ECS,
189 ALC663_ASUS_MODE1,
190 ALC662_ASUS_MODE2,
191 ALC663_ASUS_MODE3,
192 ALC663_ASUS_MODE4,
193 ALC663_ASUS_MODE5,
194 ALC663_ASUS_MODE6,
Kailang Yangebb83ee2009-12-17 12:23:00 +0100195 ALC663_ASUS_MODE7,
196 ALC663_ASUS_MODE8,
Kailang Yang622e84c2009-04-21 07:39:04 +0200197 ALC272_DELL,
198 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200199 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200200 ALC662_AUTO,
201 ALC662_MODEL_LAST,
202};
203
Kailang Yangdf694da2005-12-05 19:42:22 +0100204/* ALC882 models */
205enum {
206 ALC882_3ST_DIG,
207 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200208 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200209 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200210 ALC882_TARGA,
211 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200212 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100213 ALC885_MACPRO,
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -0800214 ALC885_MBA21,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200215 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200216 ALC885_MB5,
Luke Yelaviche458b1f2010-02-12 16:28:29 +1100217 ALC885_MACMINI3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200218 ALC885_IMAC24,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -0800219 ALC885_IMAC91,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200220 ALC883_3ST_2ch_DIG,
221 ALC883_3ST_6ch_DIG,
222 ALC883_3ST_6ch,
223 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200224 ALC883_TARGA_DIG,
225 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200226 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200227 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200228 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800229 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100230 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200231 ALC888_ACER_ASPIRE_8930G,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200232 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200233 ALC883_MEDION,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +0200234 ALC883_MEDION_WIM2160,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100235 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200236 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200237 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200238 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200239 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200240 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200241 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100242 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100243 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430244 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100245 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100246 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800247 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200248 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200249 ALC889A_INTEL,
250 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200251 ALC888_ASUS_M90V,
252 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200253 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100254 ALC1200_ASUS_P5Q,
Guido Günther3e1647c52009-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 Iwai1c7161532011-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 */
393 unsigned int sense_updated: 1;
394 unsigned int jack_present: 1;
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +0200395 unsigned int line_jack_present:1;
Takashi Iwaie9427962011-04-28 15:46:07 +0200396 unsigned int master_mute:1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200397 unsigned int auto_mic:1;
Takashi Iwaid922b512011-04-28 12:18:53 +0200398 unsigned int automute:1; /* HP automute enabled */
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +0200399 unsigned int detect_line:1; /* Line-out detection enabled */
400 unsigned int automute_lines:1; /* automute line-out as well */
Takashi Iwaicb53c622007-08-10 17:21:45 +0200401
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100402 /* other flags */
403 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai840b64c2010-07-13 22:49:01 +0200404 unsigned int dual_adc_switch:1; /* switch ADCs (for ALC275) */
Takashi Iwai584c0c42011-03-10 12:51:11 +0100405 unsigned int single_input_src:1;
Takashi Iwaid922b512011-04-28 12:18:53 +0200406
407 /* auto-mute control */
408 int automute_mode;
Takashi Iwai3b8510c2011-04-28 14:03:24 +0200409 hda_nid_t automute_mixer_nid[AUTO_CFG_MAX_OUTS];
Takashi Iwaid922b512011-04-28 12:18:53 +0200410
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200411 int init_amp;
Takashi Iwaid433a672010-09-20 15:11:54 +0200412 int codec_variant; /* flag for other variants */
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100413
Takashi Iwai2134ea42008-01-10 16:53:55 +0100414 /* for virtual master */
415 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200416#ifdef CONFIG_SND_HDA_POWER_SAVE
417 struct hda_loopback_check loopback;
418#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200419
420 /* for PLL fix */
421 hda_nid_t pll_nid;
422 unsigned int pll_coef_idx, pll_coef_bit;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +0100423
424 /* fix-up list */
425 int fixup_id;
426 const struct alc_fixup *fixup_list;
427 const char *fixup_name;
Takashi Iwaice764ab2011-04-27 16:35:23 +0200428
429 /* multi-io */
430 int multi_ios;
431 struct alc_multi_io multi_io[4];
Kailang Yangdf694da2005-12-05 19:42:22 +0100432};
433
434/*
435 * configuration template - to be copied to the spec instance
436 */
437struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200438 struct snd_kcontrol_new *mixers[5]; /* should be identical size
439 * with spec
440 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100441 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100442 const struct hda_verb *init_verbs[5];
443 unsigned int num_dacs;
444 hda_nid_t *dac_nids;
445 hda_nid_t dig_out_nid; /* optional */
446 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800447 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100448 unsigned int num_adc_nids;
449 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100450 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100451 hda_nid_t dig_in_nid;
452 unsigned int num_channel_mode;
453 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200454 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200455 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200456 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100457 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100458 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200459 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100460 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200461#ifdef CONFIG_SND_HDA_POWER_SAVE
462 struct hda_amp_list *loopbacks;
Daniel T Chenc97259d2009-12-27 18:52:08 -0500463 void (*power_hook)(struct hda_codec *codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200464#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465};
466
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467
468/*
469 * input MUX handling
470 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200471static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
472 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473{
474 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
475 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200476 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
477 if (mux_idx >= spec->num_mux_defs)
478 mux_idx = 0;
Takashi Iwai53111142010-03-08 12:13:07 +0100479 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
480 mux_idx = 0;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200481 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482}
483
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200484static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
485 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486{
487 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
488 struct alc_spec *spec = codec->spec;
489 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
490
491 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
492 return 0;
493}
494
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200495static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
496 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497{
498 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
499 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100500 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100502 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100503 hda_nid_t nid = spec->capsrc_nids ?
504 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200505 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506
Takashi Iwaicd896c32008-11-18 12:36:33 +0100507 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
508 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +0100509 if (!imux->num_items && mux_idx > 0)
510 imux = &spec->input_mux[0];
Takashi Iwaicd896c32008-11-18 12:36:33 +0100511
Takashi Iwaia22d5432009-07-27 12:54:26 +0200512 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200513 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100514 /* Matrix-mixer style (e.g. ALC882) */
515 unsigned int *cur_val = &spec->cur_mux[adc_idx];
516 unsigned int i, idx;
517
518 idx = ucontrol->value.enumerated.item[0];
519 if (idx >= imux->num_items)
520 idx = imux->num_items - 1;
521 if (*cur_val == idx)
522 return 0;
523 for (i = 0; i < imux->num_items; i++) {
524 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
525 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
526 imux->items[i].index,
527 HDA_AMP_MUTE, v);
528 }
529 *cur_val = idx;
530 return 1;
531 } else {
532 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100533 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100534 &spec->cur_mux[adc_idx]);
535 }
536}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200537
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538/*
539 * channel mode setting
540 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200541static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
542 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543{
544 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
545 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100546 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
547 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548}
549
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200550static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
551 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552{
553 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
554 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100555 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200556 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200557 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558}
559
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200560static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
561 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562{
563 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
564 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200565 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
566 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200567 &spec->ext_channel_count);
568 if (err >= 0 && !spec->const_channel_count) {
569 spec->multiout.max_channels = spec->ext_channel_count;
570 if (spec->need_dac_fix)
571 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
572 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200573 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574}
575
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100577 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200578 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100579 * being part of a format specifier. Maximum allowed length of a value is
580 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100581 *
582 * Note: some retasking pin complexes seem to ignore requests for input
583 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
584 * are requested. Therefore order this list so that this behaviour will not
585 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200586 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
587 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200588 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100589static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100590 "Mic 50pc bias", "Mic 80pc bias",
591 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100592};
593static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100594 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100595};
596/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200597 * in the pin being assumed to be exclusively an input or an output pin. In
598 * addition, "input" pins may or may not process the mic bias option
599 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
600 * accept requests for bias as of chip versions up to March 2006) and/or
601 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100602 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200603#define ALC_PIN_DIR_IN 0x00
604#define ALC_PIN_DIR_OUT 0x01
605#define ALC_PIN_DIR_INOUT 0x02
606#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
607#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100608
Kailang Yangea1fb292008-08-26 12:58:38 +0200609/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100610 * For each direction the minimum and maximum values are given.
611 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200612static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100613 { 0, 2 }, /* ALC_PIN_DIR_IN */
614 { 3, 4 }, /* ALC_PIN_DIR_OUT */
615 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200616 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
617 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100618};
619#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
620#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
621#define alc_pin_mode_n_items(_dir) \
622 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
623
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200624static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
625 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200626{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100627 unsigned int item_num = uinfo->value.enumerated.item;
628 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
629
630 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200631 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100632 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
633
634 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
635 item_num = alc_pin_mode_min(dir);
636 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200637 return 0;
638}
639
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200640static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
641 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200642{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100643 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200644 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
645 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100646 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200647 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200648 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
649 AC_VERB_GET_PIN_WIDGET_CONTROL,
650 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200651
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100652 /* Find enumerated value for current pinctl setting */
653 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200654 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100655 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200656 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100657 return 0;
658}
659
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200660static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
661 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100662{
663 signed int change;
664 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
665 hda_nid_t nid = kcontrol->private_value & 0xffff;
666 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
667 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200668 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
669 AC_VERB_GET_PIN_WIDGET_CONTROL,
670 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100671
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200672 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100673 val = alc_pin_mode_min(dir);
674
675 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100676 if (change) {
677 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200678 snd_hda_codec_write_cache(codec, nid, 0,
679 AC_VERB_SET_PIN_WIDGET_CONTROL,
680 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100681
Kailang Yangea1fb292008-08-26 12:58:38 +0200682 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100683 * for the requested pin mode. Enum values of 2 or less are
684 * input modes.
685 *
686 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200687 * reduces noise slightly (particularly on input) so we'll
688 * do it. However, having both input and output buffers
689 * enabled simultaneously doesn't seem to be problematic if
690 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100691 */
692 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200693 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
694 HDA_AMP_MUTE, HDA_AMP_MUTE);
695 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
696 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100697 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200698 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
699 HDA_AMP_MUTE, HDA_AMP_MUTE);
700 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
701 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100702 }
703 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200704 return change;
705}
706
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100707#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200708 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100709 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100710 .info = alc_pin_mode_info, \
711 .get = alc_pin_mode_get, \
712 .put = alc_pin_mode_put, \
713 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100714
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100715/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
716 * together using a mask with more than one bit set. This control is
717 * currently used only by the ALC260 test model. At this stage they are not
718 * needed for any "production" models.
719 */
720#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200721#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200722
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200723static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
724 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100725{
726 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
727 hda_nid_t nid = kcontrol->private_value & 0xffff;
728 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
729 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200730 unsigned int val = snd_hda_codec_read(codec, nid, 0,
731 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100732
733 *valp = (val & mask) != 0;
734 return 0;
735}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200736static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
737 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100738{
739 signed int change;
740 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
741 hda_nid_t nid = kcontrol->private_value & 0xffff;
742 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
743 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200744 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
745 AC_VERB_GET_GPIO_DATA,
746 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100747
748 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200749 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
750 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100751 gpio_data &= ~mask;
752 else
753 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200754 snd_hda_codec_write_cache(codec, nid, 0,
755 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100756
757 return change;
758}
759#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
760 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100761 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100762 .info = alc_gpio_data_info, \
763 .get = alc_gpio_data_get, \
764 .put = alc_gpio_data_put, \
765 .private_value = nid | (mask<<16) }
766#endif /* CONFIG_SND_DEBUG */
767
Jonathan Woithe92621f12006-02-28 11:47:47 +0100768/* A switch control to allow the enabling of the digital IO pins on the
769 * ALC260. This is incredibly simplistic; the intention of this control is
770 * to provide something in the test model allowing digital outputs to be
771 * identified if present. If models are found which can utilise these
772 * outputs a more complete mixer control can be devised for those models if
773 * necessary.
774 */
775#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200776#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200777
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200778static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
779 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100780{
781 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
782 hda_nid_t nid = kcontrol->private_value & 0xffff;
783 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
784 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200785 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100786 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100787
788 *valp = (val & mask) != 0;
789 return 0;
790}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200791static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
792 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100793{
794 signed int change;
795 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
796 hda_nid_t nid = kcontrol->private_value & 0xffff;
797 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
798 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200799 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100800 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200801 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100802
803 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200804 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100805 if (val==0)
806 ctrl_data &= ~mask;
807 else
808 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200809 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
810 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100811
812 return change;
813}
814#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
815 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100816 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100817 .info = alc_spdif_ctrl_info, \
818 .get = alc_spdif_ctrl_get, \
819 .put = alc_spdif_ctrl_put, \
820 .private_value = nid | (mask<<16) }
821#endif /* CONFIG_SND_DEBUG */
822
Jonathan Woithef8225f62008-01-08 12:16:54 +0100823/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
824 * Again, this is only used in the ALC26x test models to help identify when
825 * the EAPD line must be asserted for features to work.
826 */
827#ifdef CONFIG_SND_DEBUG
828#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
829
830static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
831 struct snd_ctl_elem_value *ucontrol)
832{
833 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
834 hda_nid_t nid = kcontrol->private_value & 0xffff;
835 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
836 long *valp = ucontrol->value.integer.value;
837 unsigned int val = snd_hda_codec_read(codec, nid, 0,
838 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
839
840 *valp = (val & mask) != 0;
841 return 0;
842}
843
844static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
845 struct snd_ctl_elem_value *ucontrol)
846{
847 int change;
848 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
849 hda_nid_t nid = kcontrol->private_value & 0xffff;
850 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
851 long val = *ucontrol->value.integer.value;
852 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
853 AC_VERB_GET_EAPD_BTLENABLE,
854 0x00);
855
856 /* Set/unset the masked control bit(s) as needed */
857 change = (!val ? 0 : mask) != (ctrl_data & mask);
858 if (!val)
859 ctrl_data &= ~mask;
860 else
861 ctrl_data |= mask;
862 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
863 ctrl_data);
864
865 return change;
866}
867
868#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
869 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100870 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100871 .info = alc_eapd_ctrl_info, \
872 .get = alc_eapd_ctrl_get, \
873 .put = alc_eapd_ctrl_put, \
874 .private_value = nid | (mask<<16) }
875#endif /* CONFIG_SND_DEBUG */
876
Kailang Yangdf694da2005-12-05 19:42:22 +0100877/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100878 * set up the input pin config (depending on the given auto-pin type)
879 */
880static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
881 int auto_pin_type)
882{
883 unsigned int val = PIN_IN;
884
Takashi Iwai86e29592010-09-09 14:50:17 +0200885 if (auto_pin_type == AUTO_PIN_MIC) {
Takashi Iwai23f0c042009-02-26 13:03:58 +0100886 unsigned int pincap;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200887 unsigned int oldval;
888 oldval = snd_hda_codec_read(codec, nid, 0,
889 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Takashi Iwai1327a322009-03-23 13:07:47 +0100890 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100891 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200892 /* if the default pin setup is vref50, we give it priority */
893 if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50)
Takashi Iwai23f0c042009-02-26 13:03:58 +0100894 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200895 else if (pincap & AC_PINCAP_VREF_50)
896 val = PIN_VREF50;
897 else if (pincap & AC_PINCAP_VREF_100)
898 val = PIN_VREF100;
899 else if (pincap & AC_PINCAP_VREF_GRD)
900 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100901 }
902 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
903}
904
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200905static void alc_fixup_autocfg_pin_nums(struct hda_codec *codec)
906{
907 struct alc_spec *spec = codec->spec;
908 struct auto_pin_cfg *cfg = &spec->autocfg;
909
910 if (!cfg->line_outs) {
911 while (cfg->line_outs < AUTO_CFG_MAX_OUTS &&
912 cfg->line_out_pins[cfg->line_outs])
913 cfg->line_outs++;
914 }
915 if (!cfg->speaker_outs) {
916 while (cfg->speaker_outs < AUTO_CFG_MAX_OUTS &&
917 cfg->speaker_pins[cfg->speaker_outs])
918 cfg->speaker_outs++;
919 }
920 if (!cfg->hp_outs) {
921 while (cfg->hp_outs < AUTO_CFG_MAX_OUTS &&
922 cfg->hp_pins[cfg->hp_outs])
923 cfg->hp_outs++;
924 }
925}
926
Takashi Iwai23f0c042009-02-26 13:03:58 +0100927/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100928 */
929static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
930{
931 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
932 return;
933 spec->mixers[spec->num_mixers++] = mix;
934}
935
936static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
937{
938 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
939 return;
940 spec->init_verbs[spec->num_init_verbs++] = verb;
941}
942
943/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100944 * set up from the preset table
945 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200946static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200947 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100948{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200949 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100950 int i;
951
952 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100953 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100954 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200955 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
956 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100957 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200958
Kailang Yangdf694da2005-12-05 19:42:22 +0100959 spec->channel_mode = preset->channel_mode;
960 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200961 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200962 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100963
Hector Martin3b315d72009-06-02 10:54:19 +0200964 if (preset->const_channel_count)
965 spec->multiout.max_channels = preset->const_channel_count;
966 else
967 spec->multiout.max_channels = spec->channel_mode[0].channels;
968 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100969
970 spec->multiout.num_dacs = preset->num_dacs;
971 spec->multiout.dac_nids = preset->dac_nids;
972 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800973 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100974 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200975
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200976 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200977 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200978 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100979 spec->input_mux = preset->input_mux;
980
981 spec->num_adc_nids = preset->num_adc_nids;
982 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100983 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100984 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100985
986 spec->unsol_event = preset->unsol_event;
987 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200988#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100989 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200990 spec->loopback.amplist = preset->loopbacks;
991#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200992
993 if (preset->setup)
994 preset->setup(codec);
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200995
996 alc_fixup_autocfg_pin_nums(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100997}
998
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200999/* Enable GPIO mask and set output */
1000static struct hda_verb alc_gpio1_init_verbs[] = {
1001 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
1002 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1003 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
1004 { }
1005};
1006
1007static struct hda_verb alc_gpio2_init_verbs[] = {
1008 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1009 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1010 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
1011 { }
1012};
1013
Kailang Yangbdd148a2007-05-08 15:19:08 +02001014static struct hda_verb alc_gpio3_init_verbs[] = {
1015 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
1016 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
1017 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
1018 { }
1019};
1020
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02001021/*
1022 * Fix hardware PLL issue
1023 * On some codecs, the analog PLL gating control must be off while
1024 * the default value is 1.
1025 */
1026static void alc_fix_pll(struct hda_codec *codec)
1027{
1028 struct alc_spec *spec = codec->spec;
1029 unsigned int val;
1030
1031 if (!spec->pll_nid)
1032 return;
1033 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1034 spec->pll_coef_idx);
1035 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
1036 AC_VERB_GET_PROC_COEF, 0);
1037 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1038 spec->pll_coef_idx);
1039 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
1040 val & ~(1 << spec->pll_coef_bit));
1041}
1042
1043static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
1044 unsigned int coef_idx, unsigned int coef_bit)
1045{
1046 struct alc_spec *spec = codec->spec;
1047 spec->pll_nid = nid;
1048 spec->pll_coef_idx = coef_idx;
1049 spec->pll_coef_bit = coef_bit;
1050 alc_fix_pll(codec);
1051}
1052
Kailang Yang9ad0e492010-09-14 23:22:00 +02001053static int alc_init_jacks(struct hda_codec *codec)
1054{
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001055#ifdef CONFIG_SND_HDA_INPUT_JACK
Kailang Yang9ad0e492010-09-14 23:22:00 +02001056 struct alc_spec *spec = codec->spec;
1057 int err;
1058 unsigned int hp_nid = spec->autocfg.hp_pins[0];
1059 unsigned int mic_nid = spec->ext_mic.pin;
1060
Takashi Iwai265a0242010-09-21 11:26:21 +02001061 if (hp_nid) {
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001062 err = snd_hda_input_jack_add(codec, hp_nid,
1063 SND_JACK_HEADPHONE, NULL);
Takashi Iwai265a0242010-09-21 11:26:21 +02001064 if (err < 0)
1065 return err;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001066 snd_hda_input_jack_report(codec, hp_nid);
Takashi Iwai265a0242010-09-21 11:26:21 +02001067 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001068
Takashi Iwai265a0242010-09-21 11:26:21 +02001069 if (mic_nid) {
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001070 err = snd_hda_input_jack_add(codec, mic_nid,
1071 SND_JACK_MICROPHONE, NULL);
Takashi Iwai265a0242010-09-21 11:26:21 +02001072 if (err < 0)
1073 return err;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001074 snd_hda_input_jack_report(codec, mic_nid);
Takashi Iwai265a0242010-09-21 11:26:21 +02001075 }
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001076#endif /* CONFIG_SND_HDA_INPUT_JACK */
Kailang Yang9ad0e492010-09-14 23:22:00 +02001077 return 0;
1078}
Kailang Yang9ad0e492010-09-14 23:22:00 +02001079
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001080static int detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins)
Kailang Yangc9b58002007-10-16 14:30:01 +02001081{
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001082 int i, present = 0;
Kailang Yangc9b58002007-10-16 14:30:01 +02001083
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001084 for (i = 0; i < num_pins; i++) {
1085 hda_nid_t nid = pins[i];
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001086 if (!nid)
1087 break;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001088 snd_hda_input_jack_report(codec, nid);
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001089 present |= snd_hda_jack_detect(codec, nid);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001090 }
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001091 return present;
1092}
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001093
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001094static void do_automute(struct hda_codec *codec, int num_pins, hda_nid_t *pins,
Takashi Iwaie9427962011-04-28 15:46:07 +02001095 bool mute, bool hp_out)
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001096{
1097 struct alc_spec *spec = codec->spec;
1098 unsigned int mute_bits = mute ? HDA_AMP_MUTE : 0;
Takashi Iwaie9427962011-04-28 15:46:07 +02001099 unsigned int pin_bits = mute ? 0 : (hp_out ? PIN_HP : PIN_OUT);
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001100 int i;
1101
1102 for (i = 0; i < num_pins; i++) {
1103 hda_nid_t nid = pins[i];
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001104 if (!nid)
1105 break;
Takashi Iwai3b8510c2011-04-28 14:03:24 +02001106 switch (spec->automute_mode) {
1107 case ALC_AUTOMUTE_PIN:
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001108 snd_hda_codec_write(codec, nid, 0,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001109 AC_VERB_SET_PIN_WIDGET_CONTROL,
1110 pin_bits);
Takashi Iwai3b8510c2011-04-28 14:03:24 +02001111 break;
1112 case ALC_AUTOMUTE_AMP:
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001113 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001114 HDA_AMP_MUTE, mute_bits);
Takashi Iwai3b8510c2011-04-28 14:03:24 +02001115 break;
1116 case ALC_AUTOMUTE_MIXER:
1117 nid = spec->automute_mixer_nid[i];
1118 if (!nid)
1119 break;
1120 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001121 HDA_AMP_MUTE, mute_bits);
Takashi Iwai3b8510c2011-04-28 14:03:24 +02001122 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 1,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001123 HDA_AMP_MUTE, mute_bits);
Takashi Iwai3b8510c2011-04-28 14:03:24 +02001124 break;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001125 }
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001126 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001127}
1128
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001129/* Toggle internal speakers muting */
1130static void update_speakers(struct hda_codec *codec)
1131{
1132 struct alc_spec *spec = codec->spec;
1133
1134 do_automute(codec, ARRAY_SIZE(spec->autocfg.speaker_pins),
1135 spec->autocfg.speaker_pins,
Takashi Iwaie9427962011-04-28 15:46:07 +02001136 spec->jack_present | spec->line_jack_present |
1137 spec->master_mute, false);
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001138
1139 /* toggle line-out mutes if needed, too */
1140 if (!spec->automute_lines)
1141 return;
1142 do_automute(codec, ARRAY_SIZE(spec->autocfg.line_out_pins),
1143 spec->autocfg.line_out_pins,
Takashi Iwaie9427962011-04-28 15:46:07 +02001144 spec->jack_present | spec->master_mute, false);
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001145}
1146
1147static void alc_hp_automute(struct hda_codec *codec)
1148{
1149 struct alc_spec *spec = codec->spec;
1150
1151 if (!spec->automute)
1152 return;
1153 spec->jack_present =
1154 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.hp_pins),
1155 spec->autocfg.hp_pins);
1156 update_speakers(codec);
1157}
1158
1159static void alc_line_automute(struct hda_codec *codec)
1160{
1161 struct alc_spec *spec = codec->spec;
1162
1163 if (!spec->automute || !spec->detect_line)
1164 return;
1165 spec->line_jack_present =
1166 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.line_out_pins),
1167 spec->autocfg.line_out_pins);
1168 update_speakers(codec);
1169}
1170
Takashi Iwai6c819492009-08-10 18:47:44 +02001171static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1172 hda_nid_t nid)
1173{
1174 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1175 int i, nums;
1176
1177 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1178 for (i = 0; i < nums; i++)
1179 if (conn[i] == nid)
1180 return i;
1181 return -1;
1182}
1183
Takashi Iwai840b64c2010-07-13 22:49:01 +02001184/* switch the current ADC according to the jack state */
1185static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1186{
1187 struct alc_spec *spec = codec->spec;
1188 unsigned int present;
1189 hda_nid_t new_adc;
1190
1191 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1192 if (present)
1193 spec->cur_adc_idx = 1;
1194 else
1195 spec->cur_adc_idx = 0;
1196 new_adc = spec->adc_nids[spec->cur_adc_idx];
1197 if (spec->cur_adc && spec->cur_adc != new_adc) {
1198 /* stream is running, let's swap the current ADC */
Takashi Iwaif0cea792010-08-13 11:56:53 +02001199 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
Takashi Iwai840b64c2010-07-13 22:49:01 +02001200 spec->cur_adc = new_adc;
1201 snd_hda_codec_setup_stream(codec, new_adc,
1202 spec->cur_adc_stream_tag, 0,
1203 spec->cur_adc_format);
1204 }
1205}
1206
Kailang Yang7fb0d782008-10-15 11:12:35 +02001207static void alc_mic_automute(struct hda_codec *codec)
1208{
1209 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001210 struct alc_mic_route *dead, *alive;
1211 unsigned int present, type;
1212 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001213
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001214 if (!spec->auto_mic)
1215 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001216 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1217 return;
1218 if (snd_BUG_ON(!spec->adc_nids))
1219 return;
1220
Takashi Iwai840b64c2010-07-13 22:49:01 +02001221 if (spec->dual_adc_switch) {
1222 alc_dual_mic_adc_auto_switch(codec);
1223 return;
1224 }
1225
Takashi Iwai6c819492009-08-10 18:47:44 +02001226 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1227
Wu Fengguang864f92b2009-11-18 12:38:02 +08001228 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001229 if (present) {
1230 alive = &spec->ext_mic;
1231 dead = &spec->int_mic;
1232 } else {
1233 alive = &spec->int_mic;
1234 dead = &spec->ext_mic;
1235 }
1236
Takashi Iwai6c819492009-08-10 18:47:44 +02001237 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1238 if (type == AC_WID_AUD_MIX) {
1239 /* Matrix-mixer style (e.g. ALC882) */
1240 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1241 alive->mux_idx,
1242 HDA_AMP_MUTE, 0);
1243 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1244 dead->mux_idx,
1245 HDA_AMP_MUTE, HDA_AMP_MUTE);
1246 } else {
1247 /* MUX style (e.g. ALC880) */
1248 snd_hda_codec_write_cache(codec, cap_nid, 0,
1249 AC_VERB_SET_CONNECT_SEL,
1250 alive->mux_idx);
1251 }
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001252 snd_hda_input_jack_report(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001253
1254 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001255}
1256
Kailang Yangc9b58002007-10-16 14:30:01 +02001257/* unsolicited event for HP jack sensing */
1258static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1259{
1260 if (codec->vendor_id == 0x10ec0880)
1261 res >>= 28;
1262 else
1263 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001264 switch (res) {
1265 case ALC880_HP_EVENT:
Takashi Iwaid922b512011-04-28 12:18:53 +02001266 alc_hp_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001267 break;
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001268 case ALC880_FRONT_EVENT:
1269 alc_line_automute(codec);
1270 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001271 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001272 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001273 break;
1274 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001275}
1276
1277static void alc_inithook(struct hda_codec *codec)
1278{
Takashi Iwaid922b512011-04-28 12:18:53 +02001279 alc_hp_automute(codec);
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001280 alc_line_automute(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001281 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001282}
1283
Kailang Yangf9423e72008-05-27 12:32:25 +02001284/* additional initialization for ALC888 variants */
1285static void alc888_coef_init(struct hda_codec *codec)
1286{
1287 unsigned int tmp;
1288
1289 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1290 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1291 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001292 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001293 /* alc888S-VC */
1294 snd_hda_codec_read(codec, 0x20, 0,
1295 AC_VERB_SET_PROC_COEF, 0x830);
1296 else
1297 /* alc888-VB */
1298 snd_hda_codec_read(codec, 0x20, 0,
1299 AC_VERB_SET_PROC_COEF, 0x3030);
1300}
1301
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001302static void alc889_coef_init(struct hda_codec *codec)
1303{
1304 unsigned int tmp;
1305
1306 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1307 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1308 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1309 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1310}
1311
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001312/* turn on/off EAPD control (only if available) */
1313static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1314{
1315 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1316 return;
1317 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1318 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1319 on ? 2 : 0);
1320}
1321
Takashi Iwai691f1fc2011-04-07 10:31:43 +02001322/* turn on/off EAPD controls of the codec */
1323static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
1324{
1325 /* We currently only handle front, HP */
1326 switch (codec->vendor_id) {
1327 case 0x10ec0260:
1328 set_eapd(codec, 0x0f, on);
1329 set_eapd(codec, 0x10, on);
1330 break;
1331 case 0x10ec0262:
1332 case 0x10ec0267:
1333 case 0x10ec0268:
1334 case 0x10ec0269:
1335 case 0x10ec0270:
1336 case 0x10ec0272:
1337 case 0x10ec0660:
1338 case 0x10ec0662:
1339 case 0x10ec0663:
1340 case 0x10ec0665:
1341 case 0x10ec0862:
1342 case 0x10ec0889:
1343 case 0x10ec0892:
1344 set_eapd(codec, 0x14, on);
1345 set_eapd(codec, 0x15, on);
1346 break;
1347 }
1348}
1349
Takashi Iwai1c7161532011-04-07 10:37:16 +02001350/* generic shutup callback;
1351 * just turning off EPAD and a little pause for avoiding pop-noise
1352 */
1353static void alc_eapd_shutup(struct hda_codec *codec)
1354{
1355 alc_auto_setup_eapd(codec, false);
1356 msleep(200);
1357}
1358
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001359static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001360{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001361 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001362
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001363 switch (type) {
1364 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001365 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1366 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001367 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001368 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1369 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001370 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001371 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1372 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001373 case ALC_INIT_DEFAULT:
Takashi Iwai691f1fc2011-04-07 10:31:43 +02001374 alc_auto_setup_eapd(codec, true);
Kailang Yangc9b58002007-10-16 14:30:01 +02001375 switch (codec->vendor_id) {
1376 case 0x10ec0260:
1377 snd_hda_codec_write(codec, 0x1a, 0,
1378 AC_VERB_SET_COEF_INDEX, 7);
1379 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1380 AC_VERB_GET_PROC_COEF, 0);
1381 snd_hda_codec_write(codec, 0x1a, 0,
1382 AC_VERB_SET_COEF_INDEX, 7);
1383 snd_hda_codec_write(codec, 0x1a, 0,
1384 AC_VERB_SET_PROC_COEF,
1385 tmp | 0x2010);
1386 break;
1387 case 0x10ec0262:
1388 case 0x10ec0880:
1389 case 0x10ec0882:
1390 case 0x10ec0883:
1391 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001392 case 0x10ec0887:
Takashi Iwai20b67dd2011-03-23 22:54:32 +01001393 /*case 0x10ec0889:*/ /* this causes an SPDIF problem */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001394 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001395 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001396 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001397 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001398 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001399#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001400 case 0x10ec0267:
1401 case 0x10ec0268:
1402 snd_hda_codec_write(codec, 0x20, 0,
1403 AC_VERB_SET_COEF_INDEX, 7);
1404 tmp = snd_hda_codec_read(codec, 0x20, 0,
1405 AC_VERB_GET_PROC_COEF, 0);
1406 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001407 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001408 snd_hda_codec_write(codec, 0x20, 0,
1409 AC_VERB_SET_PROC_COEF,
1410 tmp | 0x3000);
1411 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001412#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001413 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001414 break;
1415 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001416}
Kailang Yangea1fb292008-08-26 12:58:38 +02001417
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001418static void alc_init_auto_hp(struct hda_codec *codec)
1419{
1420 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001421 struct auto_pin_cfg *cfg = &spec->autocfg;
1422 int i;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001423
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001424 if (!cfg->hp_pins[0]) {
1425 if (cfg->line_out_type != AUTO_PIN_HP_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001426 return;
1427 }
1428
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001429 if (!cfg->speaker_pins[0]) {
1430 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT)
1431 return;
1432 memcpy(cfg->speaker_pins, cfg->line_out_pins,
1433 sizeof(cfg->speaker_pins));
1434 cfg->speaker_outs = cfg->line_outs;
1435 }
1436
1437 if (!cfg->hp_pins[0]) {
1438 memcpy(cfg->hp_pins, cfg->line_out_pins,
1439 sizeof(cfg->hp_pins));
1440 cfg->hp_outs = cfg->line_outs;
1441 }
1442
1443 for (i = 0; i < cfg->hp_outs; i++) {
1444 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1445 cfg->hp_pins[i]);
1446 snd_hda_codec_write_cache(codec, cfg->hp_pins[i], 0,
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001447 AC_VERB_SET_UNSOLICITED_ENABLE,
1448 AC_USRSP_EN | ALC880_HP_EVENT);
Takashi Iwaid922b512011-04-28 12:18:53 +02001449 spec->automute = 1;
1450 spec->automute_mode = ALC_AUTOMUTE_PIN;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001451 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001452 spec->unsol_event = alc_sku_unsol_event;
1453}
1454
Takashi Iwai6c819492009-08-10 18:47:44 +02001455static void alc_init_auto_mic(struct hda_codec *codec)
1456{
1457 struct alc_spec *spec = codec->spec;
1458 struct auto_pin_cfg *cfg = &spec->autocfg;
1459 hda_nid_t fixed, ext;
1460 int i;
1461
1462 /* there must be only two mic inputs exclusively */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001463 for (i = 0; i < cfg->num_inputs; i++)
Takashi Iwai86e29592010-09-09 14:50:17 +02001464 if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN)
Takashi Iwai6c819492009-08-10 18:47:44 +02001465 return;
1466
1467 fixed = ext = 0;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001468 for (i = 0; i < cfg->num_inputs; i++) {
1469 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai6c819492009-08-10 18:47:44 +02001470 unsigned int defcfg;
Takashi Iwai6c819492009-08-10 18:47:44 +02001471 defcfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001472 switch (snd_hda_get_input_pin_attr(defcfg)) {
1473 case INPUT_PIN_ATTR_INT:
Takashi Iwai6c819492009-08-10 18:47:44 +02001474 if (fixed)
1475 return; /* already occupied */
1476 fixed = nid;
1477 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001478 case INPUT_PIN_ATTR_UNUSED:
1479 return; /* invalid entry */
1480 default:
Takashi Iwai6c819492009-08-10 18:47:44 +02001481 if (ext)
1482 return; /* already occupied */
1483 ext = nid;
1484 break;
Takashi Iwai6c819492009-08-10 18:47:44 +02001485 }
1486 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001487 if (!ext || !fixed)
1488 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001489 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1490 return; /* no unsol support */
1491 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1492 ext, fixed);
1493 spec->ext_mic.pin = ext;
1494 spec->int_mic.pin = fixed;
1495 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1496 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1497 spec->auto_mic = 1;
1498 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1499 AC_VERB_SET_UNSOLICITED_ENABLE,
1500 AC_USRSP_EN | ALC880_MIC_EVENT);
1501 spec->unsol_event = alc_sku_unsol_event;
1502}
1503
David Henningsson90622912010-10-14 14:50:18 +02001504/* Could be any non-zero and even value. When used as fixup, tells
1505 * the driver to ignore any present sku defines.
1506 */
1507#define ALC_FIXUP_SKU_IGNORE (2)
1508
Kailang Yangda00c242010-03-19 11:23:45 +01001509static int alc_auto_parse_customize_define(struct hda_codec *codec)
1510{
1511 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +01001512 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +01001513 struct alc_spec *spec = codec->spec;
1514
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001515 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1516
David Henningsson90622912010-10-14 14:50:18 +02001517 if (spec->cdefine.fixup) {
1518 ass = spec->cdefine.sku_cfg;
1519 if (ass == ALC_FIXUP_SKU_IGNORE)
1520 return -1;
1521 goto do_sku;
1522 }
1523
Kailang Yangda00c242010-03-19 11:23:45 +01001524 ass = codec->subsystem_id & 0xffff;
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001525 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
Kailang Yangda00c242010-03-19 11:23:45 +01001526 goto do_sku;
1527
1528 nid = 0x1d;
1529 if (codec->vendor_id == 0x10ec0260)
1530 nid = 0x17;
1531 ass = snd_hda_codec_get_pincfg(codec, nid);
1532
1533 if (!(ass & 1)) {
1534 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1535 codec->chip_name, ass);
1536 return -1;
1537 }
1538
1539 /* check sum */
1540 tmp = 0;
1541 for (i = 1; i < 16; i++) {
1542 if ((ass >> i) & 1)
1543 tmp++;
1544 }
1545 if (((ass >> 16) & 0xf) != tmp)
1546 return -1;
1547
1548 spec->cdefine.port_connectivity = ass >> 30;
1549 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1550 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1551 spec->cdefine.customization = ass >> 8;
1552do_sku:
1553 spec->cdefine.sku_cfg = ass;
1554 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1555 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1556 spec->cdefine.swap = (ass & 0x2) >> 1;
1557 spec->cdefine.override = ass & 0x1;
1558
1559 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1560 nid, spec->cdefine.sku_cfg);
1561 snd_printd("SKU: port_connectivity=0x%x\n",
1562 spec->cdefine.port_connectivity);
1563 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1564 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1565 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1566 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1567 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1568 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1569 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1570
1571 return 0;
1572}
1573
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001574/* check subsystem ID and set up device-specific initialization;
1575 * return 1 if initialized, 0 if invalid SSID
1576 */
1577/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1578 * 31 ~ 16 : Manufacture ID
1579 * 15 ~ 8 : SKU ID
1580 * 7 ~ 0 : Assembly ID
1581 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1582 */
1583static int alc_subsystem_id(struct hda_codec *codec,
1584 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001585 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001586{
1587 unsigned int ass, tmp, i;
1588 unsigned nid;
1589 struct alc_spec *spec = codec->spec;
1590
David Henningsson90622912010-10-14 14:50:18 +02001591 if (spec->cdefine.fixup) {
1592 ass = spec->cdefine.sku_cfg;
1593 if (ass == ALC_FIXUP_SKU_IGNORE)
1594 return 0;
1595 goto do_sku;
1596 }
1597
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001598 ass = codec->subsystem_id & 0xffff;
1599 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1600 goto do_sku;
1601
1602 /* invalid SSID, check the special NID pin defcfg instead */
1603 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001604 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001605 * 29~21 : reserve
1606 * 20 : PCBEEP input
1607 * 19~16 : Check sum (15:1)
1608 * 15~1 : Custom
1609 * 0 : override
1610 */
1611 nid = 0x1d;
1612 if (codec->vendor_id == 0x10ec0260)
1613 nid = 0x17;
1614 ass = snd_hda_codec_get_pincfg(codec, nid);
1615 snd_printd("realtek: No valid SSID, "
1616 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001617 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001618 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001619 return 0;
1620 if ((ass >> 30) != 1) /* no physical connection */
1621 return 0;
1622
1623 /* check sum */
1624 tmp = 0;
1625 for (i = 1; i < 16; i++) {
1626 if ((ass >> i) & 1)
1627 tmp++;
1628 }
1629 if (((ass >> 16) & 0xf) != tmp)
1630 return 0;
1631do_sku:
1632 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1633 ass & 0xffff, codec->vendor_id);
1634 /*
1635 * 0 : override
1636 * 1 : Swap Jack
1637 * 2 : 0 --> Desktop, 1 --> Laptop
1638 * 3~5 : External Amplifier control
1639 * 7~6 : Reserved
1640 */
1641 tmp = (ass & 0x38) >> 3; /* external Amp control */
1642 switch (tmp) {
1643 case 1:
1644 spec->init_amp = ALC_INIT_GPIO1;
1645 break;
1646 case 3:
1647 spec->init_amp = ALC_INIT_GPIO2;
1648 break;
1649 case 7:
1650 spec->init_amp = ALC_INIT_GPIO3;
1651 break;
1652 case 5:
Takashi Iwai5a8cfb42010-11-26 17:11:18 +01001653 default:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001654 spec->init_amp = ALC_INIT_DEFAULT;
1655 break;
1656 }
1657
1658 /* is laptop or Desktop and enable the function "Mute internal speaker
1659 * when the external headphone out jack is plugged"
1660 */
1661 if (!(ass & 0x8000))
1662 return 1;
1663 /*
1664 * 10~8 : Jack location
1665 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1666 * 14~13: Resvered
1667 * 15 : 1 --> enable the function "Mute internal speaker
1668 * when the external headphone out jack is plugged"
1669 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001670 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001671 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001672 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1673 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001674 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001675 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001676 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001677 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001678 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001679 else if (tmp == 3)
1680 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001681 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001682 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001683 for (i = 0; i < spec->autocfg.line_outs; i++)
1684 if (spec->autocfg.line_out_pins[i] == nid)
1685 return 1;
1686 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001687 }
1688
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001689 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001690 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001691 return 1;
1692}
Kailang Yangea1fb292008-08-26 12:58:38 +02001693
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001694static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001695 hda_nid_t porta, hda_nid_t porte,
1696 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001697{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001698 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001699 struct alc_spec *spec = codec->spec;
1700 snd_printd("realtek: "
1701 "Enable default setup for auto mode as fallback\n");
1702 spec->init_amp = ALC_INIT_DEFAULT;
1703 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001704 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001705 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001706}
1707
Takashi Iwai41e41f12005-06-08 14:48:49 +02001708/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001709 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001710 */
1711
1712struct alc_pincfg {
1713 hda_nid_t nid;
1714 u32 val;
1715};
1716
Todd Broche1eb5f12010-12-06 11:19:51 -08001717struct alc_model_fixup {
1718 const int id;
1719 const char *name;
1720};
1721
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001722struct alc_fixup {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001723 int type;
Takashi Iwai361fe6e2011-01-14 09:55:32 +01001724 bool chained;
1725 int chain_id;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001726 union {
1727 unsigned int sku;
1728 const struct alc_pincfg *pins;
1729 const struct hda_verb *verbs;
1730 void (*func)(struct hda_codec *codec,
1731 const struct alc_fixup *fix,
1732 int action);
1733 } v;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001734};
1735
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001736enum {
1737 ALC_FIXUP_INVALID,
1738 ALC_FIXUP_SKU,
1739 ALC_FIXUP_PINS,
1740 ALC_FIXUP_VERBS,
1741 ALC_FIXUP_FUNC,
1742};
Takashi Iwaif95474e2007-07-10 00:47:43 +02001743
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001744enum {
1745 ALC_FIXUP_ACT_PRE_PROBE,
1746 ALC_FIXUP_ACT_PROBE,
Takashi Iwai58701122011-01-13 15:41:45 +01001747 ALC_FIXUP_ACT_INIT,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001748};
1749
1750static void alc_apply_fixup(struct hda_codec *codec, int action)
1751{
1752 struct alc_spec *spec = codec->spec;
1753 int id = spec->fixup_id;
Takashi Iwaiaa1d0c52011-01-19 17:27:58 +01001754#ifdef CONFIG_SND_DEBUG_VERBOSE
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001755 const char *modelname = spec->fixup_name;
Takashi Iwaiaa1d0c52011-01-19 17:27:58 +01001756#endif
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001757 int depth = 0;
1758
1759 if (!spec->fixup_list)
1760 return;
1761
1762 while (id >= 0) {
1763 const struct alc_fixup *fix = spec->fixup_list + id;
1764 const struct alc_pincfg *cfg;
1765
1766 switch (fix->type) {
1767 case ALC_FIXUP_SKU:
1768 if (action != ALC_FIXUP_ACT_PRE_PROBE || !fix->v.sku)
1769 break;;
1770 snd_printdd(KERN_INFO "hda_codec: %s: "
1771 "Apply sku override for %s\n",
1772 codec->chip_name, modelname);
1773 spec->cdefine.sku_cfg = fix->v.sku;
1774 spec->cdefine.fixup = 1;
1775 break;
1776 case ALC_FIXUP_PINS:
1777 cfg = fix->v.pins;
1778 if (action != ALC_FIXUP_ACT_PRE_PROBE || !cfg)
1779 break;
1780 snd_printdd(KERN_INFO "hda_codec: %s: "
1781 "Apply pincfg for %s\n",
1782 codec->chip_name, modelname);
1783 for (; cfg->nid; cfg++)
1784 snd_hda_codec_set_pincfg(codec, cfg->nid,
1785 cfg->val);
1786 break;
1787 case ALC_FIXUP_VERBS:
1788 if (action != ALC_FIXUP_ACT_PROBE || !fix->v.verbs)
1789 break;
1790 snd_printdd(KERN_INFO "hda_codec: %s: "
1791 "Apply fix-verbs for %s\n",
1792 codec->chip_name, modelname);
1793 add_verb(codec->spec, fix->v.verbs);
1794 break;
1795 case ALC_FIXUP_FUNC:
1796 if (!fix->v.func)
1797 break;
1798 snd_printdd(KERN_INFO "hda_codec: %s: "
1799 "Apply fix-func for %s\n",
1800 codec->chip_name, modelname);
1801 fix->v.func(codec, fix, action);
1802 break;
1803 default:
1804 snd_printk(KERN_ERR "hda_codec: %s: "
1805 "Invalid fixup type %d\n",
1806 codec->chip_name, fix->type);
1807 break;
1808 }
1809 if (!fix[id].chained)
1810 break;
1811 if (++depth > 10)
1812 break;
1813 id = fix[id].chain_id;
Takashi Iwai9d578832010-11-22 13:29:19 +01001814 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001815}
1816
Todd Broche1eb5f12010-12-06 11:19:51 -08001817static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001818 const struct alc_model_fixup *models,
1819 const struct snd_pci_quirk *quirk,
1820 const struct alc_fixup *fixlist)
Todd Broche1eb5f12010-12-06 11:19:51 -08001821{
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001822 struct alc_spec *spec = codec->spec;
1823 int id = -1;
1824 const char *name = NULL;
Todd Broche1eb5f12010-12-06 11:19:51 -08001825
Todd Broche1eb5f12010-12-06 11:19:51 -08001826 if (codec->modelname && models) {
1827 while (models->name) {
1828 if (!strcmp(codec->modelname, models->name)) {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001829 id = models->id;
1830 name = models->name;
Todd Broche1eb5f12010-12-06 11:19:51 -08001831 break;
1832 }
1833 models++;
1834 }
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001835 }
1836 if (id < 0) {
1837 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1838 if (quirk) {
1839 id = quirk->value;
1840#ifdef CONFIG_SND_DEBUG_VERBOSE
1841 name = quirk->name;
1842#endif
1843 }
1844 }
1845
1846 spec->fixup_id = id;
1847 if (id >= 0) {
1848 spec->fixup_list = fixlist;
1849 spec->fixup_name = name;
Todd Broche1eb5f12010-12-06 11:19:51 -08001850 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001851}
1852
Kailang Yang274693f2009-12-03 10:07:50 +01001853static int alc_read_coef_idx(struct hda_codec *codec,
1854 unsigned int coef_idx)
1855{
1856 unsigned int val;
1857 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1858 coef_idx);
1859 val = snd_hda_codec_read(codec, 0x20, 0,
1860 AC_VERB_GET_PROC_COEF, 0);
1861 return val;
1862}
1863
Kailang Yang977ddd62010-09-15 10:02:29 +02001864static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1865 unsigned int coef_val)
1866{
1867 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1868 coef_idx);
1869 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
1870 coef_val);
1871}
1872
Takashi Iwai757899a2010-07-30 10:48:14 +02001873/* set right pin controls for digital I/O */
1874static void alc_auto_init_digital(struct hda_codec *codec)
1875{
1876 struct alc_spec *spec = codec->spec;
1877 int i;
1878 hda_nid_t pin;
1879
1880 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1881 pin = spec->autocfg.dig_out_pins[i];
1882 if (pin) {
1883 snd_hda_codec_write(codec, pin, 0,
1884 AC_VERB_SET_PIN_WIDGET_CONTROL,
1885 PIN_OUT);
1886 }
1887 }
1888 pin = spec->autocfg.dig_in_pin;
1889 if (pin)
1890 snd_hda_codec_write(codec, pin, 0,
1891 AC_VERB_SET_PIN_WIDGET_CONTROL,
1892 PIN_IN);
1893}
1894
1895/* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1896static void alc_auto_parse_digital(struct hda_codec *codec)
1897{
1898 struct alc_spec *spec = codec->spec;
1899 int i, err;
1900 hda_nid_t dig_nid;
1901
1902 /* support multiple SPDIFs; the secondary is set up as a slave */
1903 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1904 err = snd_hda_get_connections(codec,
1905 spec->autocfg.dig_out_pins[i],
1906 &dig_nid, 1);
1907 if (err < 0)
1908 continue;
1909 if (!i) {
1910 spec->multiout.dig_out_nid = dig_nid;
1911 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1912 } else {
1913 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1914 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1915 break;
1916 spec->slave_dig_outs[i - 1] = dig_nid;
1917 }
1918 }
1919
1920 if (spec->autocfg.dig_in_pin) {
Takashi Iwai01fdf182010-09-24 09:09:42 +02001921 dig_nid = codec->start_nid;
1922 for (i = 0; i < codec->num_nodes; i++, dig_nid++) {
1923 unsigned int wcaps = get_wcaps(codec, dig_nid);
1924 if (get_wcaps_type(wcaps) != AC_WID_AUD_IN)
1925 continue;
1926 if (!(wcaps & AC_WCAP_DIGITAL))
1927 continue;
1928 if (!(wcaps & AC_WCAP_CONN_LIST))
1929 continue;
1930 err = get_connection_index(codec, dig_nid,
1931 spec->autocfg.dig_in_pin);
1932 if (err >= 0) {
1933 spec->dig_in_nid = dig_nid;
1934 break;
1935 }
1936 }
Takashi Iwai757899a2010-07-30 10:48:14 +02001937 }
1938}
1939
Takashi Iwaif95474e2007-07-10 00:47:43 +02001940/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001941 * ALC888
1942 */
1943
1944/*
1945 * 2ch mode
1946 */
1947static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1948/* Mic-in jack as mic in */
1949 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1950 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1951/* Line-in jack as Line in */
1952 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1953 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1954/* Line-Out as Front */
1955 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1956 { } /* end */
1957};
1958
1959/*
1960 * 4ch mode
1961 */
1962static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1963/* Mic-in jack as mic in */
1964 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1965 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1966/* Line-in jack as Surround */
1967 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1968 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1969/* Line-Out as Front */
1970 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1971 { } /* end */
1972};
1973
1974/*
1975 * 6ch mode
1976 */
1977static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1978/* Mic-in jack as CLFE */
1979 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1980 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1981/* Line-in jack as Surround */
1982 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1983 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1984/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1985 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1986 { } /* end */
1987};
1988
1989/*
1990 * 8ch mode
1991 */
1992static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1993/* Mic-in jack as CLFE */
1994 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1995 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1996/* Line-in jack as Surround */
1997 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1998 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1999/* Line-Out as Side */
2000 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
2001 { } /* end */
2002};
2003
2004static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
2005 { 2, alc888_4ST_ch2_intel_init },
2006 { 4, alc888_4ST_ch4_intel_init },
2007 { 6, alc888_4ST_ch6_intel_init },
2008 { 8, alc888_4ST_ch8_intel_init },
2009};
2010
2011/*
2012 * ALC888 Fujitsu Siemens Amillo xa3530
2013 */
2014
2015static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
2016/* Front Mic: set to PIN_IN (empty by default) */
2017 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2018/* Connect Internal HP to Front */
2019 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2020 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2021 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2022/* Connect Bass HP to Front */
2023 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2024 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2025 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2026/* Connect Line-Out side jack (SPDIF) to Side */
2027 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2028 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2029 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
2030/* Connect Mic jack to CLFE */
2031 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2032 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2033 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
2034/* Connect Line-in jack to Surround */
2035 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2036 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2037 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
2038/* Connect HP out jack to Front */
2039 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2040 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2041 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2042/* Enable unsolicited event for HP jack and Line-out jack */
2043 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2044 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2045 {}
2046};
2047
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002048static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02002049{
2050 struct alc_spec *spec = codec->spec;
2051
2052 spec->autocfg.hp_pins[0] = 0x15;
2053 spec->autocfg.speaker_pins[0] = 0x14;
2054 spec->autocfg.speaker_pins[1] = 0x16;
2055 spec->autocfg.speaker_pins[2] = 0x17;
2056 spec->autocfg.speaker_pins[3] = 0x19;
2057 spec->autocfg.speaker_pins[4] = 0x1a;
Takashi Iwaid922b512011-04-28 12:18:53 +02002058 spec->automute = 1;
2059 spec->automute_mode = ALC_AUTOMUTE_AMP;
Wu Fengguang6732bd02009-07-30 09:19:14 +02002060}
2061
2062static void alc889_intel_init_hook(struct hda_codec *codec)
2063{
2064 alc889_coef_init(codec);
Takashi Iwaid922b512011-04-28 12:18:53 +02002065 alc_hp_automute(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02002066}
2067
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002068static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002069{
2070 struct alc_spec *spec = codec->spec;
2071
2072 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
2073 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
2074 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
2075 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaid922b512011-04-28 12:18:53 +02002076 spec->automute = 1;
2077 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002078}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002079
2080/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002081 * ALC888 Acer Aspire 4930G model
2082 */
2083
2084static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
2085/* Front Mic: set to PIN_IN (empty by default) */
2086 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2087/* Unselect Front Mic by default in input mixer 3 */
2088 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002089/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002090 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2091/* Connect Internal HP to front */
2092 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2093 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2094 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2095/* Connect HP out to front */
2096 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2097 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2098 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie2e93292011-01-12 08:03:39 +01002099 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002100 { }
2101};
2102
Hector Martin3b315d72009-06-02 10:54:19 +02002103/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01002104 * ALC888 Acer Aspire 6530G model
2105 */
2106
2107static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
Tony Vroond1284182010-04-05 16:30:43 +01002108/* Route to built-in subwoofer as well as speakers */
2109 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2110 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2111 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2112 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002113/* Bias voltage on for external mic port */
2114 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02002115/* Front Mic: set to PIN_IN (empty by default) */
2116 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2117/* Unselect Front Mic by default in input mixer 3 */
2118 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002119/* Enable unsolicited event for HP jack */
2120 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2121/* Enable speaker output */
2122 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2123 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tony Vroond1284182010-04-05 16:30:43 +01002124 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002125/* Enable headphone output */
2126 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2127 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2128 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Tony Vroond1284182010-04-05 16:30:43 +01002129 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002130 { }
2131};
2132
2133/*
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002134 *ALC888 Acer Aspire 7730G model
2135 */
2136
2137static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
2138/* Bias voltage on for external mic port */
2139 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
2140/* Front Mic: set to PIN_IN (empty by default) */
2141 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2142/* Unselect Front Mic by default in input mixer 3 */
2143 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2144/* Enable unsolicited event for HP jack */
2145 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2146/* Enable speaker output */
2147 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2148 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2149 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
2150/* Enable headphone output */
2151 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2152 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2153 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2154 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
2155/*Enable internal subwoofer */
2156 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2157 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2158 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
2159 {0x17, AC_VERB_SET_EAPD_BTLENABLE, 2},
2160 { }
2161};
2162
2163/*
Hector Martin018df412009-06-04 00:13:40 +02002164 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02002165 */
2166
Hector Martin018df412009-06-04 00:13:40 +02002167static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02002168/* Front Mic: set to PIN_IN (empty by default) */
2169 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2170/* Unselect Front Mic by default in input mixer 3 */
2171 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2172/* Enable unsolicited event for HP jack */
2173 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2174/* Connect Internal Front to Front */
2175 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2176 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2177 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2178/* Connect Internal Rear to Rear */
2179 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2180 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2181 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
2182/* Connect Internal CLFE to CLFE */
2183 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2184 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2185 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
2186/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02002187 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02002188 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2189 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2190/* Enable all DACs */
2191/* DAC DISABLE/MUTE 1? */
2192/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
2193 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
2194 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
2195/* DAC DISABLE/MUTE 2? */
2196/* some bit here disables the other DACs. Init=0x4900 */
2197 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
2198 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02002199/* DMIC fix
2200 * This laptop has a stereo digital microphone. The mics are only 1cm apart
2201 * which makes the stereo useless. However, either the mic or the ALC889
2202 * makes the signal become a difference/sum signal instead of standard
2203 * stereo, which is annoying. So instead we flip this bit which makes the
2204 * codec replicate the sum signal to both channels, turning it into a
2205 * normal mono mic.
2206 */
2207/* DMIC_CONTROL? Init value = 0x0001 */
2208 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
2209 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02002210 { }
2211};
2212
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002213static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002214 /* Front mic only available on one ADC */
2215 {
2216 .num_items = 4,
2217 .items = {
2218 { "Mic", 0x0 },
2219 { "Line", 0x2 },
2220 { "CD", 0x4 },
2221 { "Front Mic", 0xb },
2222 },
2223 },
2224 {
2225 .num_items = 3,
2226 .items = {
2227 { "Mic", 0x0 },
2228 { "Line", 0x2 },
2229 { "CD", 0x4 },
2230 },
2231 }
2232};
2233
Tony Vroond2fd4b02009-06-21 00:40:10 +01002234static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
2235 /* Interal mic only available on one ADC */
2236 {
Tony Vroon684a8842009-06-26 09:27:50 +01002237 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002238 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +01002239 { "Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002240 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002241 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002242 { "Input Mix", 0xa },
David Henningsson28c4edb2010-12-20 14:24:29 +01002243 { "Internal Mic", 0xb },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002244 },
2245 },
2246 {
Tony Vroon684a8842009-06-26 09:27:50 +01002247 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002248 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +01002249 { "Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002250 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002251 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002252 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002253 },
2254 }
2255};
2256
Hector Martin018df412009-06-04 00:13:40 +02002257static struct hda_input_mux alc889_capture_sources[3] = {
2258 /* Digital mic only available on first "ADC" */
2259 {
2260 .num_items = 5,
2261 .items = {
2262 { "Mic", 0x0 },
2263 { "Line", 0x2 },
2264 { "CD", 0x4 },
2265 { "Front Mic", 0xb },
2266 { "Input Mix", 0xa },
2267 },
2268 },
2269 {
2270 .num_items = 4,
2271 .items = {
2272 { "Mic", 0x0 },
2273 { "Line", 0x2 },
2274 { "CD", 0x4 },
2275 { "Input Mix", 0xa },
2276 },
2277 },
2278 {
2279 .num_items = 4,
2280 .items = {
2281 { "Mic", 0x0 },
2282 { "Line", 0x2 },
2283 { "CD", 0x4 },
2284 { "Input Mix", 0xa },
2285 },
2286 }
2287};
2288
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002289static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002290 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2291 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2292 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2293 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2294 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2295 HDA_OUTPUT),
2296 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2297 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2298 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2299 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2300 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2301 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2302 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2303 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2304 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2305 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01002306 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002307 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002308 { } /* end */
2309};
2310
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +01002311static struct snd_kcontrol_new alc888_acer_aspire_4930g_mixer[] = {
2312 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2313 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2314 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2315 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Łukasz Wojniłowicz786c51f2011-02-24 10:03:31 +01002316 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +01002317 HDA_OUTPUT),
Łukasz Wojniłowicz786c51f2011-02-24 10:03:31 +01002318 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2319 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2320 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2321 HDA_CODEC_VOLUME_MONO("Internal LFE Playback Volume", 0x0f, 1, 0x0, HDA_OUTPUT),
2322 HDA_BIND_MUTE_MONO("Internal LFE Playback Switch", 0x0f, 1, 2, HDA_INPUT),
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +01002323 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2324 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2325 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2326 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2327 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2328 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
2329 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2330 { } /* end */
2331};
2332
Hector Martin556eea92009-12-20 22:51:23 +01002333static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
2334 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2335 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2336 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2337 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2338 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2339 HDA_OUTPUT),
2340 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2341 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2342 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2343 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2344 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2345 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01002346 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Hector Martin556eea92009-12-20 22:51:23 +01002347 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2348 { } /* end */
2349};
2350
2351
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002352static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002353{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002354 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002355
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002356 spec->autocfg.hp_pins[0] = 0x15;
2357 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01002358 spec->autocfg.speaker_pins[1] = 0x16;
2359 spec->autocfg.speaker_pins[2] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02002360 spec->automute = 1;
2361 spec->automute_mode = ALC_AUTOMUTE_AMP;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002362}
2363
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002364static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02002365{
2366 struct alc_spec *spec = codec->spec;
2367
2368 spec->autocfg.hp_pins[0] = 0x15;
2369 spec->autocfg.speaker_pins[0] = 0x14;
2370 spec->autocfg.speaker_pins[1] = 0x16;
2371 spec->autocfg.speaker_pins[2] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02002372 spec->automute = 1;
2373 spec->automute_mode = ALC_AUTOMUTE_AMP;
Emilio López320d5922009-06-25 08:18:44 +02002374}
2375
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002376static void alc888_acer_aspire_7730g_setup(struct hda_codec *codec)
2377{
2378 struct alc_spec *spec = codec->spec;
2379
2380 spec->autocfg.hp_pins[0] = 0x15;
2381 spec->autocfg.speaker_pins[0] = 0x14;
2382 spec->autocfg.speaker_pins[1] = 0x16;
2383 spec->autocfg.speaker_pins[2] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02002384 spec->automute = 1;
2385 spec->automute_mode = ALC_AUTOMUTE_AMP;
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002386}
2387
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002388static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02002389{
2390 struct alc_spec *spec = codec->spec;
2391
2392 spec->autocfg.hp_pins[0] = 0x15;
2393 spec->autocfg.speaker_pins[0] = 0x14;
2394 spec->autocfg.speaker_pins[1] = 0x16;
2395 spec->autocfg.speaker_pins[2] = 0x1b;
Takashi Iwaid922b512011-04-28 12:18:53 +02002396 spec->automute = 1;
2397 spec->automute_mode = ALC_AUTOMUTE_AMP;
Hector Martin3b315d72009-06-02 10:54:19 +02002398}
2399
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002400/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002401 * ALC880 3-stack model
2402 *
2403 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002404 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2405 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07002406 */
2407
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002408static hda_nid_t alc880_dac_nids[4] = {
2409 /* front, rear, clfe, rear_surr */
2410 0x02, 0x05, 0x04, 0x03
2411};
2412
2413static hda_nid_t alc880_adc_nids[3] = {
2414 /* ADC0-2 */
2415 0x07, 0x08, 0x09,
2416};
2417
2418/* The datasheet says the node 0x07 is connected from inputs,
2419 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01002420 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07002421 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002422static hda_nid_t alc880_adc_nids_alt[2] = {
2423 /* ADC1-2 */
2424 0x08, 0x09,
2425};
2426
2427#define ALC880_DIGOUT_NID 0x06
2428#define ALC880_DIGIN_NID 0x0a
2429
2430static struct hda_input_mux alc880_capture_source = {
2431 .num_items = 4,
2432 .items = {
2433 { "Mic", 0x0 },
2434 { "Front Mic", 0x3 },
2435 { "Line", 0x2 },
2436 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002437 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002438};
2439
2440/* channel source setting (2/6 channel selection for 3-stack) */
2441/* 2ch mode */
2442static struct hda_verb alc880_threestack_ch2_init[] = {
2443 /* set line-in to input, mute it */
2444 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2445 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2446 /* set mic-in to input vref 80%, mute it */
2447 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2448 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002449 { } /* end */
2450};
2451
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002452/* 6ch mode */
2453static struct hda_verb alc880_threestack_ch6_init[] = {
2454 /* set line-in to output, unmute it */
2455 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2456 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2457 /* set mic-in to output, unmute it */
2458 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2459 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2460 { } /* end */
2461};
2462
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002463static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002464 { 2, alc880_threestack_ch2_init },
2465 { 6, alc880_threestack_ch6_init },
2466};
2467
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002468static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002469 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002470 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002471 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002472 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002473 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2474 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002475 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2476 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002477 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2478 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2479 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2480 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2481 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2482 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2483 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2484 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002485 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002486 {
2487 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2488 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002489 .info = alc_ch_mode_info,
2490 .get = alc_ch_mode_get,
2491 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002492 },
2493 { } /* end */
2494};
2495
2496/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002497static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2498 struct snd_ctl_elem_info *uinfo)
2499{
2500 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2501 struct alc_spec *spec = codec->spec;
2502 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002503
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002504 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002505 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2506 HDA_INPUT);
2507 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002508 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002509 return err;
2510}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002511
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002512static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2513 unsigned int size, unsigned int __user *tlv)
2514{
2515 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2516 struct alc_spec *spec = codec->spec;
2517 int err;
2518
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002519 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002520 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2521 HDA_INPUT);
2522 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002523 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002524 return err;
2525}
2526
2527typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2528 struct snd_ctl_elem_value *ucontrol);
2529
2530static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2531 struct snd_ctl_elem_value *ucontrol,
2532 getput_call_t func)
2533{
2534 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2535 struct alc_spec *spec = codec->spec;
2536 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2537 int err;
2538
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002539 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002540 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2541 3, 0, HDA_INPUT);
2542 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002543 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002544 return err;
2545}
2546
2547static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2548 struct snd_ctl_elem_value *ucontrol)
2549{
2550 return alc_cap_getput_caller(kcontrol, ucontrol,
2551 snd_hda_mixer_amp_volume_get);
2552}
2553
2554static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2555 struct snd_ctl_elem_value *ucontrol)
2556{
2557 return alc_cap_getput_caller(kcontrol, ucontrol,
2558 snd_hda_mixer_amp_volume_put);
2559}
2560
2561/* capture mixer elements */
2562#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2563
2564static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2565 struct snd_ctl_elem_value *ucontrol)
2566{
2567 return alc_cap_getput_caller(kcontrol, ucontrol,
2568 snd_hda_mixer_amp_switch_get);
2569}
2570
2571static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2572 struct snd_ctl_elem_value *ucontrol)
2573{
2574 return alc_cap_getput_caller(kcontrol, ucontrol,
2575 snd_hda_mixer_amp_switch_put);
2576}
2577
Takashi Iwaia23b6882009-03-23 15:21:36 +01002578#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002579 { \
2580 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2581 .name = "Capture Switch", \
2582 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2583 .count = num, \
2584 .info = alc_cap_sw_info, \
2585 .get = alc_cap_sw_get, \
2586 .put = alc_cap_sw_put, \
2587 }, \
2588 { \
2589 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2590 .name = "Capture Volume", \
2591 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2592 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2593 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2594 .count = num, \
2595 .info = alc_cap_vol_info, \
2596 .get = alc_cap_vol_get, \
2597 .put = alc_cap_vol_put, \
2598 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002599 }
2600
2601#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002602 { \
2603 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2604 /* .name = "Capture Source", */ \
2605 .name = "Input Source", \
2606 .count = num, \
2607 .info = alc_mux_enum_info, \
2608 .get = alc_mux_enum_get, \
2609 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002610 }
2611
2612#define DEFINE_CAPMIX(num) \
2613static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2614 _DEFINE_CAPMIX(num), \
2615 _DEFINE_CAPSRC(num), \
2616 { } /* end */ \
2617}
2618
2619#define DEFINE_CAPMIX_NOSRC(num) \
2620static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2621 _DEFINE_CAPMIX(num), \
2622 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002623}
2624
2625/* up to three ADCs */
2626DEFINE_CAPMIX(1);
2627DEFINE_CAPMIX(2);
2628DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002629DEFINE_CAPMIX_NOSRC(1);
2630DEFINE_CAPMIX_NOSRC(2);
2631DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002632
2633/*
2634 * ALC880 5-stack model
2635 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002636 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2637 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002638 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2639 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2640 */
2641
2642/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002643static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002644 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002645 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002646 { } /* end */
2647};
2648
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002649/* channel source setting (6/8 channel selection for 5-stack) */
2650/* 6ch mode */
2651static struct hda_verb alc880_fivestack_ch6_init[] = {
2652 /* set line-in to input, mute it */
2653 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2654 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002655 { } /* end */
2656};
2657
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002658/* 8ch mode */
2659static struct hda_verb alc880_fivestack_ch8_init[] = {
2660 /* set line-in to output, unmute it */
2661 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2662 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2663 { } /* end */
2664};
2665
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002666static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002667 { 6, alc880_fivestack_ch6_init },
2668 { 8, alc880_fivestack_ch8_init },
2669};
2670
2671
2672/*
2673 * ALC880 6-stack model
2674 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002675 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2676 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002677 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2678 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2679 */
2680
2681static hda_nid_t alc880_6st_dac_nids[4] = {
2682 /* front, rear, clfe, rear_surr */
2683 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002684};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002685
2686static struct hda_input_mux alc880_6stack_capture_source = {
2687 .num_items = 4,
2688 .items = {
2689 { "Mic", 0x0 },
2690 { "Front Mic", 0x1 },
2691 { "Line", 0x2 },
2692 { "CD", 0x4 },
2693 },
2694};
2695
2696/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002697static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002698 { 8, NULL },
2699};
2700
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002701static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002702 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002703 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002704 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002705 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002706 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2707 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002708 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2709 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002710 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002711 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002712 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2713 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2714 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2715 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2716 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2717 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2718 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2719 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002720 {
2721 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2722 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002723 .info = alc_ch_mode_info,
2724 .get = alc_ch_mode_get,
2725 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002726 },
2727 { } /* end */
2728};
2729
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002730
2731/*
2732 * ALC880 W810 model
2733 *
2734 * W810 has rear IO for:
2735 * Front (DAC 02)
2736 * Surround (DAC 03)
2737 * Center/LFE (DAC 04)
2738 * Digital out (06)
2739 *
2740 * The system also has a pair of internal speakers, and a headphone jack.
2741 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002742 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002743 * There is a variable resistor to control the speaker or headphone
2744 * volume. This is a hardware-only device without a software API.
2745 *
2746 * Plugging headphones in will disable the internal speakers. This is
2747 * implemented in hardware, not via the driver using jack sense. In
2748 * a similar fashion, plugging into the rear socket marked "front" will
2749 * disable both the speakers and headphones.
2750 *
2751 * For input, there's a microphone jack, and an "audio in" jack.
2752 * These may not do anything useful with this driver yet, because I
2753 * haven't setup any initialization verbs for these yet...
2754 */
2755
2756static hda_nid_t alc880_w810_dac_nids[3] = {
2757 /* front, rear/surround, clfe */
2758 0x02, 0x03, 0x04
2759};
2760
2761/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002762static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002763 { 6, NULL }
2764};
2765
2766/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002767static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002768 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002769 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002770 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002771 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002772 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2773 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002774 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2775 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002776 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2777 { } /* end */
2778};
2779
2780
2781/*
2782 * Z710V model
2783 *
2784 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002785 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2786 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002787 */
2788
2789static hda_nid_t alc880_z71v_dac_nids[1] = {
2790 0x02
2791};
2792#define ALC880_Z71V_HP_DAC 0x03
2793
2794/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002795static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002796 { 2, NULL }
2797};
2798
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002799static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002800 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002801 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002802 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002803 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002804 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2805 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2806 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2807 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2808 { } /* end */
2809};
2810
2811
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002812/*
2813 * ALC880 F1734 model
2814 *
2815 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2816 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2817 */
2818
2819static hda_nid_t alc880_f1734_dac_nids[1] = {
2820 0x03
2821};
2822#define ALC880_F1734_HP_DAC 0x02
2823
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002824static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002825 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002826 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002827 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2828 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002829 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2830 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002831 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2832 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002833 { } /* end */
2834};
2835
Takashi Iwai937b4162008-02-11 14:52:36 +01002836static struct hda_input_mux alc880_f1734_capture_source = {
2837 .num_items = 2,
2838 .items = {
2839 { "Mic", 0x1 },
2840 { "CD", 0x4 },
2841 },
2842};
2843
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002844
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002845/*
2846 * ALC880 ASUS model
2847 *
2848 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2849 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2850 * Mic = 0x18, Line = 0x1a
2851 */
2852
2853#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2854#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2855
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002856static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002857 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002858 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002859 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002860 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002861 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2862 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002863 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2864 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002865 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2866 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2867 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2868 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2869 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2870 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002871 {
2872 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2873 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002874 .info = alc_ch_mode_info,
2875 .get = alc_ch_mode_get,
2876 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002877 },
2878 { } /* end */
2879};
2880
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002881/*
2882 * ALC880 ASUS W1V model
2883 *
2884 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2885 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2886 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2887 */
2888
2889/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002890static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002891 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2892 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002893 { } /* end */
2894};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002895
Kailang Yangdf694da2005-12-05 19:42:22 +01002896/* TCL S700 */
2897static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2898 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2899 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2900 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2901 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2902 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2903 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2904 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2905 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2906 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002907 { } /* end */
2908};
2909
Kailang Yangccc656c2006-10-17 12:32:26 +02002910/* Uniwill */
2911static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002912 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2913 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2914 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2915 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002916 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2917 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2918 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2919 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2920 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2921 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2922 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2923 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2924 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2925 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2926 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2927 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002928 {
2929 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2930 .name = "Channel Mode",
2931 .info = alc_ch_mode_info,
2932 .get = alc_ch_mode_get,
2933 .put = alc_ch_mode_put,
2934 },
2935 { } /* end */
2936};
2937
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002938static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2939 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2940 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2941 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2942 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2943 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2944 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson8607f7c2010-12-20 14:43:54 +01002945 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2946 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01002947 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2948 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002949 { } /* end */
2950};
2951
Kailang Yangccc656c2006-10-17 12:32:26 +02002952static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002953 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2954 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2955 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2956 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002957 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2958 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2959 { } /* end */
2960};
2961
Linus Torvalds1da177e2005-04-16 15:20:36 -07002962/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002963 * virtual master controls
2964 */
2965
2966/*
2967 * slave controls for virtual master
2968 */
Takashi Iwaiea734962011-01-17 11:29:34 +01002969static const char * const alc_slave_vols[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002970 "Front Playback Volume",
2971 "Surround Playback Volume",
2972 "Center Playback Volume",
2973 "LFE Playback Volume",
2974 "Side Playback Volume",
2975 "Headphone Playback Volume",
2976 "Speaker Playback Volume",
2977 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002978 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002979 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002980 NULL,
2981};
2982
Takashi Iwaiea734962011-01-17 11:29:34 +01002983static const char * const alc_slave_sws[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002984 "Front Playback Switch",
2985 "Surround Playback Switch",
2986 "Center Playback Switch",
2987 "LFE Playback Switch",
2988 "Side Playback Switch",
2989 "Headphone Playback Switch",
2990 "Speaker Playback Switch",
2991 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002992 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002993 "Line-Out Playback Switch",
2994 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002995 NULL,
2996};
2997
2998/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002999 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07003000 */
Takashi Iwai603c4012008-07-30 15:01:44 +02003001
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003002#define NID_MAPPING (-1)
3003
3004#define SUBDEV_SPEAKER_ (0 << 6)
3005#define SUBDEV_HP_ (1 << 6)
3006#define SUBDEV_LINE_ (2 << 6)
3007#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
3008#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
3009#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
3010
Takashi Iwai603c4012008-07-30 15:01:44 +02003011static void alc_free_kctls(struct hda_codec *codec);
3012
Takashi Iwai67d634c2009-11-16 15:35:59 +01003013#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003014/* additional beep mixers; the actual parameters are overwritten at build */
3015static struct snd_kcontrol_new alc_beep_mixer[] = {
3016 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003017 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003018 { } /* end */
3019};
Takashi Iwai67d634c2009-11-16 15:35:59 +01003020#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003021
Linus Torvalds1da177e2005-04-16 15:20:36 -07003022static int alc_build_controls(struct hda_codec *codec)
3023{
3024 struct alc_spec *spec = codec->spec;
Takashi Iwai2f44f842010-06-22 11:12:32 +02003025 struct snd_kcontrol *kctl = NULL;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003026 struct snd_kcontrol_new *knew;
3027 int i, j, err;
3028 unsigned int u;
3029 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003030
3031 for (i = 0; i < spec->num_mixers; i++) {
3032 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
3033 if (err < 0)
3034 return err;
3035 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003036 if (spec->cap_mixer) {
3037 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
3038 if (err < 0)
3039 return err;
3040 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003041 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003042 err = snd_hda_create_spdif_out_ctls(codec,
3043 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003044 if (err < 0)
3045 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003046 if (!spec->no_analog) {
3047 err = snd_hda_create_spdif_share_sw(codec,
3048 &spec->multiout);
3049 if (err < 0)
3050 return err;
3051 spec->multiout.share_spdif = 1;
3052 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003053 }
3054 if (spec->dig_in_nid) {
3055 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
3056 if (err < 0)
3057 return err;
3058 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01003059
Takashi Iwai67d634c2009-11-16 15:35:59 +01003060#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003061 /* create beep controls if needed */
3062 if (spec->beep_amp) {
3063 struct snd_kcontrol_new *knew;
3064 for (knew = alc_beep_mixer; knew->name; knew++) {
3065 struct snd_kcontrol *kctl;
3066 kctl = snd_ctl_new1(knew, codec);
3067 if (!kctl)
3068 return -ENOMEM;
3069 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01003070 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003071 if (err < 0)
3072 return err;
3073 }
3074 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01003075#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003076
Takashi Iwai2134ea42008-01-10 16:53:55 +01003077 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003078 if (!spec->no_analog &&
3079 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01003080 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01003081 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01003082 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01003083 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01003084 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01003085 if (err < 0)
3086 return err;
3087 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003088 if (!spec->no_analog &&
3089 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003090 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
3091 NULL, alc_slave_sws);
3092 if (err < 0)
3093 return err;
3094 }
3095
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003096 /* assign Capture Source enums to NID */
Takashi Iwaifbe618f2010-06-11 11:24:58 +02003097 if (spec->capsrc_nids || spec->adc_nids) {
3098 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
3099 if (!kctl)
3100 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
3101 for (i = 0; kctl && i < kctl->count; i++) {
3102 hda_nid_t *nids = spec->capsrc_nids;
3103 if (!nids)
3104 nids = spec->adc_nids;
3105 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
3106 if (err < 0)
3107 return err;
3108 }
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003109 }
3110 if (spec->cap_mixer) {
3111 const char *kname = kctl ? kctl->id.name : NULL;
3112 for (knew = spec->cap_mixer; knew->name; knew++) {
3113 if (kname && strcmp(knew->name, kname) == 0)
3114 continue;
3115 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3116 for (i = 0; kctl && i < kctl->count; i++) {
3117 err = snd_hda_add_nid(codec, kctl, i,
3118 spec->adc_nids[i]);
3119 if (err < 0)
3120 return err;
3121 }
3122 }
3123 }
3124
3125 /* other nid->control mapping */
3126 for (i = 0; i < spec->num_mixers; i++) {
3127 for (knew = spec->mixers[i]; knew->name; knew++) {
3128 if (knew->iface != NID_MAPPING)
3129 continue;
3130 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3131 if (kctl == NULL)
3132 continue;
3133 u = knew->subdevice;
3134 for (j = 0; j < 4; j++, u >>= 8) {
3135 nid = u & 0x3f;
3136 if (nid == 0)
3137 continue;
3138 switch (u & 0xc0) {
3139 case SUBDEV_SPEAKER_:
3140 nid = spec->autocfg.speaker_pins[nid];
3141 break;
3142 case SUBDEV_LINE_:
3143 nid = spec->autocfg.line_out_pins[nid];
3144 break;
3145 case SUBDEV_HP_:
3146 nid = spec->autocfg.hp_pins[nid];
3147 break;
3148 default:
3149 continue;
3150 }
3151 err = snd_hda_add_nid(codec, kctl, 0, nid);
3152 if (err < 0)
3153 return err;
3154 }
3155 u = knew->private_value;
3156 for (j = 0; j < 4; j++, u >>= 8) {
3157 nid = u & 0xff;
3158 if (nid == 0)
3159 continue;
3160 err = snd_hda_add_nid(codec, kctl, 0, nid);
3161 if (err < 0)
3162 return err;
3163 }
3164 }
3165 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01003166
3167 alc_free_kctls(codec); /* no longer needed */
3168
Linus Torvalds1da177e2005-04-16 15:20:36 -07003169 return 0;
3170}
3171
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003172
Linus Torvalds1da177e2005-04-16 15:20:36 -07003173/*
3174 * initialize the codec volumes, etc
3175 */
3176
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003177/*
3178 * generic initialization of ADC, input mixers and output mixers
3179 */
3180static struct hda_verb alc880_volume_init_verbs[] = {
3181 /*
3182 * Unmute ADC0-2 and set the default input to mic-in
3183 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003184 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003185 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003186 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003187 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003188 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003189 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003190
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003191 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3192 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003193 * Note: PASD motherboards uses the Line In 2 as the input for front
3194 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003195 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003196 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003197 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3198 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3199 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3200 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3201 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3202 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3203 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003204
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003205 /*
3206 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003207 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003208 /* set vol=0 to output mixers */
3209 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3210 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3211 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3212 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3213 /* set up input amps for analog loopback */
3214 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003215 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3216 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003217 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3218 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003219 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3220 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003221 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3222 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003223
3224 { }
3225};
3226
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003227/*
3228 * 3-stack pin configuration:
3229 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
3230 */
3231static struct hda_verb alc880_pin_3stack_init_verbs[] = {
3232 /*
3233 * preset connection lists of input pins
3234 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3235 */
3236 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3237 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3238 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3239
3240 /*
3241 * Set pin mode and muting
3242 */
3243 /* set front pin widgets 0x14 for output */
3244 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3245 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3246 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3247 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3248 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3249 /* Mic2 (as headphone out) for HP output */
3250 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3251 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3252 /* Line In pin widget for input */
3253 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3254 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3255 /* Line2 (as front mic) pin widget for input and vref at 80% */
3256 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3257 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3258 /* CD pin widget for input */
3259 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3260
3261 { }
3262};
3263
3264/*
3265 * 5-stack pin configuration:
3266 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
3267 * line-in/side = 0x1a, f-mic = 0x1b
3268 */
3269static struct hda_verb alc880_pin_5stack_init_verbs[] = {
3270 /*
3271 * preset connection lists of input pins
3272 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3273 */
3274 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3275 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
3276
3277 /*
3278 * Set pin mode and muting
3279 */
3280 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02003281 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3282 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3283 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3284 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003285 /* unmute pins for output (no gain on this amp) */
3286 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3287 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3288 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3289 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3290
Linus Torvalds1da177e2005-04-16 15:20:36 -07003291 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003292 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003293 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3294 /* Mic2 (as headphone out) for HP output */
3295 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003296 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003297 /* Line In pin widget for input */
3298 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3299 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3300 /* Line2 (as front mic) pin widget for input and vref at 80% */
3301 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3302 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3303 /* CD pin widget for input */
3304 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003305
3306 { }
3307};
3308
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003309/*
3310 * W810 pin configuration:
3311 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
3312 */
3313static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003314 /* hphone/speaker input selector: front DAC */
3315 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
3316
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003317 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3318 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3319 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3320 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3321 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3322 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3323
3324 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003325 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003326
Linus Torvalds1da177e2005-04-16 15:20:36 -07003327 { }
3328};
3329
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003330/*
3331 * Z71V pin configuration:
3332 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
3333 */
3334static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003335 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003336 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02003337 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003338 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003339
Takashi Iwai16ded522005-06-10 19:58:24 +02003340 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003341 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003342 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003343 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003344
3345 { }
3346};
3347
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003348/*
3349 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003350 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
3351 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003352 */
3353static struct hda_verb alc880_pin_6stack_init_verbs[] = {
3354 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3355
Takashi Iwai16ded522005-06-10 19:58:24 +02003356 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003357 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003358 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003359 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003360 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003361 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003362 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003363 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3364
Takashi Iwai16ded522005-06-10 19:58:24 +02003365 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003366 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003367 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003368 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003369 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003370 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003371 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02003372 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003373 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003374
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003375 { }
3376};
Takashi Iwai16ded522005-06-10 19:58:24 +02003377
Kailang Yangccc656c2006-10-17 12:32:26 +02003378/*
3379 * Uniwill pin configuration:
3380 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3381 * line = 0x1a
3382 */
3383static struct hda_verb alc880_uniwill_init_verbs[] = {
3384 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3385
3386 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3387 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3388 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3389 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3390 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3391 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3392 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3393 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3394 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3395 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3396 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3397 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3398 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3399 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3400
3401 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3402 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3403 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3404 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3405 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3406 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3407 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3408 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3409 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3410
3411 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3412 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3413
3414 { }
3415};
3416
3417/*
3418* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02003419* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02003420 */
3421static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3422 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3423
3424 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3425 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3426 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3427 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3428 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3429 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3430 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3431 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3432 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3433 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3434 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3435 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3436
3437 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3438 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3439 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3440 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3441 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3442 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3443
3444 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3445 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3446
3447 { }
3448};
3449
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003450static struct hda_verb alc880_beep_init_verbs[] = {
3451 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3452 { }
3453};
3454
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003455/* auto-toggle front mic */
Anisse Astiereeb43382010-12-16 12:19:47 +01003456static void alc88x_simple_mic_automute(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003457{
3458 unsigned int present;
3459 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02003460
Wu Fengguang864f92b2009-11-18 12:38:02 +08003461 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003462 bits = present ? HDA_AMP_MUTE : 0;
3463 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003464}
3465
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003466static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003467{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003468 struct alc_spec *spec = codec->spec;
3469
3470 spec->autocfg.hp_pins[0] = 0x14;
3471 spec->autocfg.speaker_pins[0] = 0x15;
3472 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwaid922b512011-04-28 12:18:53 +02003473 spec->automute = 1;
3474 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003475}
3476
3477static void alc880_uniwill_init_hook(struct hda_codec *codec)
3478{
Takashi Iwaid922b512011-04-28 12:18:53 +02003479 alc_hp_automute(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +01003480 alc88x_simple_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02003481}
3482
3483static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3484 unsigned int res)
3485{
3486 /* Looks like the unsol event is incompatible with the standard
3487 * definition. 4bit tag is placed at 28 bit!
3488 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003489 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003490 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +01003491 alc88x_simple_mic_automute(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003492 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003493 default:
Takashi Iwaid922b512011-04-28 12:18:53 +02003494 alc_sku_unsol_event(codec, res);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003495 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003496 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003497}
3498
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003499static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003500{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003501 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003502
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003503 spec->autocfg.hp_pins[0] = 0x14;
3504 spec->autocfg.speaker_pins[0] = 0x15;
Takashi Iwaid922b512011-04-28 12:18:53 +02003505 spec->automute = 1;
3506 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yangccc656c2006-10-17 12:32:26 +02003507}
3508
3509static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3510{
3511 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003512
Kailang Yangccc656c2006-10-17 12:32:26 +02003513 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003514 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3515 present &= HDA_AMP_VOLMASK;
3516 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3517 HDA_AMP_VOLMASK, present);
3518 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3519 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003520}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003521
Kailang Yangccc656c2006-10-17 12:32:26 +02003522static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3523 unsigned int res)
3524{
3525 /* Looks like the unsol event is incompatible with the standard
3526 * definition. 4bit tag is placed at 28 bit!
3527 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003528 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003529 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003530 else
Takashi Iwaid922b512011-04-28 12:18:53 +02003531 alc_sku_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003532}
3533
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003534/*
3535 * F1734 pin configuration:
3536 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3537 */
3538static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003539 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003540 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3541 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3542 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3543 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3544
3545 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3546 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3547 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3548 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3549
3550 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3551 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003552 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003553 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3554 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3555 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3556 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3557 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3558 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003559
Takashi Iwai937b4162008-02-11 14:52:36 +01003560 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3561 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3562
Takashi Iwai16ded522005-06-10 19:58:24 +02003563 { }
3564};
3565
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003566/*
3567 * ASUS pin configuration:
3568 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3569 */
3570static struct hda_verb alc880_pin_asus_init_verbs[] = {
3571 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3572 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3573 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3574 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3575
3576 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3577 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3578 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3579 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3580 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3581 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3582 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3583 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3584
3585 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3586 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3587 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3588 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3589 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3590 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3591 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3592 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3593 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003594
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003595 { }
3596};
3597
3598/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003599#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3600#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003601#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003602
Kailang Yangdf694da2005-12-05 19:42:22 +01003603/* Clevo m520g init */
3604static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3605 /* headphone output */
3606 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3607 /* line-out */
3608 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3609 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3610 /* Line-in */
3611 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3612 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3613 /* CD */
3614 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3615 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3616 /* Mic1 (rear panel) */
3617 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3618 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3619 /* Mic2 (front panel) */
3620 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3621 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3622 /* headphone */
3623 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3624 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3625 /* change to EAPD mode */
3626 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3627 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3628
3629 { }
3630};
3631
3632static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003633 /* change to EAPD mode */
3634 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3635 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3636
Kailang Yangdf694da2005-12-05 19:42:22 +01003637 /* Headphone output */
3638 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3639 /* Front output*/
3640 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3641 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3642
3643 /* Line In pin widget for input */
3644 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3645 /* CD pin widget for input */
3646 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3647 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3648 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3649
3650 /* change to EAPD mode */
3651 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3652 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3653
3654 { }
3655};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003656
3657/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003658 * LG m1 express dual
3659 *
3660 * Pin assignment:
3661 * Rear Line-In/Out (blue): 0x14
3662 * Build-in Mic-In: 0x15
3663 * Speaker-out: 0x17
3664 * HP-Out (green): 0x1b
3665 * Mic-In/Out (red): 0x19
3666 * SPDIF-Out: 0x1e
3667 */
3668
3669/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3670static hda_nid_t alc880_lg_dac_nids[3] = {
3671 0x05, 0x02, 0x03
3672};
3673
3674/* seems analog CD is not working */
3675static struct hda_input_mux alc880_lg_capture_source = {
3676 .num_items = 3,
3677 .items = {
3678 { "Mic", 0x1 },
3679 { "Line", 0x5 },
3680 { "Internal Mic", 0x6 },
3681 },
3682};
3683
3684/* 2,4,6 channel modes */
3685static struct hda_verb alc880_lg_ch2_init[] = {
3686 /* set line-in and mic-in to input */
3687 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3688 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3689 { }
3690};
3691
3692static struct hda_verb alc880_lg_ch4_init[] = {
3693 /* set line-in to out and mic-in to input */
3694 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3695 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3696 { }
3697};
3698
3699static struct hda_verb alc880_lg_ch6_init[] = {
3700 /* set line-in and mic-in to output */
3701 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3702 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3703 { }
3704};
3705
3706static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3707 { 2, alc880_lg_ch2_init },
3708 { 4, alc880_lg_ch4_init },
3709 { 6, alc880_lg_ch6_init },
3710};
3711
3712static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003713 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3714 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003715 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3716 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3717 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3718 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3719 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3720 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3721 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3722 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3723 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3724 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3725 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3726 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3727 {
3728 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3729 .name = "Channel Mode",
3730 .info = alc_ch_mode_info,
3731 .get = alc_ch_mode_get,
3732 .put = alc_ch_mode_put,
3733 },
3734 { } /* end */
3735};
3736
3737static struct hda_verb alc880_lg_init_verbs[] = {
3738 /* set capture source to mic-in */
3739 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3740 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3741 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3742 /* mute all amp mixer inputs */
3743 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003744 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3745 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003746 /* line-in to input */
3747 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3748 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3749 /* built-in mic */
3750 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3751 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3752 /* speaker-out */
3753 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3754 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3755 /* mic-in to input */
3756 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3757 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3758 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3759 /* HP-out */
3760 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3761 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3762 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3763 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003764 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003765 { }
3766};
3767
3768/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003769static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003770{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003771 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003772
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003773 spec->autocfg.hp_pins[0] = 0x1b;
3774 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02003775 spec->automute = 1;
3776 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003777}
3778
3779/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003780 * LG LW20
3781 *
3782 * Pin assignment:
3783 * Speaker-out: 0x14
3784 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003785 * Built-in Mic-In: 0x19
3786 * Line-In: 0x1b
3787 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003788 * SPDIF-Out: 0x1e
3789 */
3790
Takashi Iwaid6815182006-03-23 16:06:23 +01003791static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003792 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003793 .items = {
3794 { "Mic", 0x0 },
3795 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003796 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003797 },
3798};
3799
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003800#define alc880_lg_lw_modes alc880_threestack_modes
3801
Takashi Iwaid6815182006-03-23 16:06:23 +01003802static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003803 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3804 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3805 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3806 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3807 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3808 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3809 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3810 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3811 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3812 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003813 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3814 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3815 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3816 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003817 {
3818 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3819 .name = "Channel Mode",
3820 .info = alc_ch_mode_info,
3821 .get = alc_ch_mode_get,
3822 .put = alc_ch_mode_put,
3823 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003824 { } /* end */
3825};
3826
3827static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003828 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3829 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3830 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3831
Takashi Iwaid6815182006-03-23 16:06:23 +01003832 /* set capture source to mic-in */
3833 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3834 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3835 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003836 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003837 /* speaker-out */
3838 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3839 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3840 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003841 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3842 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3843 /* mic-in to input */
3844 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3845 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3846 /* built-in mic */
3847 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3848 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3849 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003850 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003851 { }
3852};
3853
3854/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003855static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003856{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003857 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003858
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003859 spec->autocfg.hp_pins[0] = 0x1b;
3860 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +02003861 spec->automute = 1;
3862 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwaid6815182006-03-23 16:06:23 +01003863}
3864
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003865static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3866 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3867 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3868 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3869 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3870 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3871 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3872 { } /* end */
3873};
3874
3875static struct hda_input_mux alc880_medion_rim_capture_source = {
3876 .num_items = 2,
3877 .items = {
3878 { "Mic", 0x0 },
3879 { "Internal Mic", 0x1 },
3880 },
3881};
3882
3883static struct hda_verb alc880_medion_rim_init_verbs[] = {
3884 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3885
3886 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3887 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3888
3889 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3890 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3891 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3892 /* Mic2 (as headphone out) for HP output */
3893 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3894 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3895 /* Internal Speaker */
3896 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3897 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3898
3899 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3900 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3901
3902 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3903 { }
3904};
3905
3906/* toggle speaker-output according to the hp-jack state */
3907static void alc880_medion_rim_automute(struct hda_codec *codec)
3908{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003909 struct alc_spec *spec = codec->spec;
Takashi Iwaid922b512011-04-28 12:18:53 +02003910 alc_hp_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003911 /* toggle EAPD */
3912 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003913 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3914 else
3915 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3916}
3917
3918static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3919 unsigned int res)
3920{
3921 /* Looks like the unsol event is incompatible with the standard
3922 * definition. 4bit tag is placed at 28 bit!
3923 */
3924 if ((res >> 28) == ALC880_HP_EVENT)
3925 alc880_medion_rim_automute(codec);
3926}
3927
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003928static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003929{
3930 struct alc_spec *spec = codec->spec;
3931
3932 spec->autocfg.hp_pins[0] = 0x14;
3933 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaid922b512011-04-28 12:18:53 +02003934 spec->automute = 1;
3935 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003936}
3937
Takashi Iwaicb53c622007-08-10 17:21:45 +02003938#ifdef CONFIG_SND_HDA_POWER_SAVE
3939static struct hda_amp_list alc880_loopbacks[] = {
3940 { 0x0b, HDA_INPUT, 0 },
3941 { 0x0b, HDA_INPUT, 1 },
3942 { 0x0b, HDA_INPUT, 2 },
3943 { 0x0b, HDA_INPUT, 3 },
3944 { 0x0b, HDA_INPUT, 4 },
3945 { } /* end */
3946};
3947
3948static struct hda_amp_list alc880_lg_loopbacks[] = {
3949 { 0x0b, HDA_INPUT, 1 },
3950 { 0x0b, HDA_INPUT, 6 },
3951 { 0x0b, HDA_INPUT, 7 },
3952 { } /* end */
3953};
3954#endif
3955
Takashi Iwaid6815182006-03-23 16:06:23 +01003956/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003957 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003958 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003959
Takashi Iwai584c0c42011-03-10 12:51:11 +01003960static void alc_init_special_input_src(struct hda_codec *codec);
3961
Linus Torvalds1da177e2005-04-16 15:20:36 -07003962static int alc_init(struct hda_codec *codec)
3963{
3964 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003965 unsigned int i;
3966
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003967 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003968 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003969
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003970 for (i = 0; i < spec->num_init_verbs; i++)
3971 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwai584c0c42011-03-10 12:51:11 +01003972 alc_init_special_input_src(codec);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003973
3974 if (spec->init_hook)
3975 spec->init_hook(codec);
3976
Takashi Iwai58701122011-01-13 15:41:45 +01003977 alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT);
3978
Takashi Iwai9e5341b2010-09-21 09:57:06 +02003979 hda_call_check_power_status(codec, 0x01);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003980 return 0;
3981}
3982
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003983static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3984{
3985 struct alc_spec *spec = codec->spec;
3986
3987 if (spec->unsol_event)
3988 spec->unsol_event(codec, res);
3989}
3990
Takashi Iwaicb53c622007-08-10 17:21:45 +02003991#ifdef CONFIG_SND_HDA_POWER_SAVE
3992static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3993{
3994 struct alc_spec *spec = codec->spec;
3995 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3996}
3997#endif
3998
Linus Torvalds1da177e2005-04-16 15:20:36 -07003999/*
4000 * Analog playback callbacks
4001 */
4002static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
4003 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004004 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004005{
4006 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01004007 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
4008 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004009}
4010
4011static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
4012 struct hda_codec *codec,
4013 unsigned int stream_tag,
4014 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004015 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004016{
4017 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004018 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
4019 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004020}
4021
4022static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
4023 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004024 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004025{
4026 struct alc_spec *spec = codec->spec;
4027 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
4028}
4029
4030/*
4031 * Digital out
4032 */
4033static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
4034 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004035 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004036{
4037 struct alc_spec *spec = codec->spec;
4038 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
4039}
4040
Takashi Iwai6b97eb42007-04-05 14:51:48 +02004041static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
4042 struct hda_codec *codec,
4043 unsigned int stream_tag,
4044 unsigned int format,
4045 struct snd_pcm_substream *substream)
4046{
4047 struct alc_spec *spec = codec->spec;
4048 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
4049 stream_tag, format, substream);
4050}
4051
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01004052static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
4053 struct hda_codec *codec,
4054 struct snd_pcm_substream *substream)
4055{
4056 struct alc_spec *spec = codec->spec;
4057 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
4058}
4059
Linus Torvalds1da177e2005-04-16 15:20:36 -07004060static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
4061 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004062 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004063{
4064 struct alc_spec *spec = codec->spec;
4065 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
4066}
4067
4068/*
4069 * Analog capture
4070 */
Takashi Iwai63300792008-01-24 15:31:36 +01004071static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004072 struct hda_codec *codec,
4073 unsigned int stream_tag,
4074 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004075 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004076{
4077 struct alc_spec *spec = codec->spec;
4078
Takashi Iwai63300792008-01-24 15:31:36 +01004079 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07004080 stream_tag, 0, format);
4081 return 0;
4082}
4083
Takashi Iwai63300792008-01-24 15:31:36 +01004084static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004085 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004086 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004087{
4088 struct alc_spec *spec = codec->spec;
4089
Takashi Iwai888afa12008-03-18 09:57:50 +01004090 snd_hda_codec_cleanup_stream(codec,
4091 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004092 return 0;
4093}
4094
Takashi Iwai840b64c2010-07-13 22:49:01 +02004095/* analog capture with dynamic dual-adc changes */
4096static int dualmic_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
4097 struct hda_codec *codec,
4098 unsigned int stream_tag,
4099 unsigned int format,
4100 struct snd_pcm_substream *substream)
4101{
4102 struct alc_spec *spec = codec->spec;
4103 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
4104 spec->cur_adc_stream_tag = stream_tag;
4105 spec->cur_adc_format = format;
4106 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
4107 return 0;
4108}
4109
4110static int dualmic_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
4111 struct hda_codec *codec,
4112 struct snd_pcm_substream *substream)
4113{
4114 struct alc_spec *spec = codec->spec;
4115 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
4116 spec->cur_adc = 0;
4117 return 0;
4118}
4119
4120static struct hda_pcm_stream dualmic_pcm_analog_capture = {
4121 .substreams = 1,
4122 .channels_min = 2,
4123 .channels_max = 2,
4124 .nid = 0, /* fill later */
4125 .ops = {
4126 .prepare = dualmic_capture_pcm_prepare,
4127 .cleanup = dualmic_capture_pcm_cleanup
4128 },
4129};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004130
4131/*
4132 */
4133static struct hda_pcm_stream alc880_pcm_analog_playback = {
4134 .substreams = 1,
4135 .channels_min = 2,
4136 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004137 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004138 .ops = {
4139 .open = alc880_playback_pcm_open,
4140 .prepare = alc880_playback_pcm_prepare,
4141 .cleanup = alc880_playback_pcm_cleanup
4142 },
4143};
4144
4145static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01004146 .substreams = 1,
4147 .channels_min = 2,
4148 .channels_max = 2,
4149 /* NID is set in alc_build_pcms */
4150};
4151
4152static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
4153 .substreams = 1,
4154 .channels_min = 2,
4155 .channels_max = 2,
4156 /* NID is set in alc_build_pcms */
4157};
4158
4159static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
4160 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004161 .channels_min = 2,
4162 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004163 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004164 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01004165 .prepare = alc880_alt_capture_pcm_prepare,
4166 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004167 },
4168};
4169
4170static struct hda_pcm_stream alc880_pcm_digital_playback = {
4171 .substreams = 1,
4172 .channels_min = 2,
4173 .channels_max = 2,
4174 /* NID is set in alc_build_pcms */
4175 .ops = {
4176 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02004177 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01004178 .prepare = alc880_dig_playback_pcm_prepare,
4179 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004180 },
4181};
4182
4183static struct hda_pcm_stream alc880_pcm_digital_capture = {
4184 .substreams = 1,
4185 .channels_min = 2,
4186 .channels_max = 2,
4187 /* NID is set in alc_build_pcms */
4188};
4189
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004190/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01004191static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004192 .substreams = 0,
4193 .channels_min = 0,
4194 .channels_max = 0,
4195};
4196
Linus Torvalds1da177e2005-04-16 15:20:36 -07004197static int alc_build_pcms(struct hda_codec *codec)
4198{
4199 struct alc_spec *spec = codec->spec;
4200 struct hda_pcm *info = spec->pcm_rec;
4201 int i;
4202
4203 codec->num_pcms = 1;
4204 codec->pcm_info = info;
4205
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004206 if (spec->no_analog)
4207 goto skip_analog;
4208
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004209 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
4210 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004211 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01004212
Takashi Iwai4a471b72005-12-07 13:56:29 +01004213 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004214 if (snd_BUG_ON(!spec->multiout.dac_nids))
4215 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004216 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
4217 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
4218 }
4219 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004220 if (snd_BUG_ON(!spec->adc_nids))
4221 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004222 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
4223 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
4224 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004225
Takashi Iwai4a471b72005-12-07 13:56:29 +01004226 if (spec->channel_mode) {
4227 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
4228 for (i = 0; i < spec->num_channel_mode; i++) {
4229 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
4230 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
4231 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004232 }
4233 }
4234
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004235 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02004236 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004237 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004238 snprintf(spec->stream_name_digital,
4239 sizeof(spec->stream_name_digital),
4240 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02004241 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08004242 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004243 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004244 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01004245 if (spec->dig_out_type)
4246 info->pcm_type = spec->dig_out_type;
4247 else
4248 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004249 if (spec->multiout.dig_out_nid &&
4250 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004251 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
4252 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
4253 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004254 if (spec->dig_in_nid &&
4255 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004256 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
4257 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
4258 }
Takashi Iwai963f8032008-08-11 10:04:40 +02004259 /* FIXME: do we need this for all Realtek codec models? */
4260 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004261 }
4262
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004263 if (spec->no_analog)
4264 return 0;
4265
Takashi Iwaie08a0072006-09-07 17:52:14 +02004266 /* If the use of more than one ADC is requested for the current
4267 * model, configure a second analog capture-only PCM.
4268 */
4269 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01004270 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
4271 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02004272 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004273 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004274 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01004275 if (spec->alt_dac_nid) {
4276 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4277 *spec->stream_analog_alt_playback;
4278 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
4279 spec->alt_dac_nid;
4280 } else {
4281 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4282 alc_pcm_null_stream;
4283 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
4284 }
4285 if (spec->num_adc_nids > 1) {
4286 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4287 *spec->stream_analog_alt_capture;
4288 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
4289 spec->adc_nids[1];
4290 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
4291 spec->num_adc_nids - 1;
4292 } else {
4293 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4294 alc_pcm_null_stream;
4295 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004296 }
4297 }
4298
Linus Torvalds1da177e2005-04-16 15:20:36 -07004299 return 0;
4300}
4301
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004302static inline void alc_shutup(struct hda_codec *codec)
4303{
Takashi Iwai1c7161532011-04-07 10:37:16 +02004304 struct alc_spec *spec = codec->spec;
4305
4306 if (spec && spec->shutup)
4307 spec->shutup(codec);
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004308 snd_hda_shutup_pins(codec);
4309}
4310
Takashi Iwai603c4012008-07-30 15:01:44 +02004311static void alc_free_kctls(struct hda_codec *codec)
4312{
4313 struct alc_spec *spec = codec->spec;
4314
4315 if (spec->kctls.list) {
4316 struct snd_kcontrol_new *kctl = spec->kctls.list;
4317 int i;
4318 for (i = 0; i < spec->kctls.used; i++)
4319 kfree(kctl[i].name);
4320 }
4321 snd_array_free(&spec->kctls);
4322}
4323
Linus Torvalds1da177e2005-04-16 15:20:36 -07004324static void alc_free(struct hda_codec *codec)
4325{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004326 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004327
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004328 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004329 return;
4330
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004331 alc_shutup(codec);
Takashi Iwaicd372fb2011-03-03 14:40:14 +01004332 snd_hda_input_jack_free(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02004333 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004334 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004335 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004336}
4337
Hector Martinf5de24b2009-12-20 22:51:31 +01004338#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05004339static void alc_power_eapd(struct hda_codec *codec)
4340{
Takashi Iwai691f1fc2011-04-07 10:31:43 +02004341 alc_auto_setup_eapd(codec, false);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004342}
4343
Hector Martinf5de24b2009-12-20 22:51:31 +01004344static int alc_suspend(struct hda_codec *codec, pm_message_t state)
4345{
4346 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004347 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004348 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05004349 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004350 return 0;
4351}
4352#endif
4353
Takashi Iwaie044c392008-10-27 16:56:24 +01004354#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01004355static int alc_resume(struct hda_codec *codec)
4356{
Takashi Iwai1c7161532011-04-07 10:37:16 +02004357 msleep(150); /* to avoid pop noise */
Takashi Iwaie044c392008-10-27 16:56:24 +01004358 codec->patch_ops.init(codec);
4359 snd_hda_codec_resume_amp(codec);
4360 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +02004361 hda_call_check_power_status(codec, 0x01);
Takashi Iwaie044c392008-10-27 16:56:24 +01004362 return 0;
4363}
Takashi Iwaie044c392008-10-27 16:56:24 +01004364#endif
4365
Linus Torvalds1da177e2005-04-16 15:20:36 -07004366/*
4367 */
4368static struct hda_codec_ops alc_patch_ops = {
4369 .build_controls = alc_build_controls,
4370 .build_pcms = alc_build_pcms,
4371 .init = alc_init,
4372 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004373 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01004374#ifdef SND_HDA_NEEDS_RESUME
4375 .resume = alc_resume,
4376#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02004377#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01004378 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004379 .check_power_status = alc_check_power_status,
4380#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05004381 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004382};
4383
Kailang Yangc027ddc2010-03-19 11:33:06 +01004384/* replace the codec chip_name with the given string */
4385static int alc_codec_rename(struct hda_codec *codec, const char *name)
4386{
4387 kfree(codec->chip_name);
4388 codec->chip_name = kstrdup(name, GFP_KERNEL);
4389 if (!codec->chip_name) {
4390 alc_free(codec);
4391 return -ENOMEM;
4392 }
4393 return 0;
4394}
4395
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004396/*
4397 * Test configuration for debugging
4398 *
4399 * Almost all inputs/outputs are enabled. I/O pins can be configured via
4400 * enum controls.
4401 */
4402#ifdef CONFIG_SND_DEBUG
4403static hda_nid_t alc880_test_dac_nids[4] = {
4404 0x02, 0x03, 0x04, 0x05
4405};
4406
4407static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004408 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004409 .items = {
4410 { "In-1", 0x0 },
4411 { "In-2", 0x1 },
4412 { "In-3", 0x2 },
4413 { "In-4", 0x3 },
4414 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004415 { "Front", 0x5 },
4416 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004417 },
4418};
4419
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004420static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004421 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004422 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004423 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004424 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004425};
4426
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004427static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
4428 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004429{
4430 static char *texts[] = {
4431 "N/A", "Line Out", "HP Out",
4432 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
4433 };
4434 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4435 uinfo->count = 1;
4436 uinfo->value.enumerated.items = 8;
4437 if (uinfo->value.enumerated.item >= 8)
4438 uinfo->value.enumerated.item = 7;
4439 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4440 return 0;
4441}
4442
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004443static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
4444 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004445{
4446 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4447 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4448 unsigned int pin_ctl, item = 0;
4449
4450 pin_ctl = snd_hda_codec_read(codec, nid, 0,
4451 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4452 if (pin_ctl & AC_PINCTL_OUT_EN) {
4453 if (pin_ctl & AC_PINCTL_HP_EN)
4454 item = 2;
4455 else
4456 item = 1;
4457 } else if (pin_ctl & AC_PINCTL_IN_EN) {
4458 switch (pin_ctl & AC_PINCTL_VREFEN) {
4459 case AC_PINCTL_VREF_HIZ: item = 3; break;
4460 case AC_PINCTL_VREF_50: item = 4; break;
4461 case AC_PINCTL_VREF_GRD: item = 5; break;
4462 case AC_PINCTL_VREF_80: item = 6; break;
4463 case AC_PINCTL_VREF_100: item = 7; break;
4464 }
4465 }
4466 ucontrol->value.enumerated.item[0] = item;
4467 return 0;
4468}
4469
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004470static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
4471 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004472{
4473 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4474 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4475 static unsigned int ctls[] = {
4476 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
4477 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
4478 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
4479 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
4480 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
4481 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
4482 };
4483 unsigned int old_ctl, new_ctl;
4484
4485 old_ctl = snd_hda_codec_read(codec, nid, 0,
4486 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4487 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
4488 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004489 int val;
4490 snd_hda_codec_write_cache(codec, nid, 0,
4491 AC_VERB_SET_PIN_WIDGET_CONTROL,
4492 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02004493 val = ucontrol->value.enumerated.item[0] >= 3 ?
4494 HDA_AMP_MUTE : 0;
4495 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
4496 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004497 return 1;
4498 }
4499 return 0;
4500}
4501
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004502static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
4503 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004504{
4505 static char *texts[] = {
4506 "Front", "Surround", "CLFE", "Side"
4507 };
4508 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4509 uinfo->count = 1;
4510 uinfo->value.enumerated.items = 4;
4511 if (uinfo->value.enumerated.item >= 4)
4512 uinfo->value.enumerated.item = 3;
4513 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4514 return 0;
4515}
4516
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004517static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
4518 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004519{
4520 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4521 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4522 unsigned int sel;
4523
4524 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4525 ucontrol->value.enumerated.item[0] = sel & 3;
4526 return 0;
4527}
4528
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004529static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4530 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004531{
4532 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4533 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4534 unsigned int sel;
4535
4536 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4537 if (ucontrol->value.enumerated.item[0] != sel) {
4538 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004539 snd_hda_codec_write_cache(codec, nid, 0,
4540 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004541 return 1;
4542 }
4543 return 0;
4544}
4545
4546#define PIN_CTL_TEST(xname,nid) { \
4547 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4548 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004549 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004550 .info = alc_test_pin_ctl_info, \
4551 .get = alc_test_pin_ctl_get, \
4552 .put = alc_test_pin_ctl_put, \
4553 .private_value = nid \
4554 }
4555
4556#define PIN_SRC_TEST(xname,nid) { \
4557 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4558 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004559 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004560 .info = alc_test_pin_src_info, \
4561 .get = alc_test_pin_src_get, \
4562 .put = alc_test_pin_src_put, \
4563 .private_value = nid \
4564 }
4565
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004566static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004567 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4568 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4569 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4570 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004571 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4572 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4573 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4574 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004575 PIN_CTL_TEST("Front Pin Mode", 0x14),
4576 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4577 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4578 PIN_CTL_TEST("Side Pin Mode", 0x17),
4579 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4580 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4581 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4582 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4583 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4584 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4585 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4586 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4587 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4588 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4589 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4590 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4591 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4592 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4593 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4594 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4595 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4596 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004597 {
4598 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4599 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004600 .info = alc_ch_mode_info,
4601 .get = alc_ch_mode_get,
4602 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004603 },
4604 { } /* end */
4605};
4606
4607static struct hda_verb alc880_test_init_verbs[] = {
4608 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004609 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4610 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4611 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4612 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4613 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4614 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4615 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4616 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004617 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004618 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4619 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4620 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4621 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004622 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004623 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4624 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4625 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4626 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004627 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004628 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4629 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4630 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4631 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004632 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004633 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4634 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004635 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4636 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4637 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004638 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004639 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4640 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4641 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4642 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004643 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004644 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004645 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004646 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004647 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004648 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004649 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004650 /* Analog input/passthru */
4651 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4652 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4653 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4654 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4655 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004656 { }
4657};
4658#endif
4659
Linus Torvalds1da177e2005-04-16 15:20:36 -07004660/*
4661 */
4662
Takashi Iwaiea734962011-01-17 11:29:34 +01004663static const char * const alc880_models[ALC880_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004664 [ALC880_3ST] = "3stack",
4665 [ALC880_TCL_S700] = "tcl",
4666 [ALC880_3ST_DIG] = "3stack-digout",
4667 [ALC880_CLEVO] = "clevo",
4668 [ALC880_5ST] = "5stack",
4669 [ALC880_5ST_DIG] = "5stack-digout",
4670 [ALC880_W810] = "w810",
4671 [ALC880_Z71V] = "z71v",
4672 [ALC880_6ST] = "6stack",
4673 [ALC880_6ST_DIG] = "6stack-digout",
4674 [ALC880_ASUS] = "asus",
4675 [ALC880_ASUS_W1V] = "asus-w1v",
4676 [ALC880_ASUS_DIG] = "asus-dig",
4677 [ALC880_ASUS_DIG2] = "asus-dig2",
4678 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004679 [ALC880_UNIWILL_P53] = "uniwill-p53",
4680 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004681 [ALC880_F1734] = "F1734",
4682 [ALC880_LG] = "lg",
4683 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004684 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004685#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004686 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004687#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004688 [ALC880_AUTO] = "auto",
4689};
4690
4691static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004692 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004693 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4694 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4695 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4696 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4697 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4698 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4699 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4700 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004701 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4702 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004703 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4704 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4705 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4706 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4707 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4708 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4709 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4710 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4711 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4712 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004713 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004714 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4715 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4716 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004717 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004718 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004719 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4720 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004721 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4722 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004723 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4724 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4725 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4726 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004727 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4728 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004729 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004730 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004731 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Justin P. Mattocka2e2bc22011-02-24 22:16:02 -08004732 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004733 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4734 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004735 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004736 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004737 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004738 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004739 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004740 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Daniel T Chen33535412010-04-22 07:15:26 -04004741 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004742 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004743 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004744 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
Daniel T Chen77c4d5c2010-12-02 22:45:45 -05004745 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004746 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004747 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004748 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4749 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4750 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4751 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004752 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4753 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004754 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004755 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004756 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4757 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004758 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4759 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4760 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004761 /* default Intel */
4762 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004763 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4764 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004765 {}
4766};
4767
Takashi Iwai16ded522005-06-10 19:58:24 +02004768/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004769 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004770 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004771static struct alc_config_preset alc880_presets[] = {
4772 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004773 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004774 .init_verbs = { alc880_volume_init_verbs,
4775 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004776 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004777 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004778 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4779 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004780 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004781 .input_mux = &alc880_capture_source,
4782 },
4783 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004784 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004785 .init_verbs = { alc880_volume_init_verbs,
4786 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004787 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004788 .dac_nids = alc880_dac_nids,
4789 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004790 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4791 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004792 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004793 .input_mux = &alc880_capture_source,
4794 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004795 [ALC880_TCL_S700] = {
4796 .mixers = { alc880_tcl_s700_mixer },
4797 .init_verbs = { alc880_volume_init_verbs,
4798 alc880_pin_tcl_S700_init_verbs,
4799 alc880_gpio2_init_verbs },
4800 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4801 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004802 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4803 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004804 .hp_nid = 0x03,
4805 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4806 .channel_mode = alc880_2_jack_modes,
4807 .input_mux = &alc880_capture_source,
4808 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004809 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004810 .mixers = { alc880_three_stack_mixer,
4811 alc880_five_stack_mixer},
4812 .init_verbs = { alc880_volume_init_verbs,
4813 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004814 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4815 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004816 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4817 .channel_mode = alc880_fivestack_modes,
4818 .input_mux = &alc880_capture_source,
4819 },
4820 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004821 .mixers = { alc880_three_stack_mixer,
4822 alc880_five_stack_mixer },
4823 .init_verbs = { alc880_volume_init_verbs,
4824 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004825 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4826 .dac_nids = alc880_dac_nids,
4827 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004828 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4829 .channel_mode = alc880_fivestack_modes,
4830 .input_mux = &alc880_capture_source,
4831 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004832 [ALC880_6ST] = {
4833 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004834 .init_verbs = { alc880_volume_init_verbs,
4835 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004836 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4837 .dac_nids = alc880_6st_dac_nids,
4838 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4839 .channel_mode = alc880_sixstack_modes,
4840 .input_mux = &alc880_6stack_capture_source,
4841 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004842 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004843 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004844 .init_verbs = { alc880_volume_init_verbs,
4845 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004846 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4847 .dac_nids = alc880_6st_dac_nids,
4848 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004849 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4850 .channel_mode = alc880_sixstack_modes,
4851 .input_mux = &alc880_6stack_capture_source,
4852 },
4853 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004854 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004855 .init_verbs = { alc880_volume_init_verbs,
4856 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004857 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004858 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4859 .dac_nids = alc880_w810_dac_nids,
4860 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004861 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4862 .channel_mode = alc880_w810_modes,
4863 .input_mux = &alc880_capture_source,
4864 },
4865 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004866 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004867 .init_verbs = { alc880_volume_init_verbs,
4868 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004869 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4870 .dac_nids = alc880_z71v_dac_nids,
4871 .dig_out_nid = ALC880_DIGOUT_NID,
4872 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004873 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4874 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004875 .input_mux = &alc880_capture_source,
4876 },
4877 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004878 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004879 .init_verbs = { alc880_volume_init_verbs,
4880 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004881 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4882 .dac_nids = alc880_f1734_dac_nids,
4883 .hp_nid = 0x02,
4884 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4885 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004886 .input_mux = &alc880_f1734_capture_source,
4887 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004888 .setup = alc880_uniwill_p53_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +02004889 .init_hook = alc_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02004890 },
4891 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004892 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004893 .init_verbs = { alc880_volume_init_verbs,
4894 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004895 alc880_gpio1_init_verbs },
4896 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4897 .dac_nids = alc880_asus_dac_nids,
4898 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4899 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004900 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004901 .input_mux = &alc880_capture_source,
4902 },
4903 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004904 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004905 .init_verbs = { alc880_volume_init_verbs,
4906 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004907 alc880_gpio1_init_verbs },
4908 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4909 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004910 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004911 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4912 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004913 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004914 .input_mux = &alc880_capture_source,
4915 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004916 [ALC880_ASUS_DIG2] = {
4917 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004918 .init_verbs = { alc880_volume_init_verbs,
4919 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004920 alc880_gpio2_init_verbs }, /* use GPIO2 */
4921 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4922 .dac_nids = alc880_asus_dac_nids,
4923 .dig_out_nid = ALC880_DIGOUT_NID,
4924 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4925 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004926 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004927 .input_mux = &alc880_capture_source,
4928 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004929 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004930 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004931 .init_verbs = { alc880_volume_init_verbs,
4932 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004933 alc880_gpio1_init_verbs },
4934 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4935 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004936 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004937 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4938 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004939 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004940 .input_mux = &alc880_capture_source,
4941 },
4942 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004943 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004944 .init_verbs = { alc880_volume_init_verbs,
4945 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004946 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4947 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004948 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004949 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4950 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004951 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004952 .input_mux = &alc880_capture_source,
4953 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004954 [ALC880_UNIWILL] = {
4955 .mixers = { alc880_uniwill_mixer },
4956 .init_verbs = { alc880_volume_init_verbs,
4957 alc880_uniwill_init_verbs },
4958 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4959 .dac_nids = alc880_asus_dac_nids,
4960 .dig_out_nid = ALC880_DIGOUT_NID,
4961 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4962 .channel_mode = alc880_threestack_modes,
4963 .need_dac_fix = 1,
4964 .input_mux = &alc880_capture_source,
4965 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004966 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004967 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004968 },
4969 [ALC880_UNIWILL_P53] = {
4970 .mixers = { alc880_uniwill_p53_mixer },
4971 .init_verbs = { alc880_volume_init_verbs,
4972 alc880_uniwill_p53_init_verbs },
4973 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4974 .dac_nids = alc880_asus_dac_nids,
4975 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004976 .channel_mode = alc880_threestack_modes,
4977 .input_mux = &alc880_capture_source,
4978 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004979 .setup = alc880_uniwill_p53_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +02004980 .init_hook = alc_hp_automute,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004981 },
4982 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004983 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004984 .init_verbs = { alc880_volume_init_verbs,
4985 alc880_uniwill_p53_init_verbs,
4986 alc880_beep_init_verbs },
4987 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4988 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004989 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004990 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4991 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004992 .input_mux = &alc880_capture_source,
4993 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004994 .setup = alc880_uniwill_p53_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +02004995 .init_hook = alc_hp_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02004996 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004997 [ALC880_CLEVO] = {
4998 .mixers = { alc880_three_stack_mixer },
4999 .init_verbs = { alc880_volume_init_verbs,
5000 alc880_pin_clevo_init_verbs },
5001 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
5002 .dac_nids = alc880_dac_nids,
5003 .hp_nid = 0x03,
5004 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5005 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005006 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01005007 .input_mux = &alc880_capture_source,
5008 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005009 [ALC880_LG] = {
5010 .mixers = { alc880_lg_mixer },
5011 .init_verbs = { alc880_volume_init_verbs,
5012 alc880_lg_init_verbs },
5013 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
5014 .dac_nids = alc880_lg_dac_nids,
5015 .dig_out_nid = ALC880_DIGOUT_NID,
5016 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
5017 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005018 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005019 .input_mux = &alc880_lg_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +02005020 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02005021 .setup = alc880_lg_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +02005022 .init_hook = alc_hp_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02005023#ifdef CONFIG_SND_HDA_POWER_SAVE
5024 .loopbacks = alc880_lg_loopbacks,
5025#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005026 },
Takashi Iwaid6815182006-03-23 16:06:23 +01005027 [ALC880_LG_LW] = {
5028 .mixers = { alc880_lg_lw_mixer },
5029 .init_verbs = { alc880_volume_init_verbs,
5030 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02005031 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01005032 .dac_nids = alc880_dac_nids,
5033 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02005034 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
5035 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01005036 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +02005037 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02005038 .setup = alc880_lg_lw_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +02005039 .init_hook = alc_hp_automute,
Takashi Iwaid6815182006-03-23 16:06:23 +01005040 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02005041 [ALC880_MEDION_RIM] = {
5042 .mixers = { alc880_medion_rim_mixer },
5043 .init_verbs = { alc880_volume_init_verbs,
5044 alc880_medion_rim_init_verbs,
5045 alc_gpio2_init_verbs },
5046 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
5047 .dac_nids = alc880_dac_nids,
5048 .dig_out_nid = ALC880_DIGOUT_NID,
5049 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
5050 .channel_mode = alc880_2_jack_modes,
5051 .input_mux = &alc880_medion_rim_capture_source,
5052 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02005053 .setup = alc880_medion_rim_setup,
5054 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02005055 },
Takashi Iwai16ded522005-06-10 19:58:24 +02005056#ifdef CONFIG_SND_DEBUG
5057 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005058 .mixers = { alc880_test_mixer },
5059 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02005060 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
5061 .dac_nids = alc880_test_dac_nids,
5062 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02005063 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
5064 .channel_mode = alc880_test_modes,
5065 .input_mux = &alc880_test_capture_source,
5066 },
5067#endif
5068};
5069
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005070/*
5071 * Automatic parse of I/O pins from the BIOS configuration
5072 */
5073
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005074enum {
5075 ALC_CTL_WIDGET_VOL,
5076 ALC_CTL_WIDGET_MUTE,
5077 ALC_CTL_BIND_MUTE,
5078};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005079static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005080 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
5081 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01005082 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005083};
5084
Takashi Iwaice764ab2011-04-27 16:35:23 +02005085static struct snd_kcontrol_new *alc_kcontrol_new(struct alc_spec *spec)
5086{
5087 snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32);
5088 return snd_array_new(&spec->kctls);
5089}
5090
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005091/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005092static int add_control(struct alc_spec *spec, int type, const char *name,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005093 int cidx, unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005094{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005095 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005096
Takashi Iwaice764ab2011-04-27 16:35:23 +02005097 knew = alc_kcontrol_new(spec);
Takashi Iwai603c4012008-07-30 15:01:44 +02005098 if (!knew)
5099 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005100 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07005101 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005102 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005103 return -ENOMEM;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005104 knew->index = cidx;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01005105 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01005106 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005107 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005108 return 0;
5109}
5110
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005111static int add_control_with_pfx(struct alc_spec *spec, int type,
5112 const char *pfx, const char *dir,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005113 const char *sfx, int cidx, unsigned long val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005114{
5115 char name[32];
5116 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005117 return add_control(spec, type, name, cidx, val);
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005118}
5119
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005120#define add_pb_vol_ctrl(spec, type, pfx, val) \
5121 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
5122#define add_pb_sw_ctrl(spec, type, pfx, val) \
5123 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
5124#define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
5125 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
5126#define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
5127 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005128
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005129#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
5130#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
5131#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
5132#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005133#define alc880_idx_to_dac(nid) ((nid) + 0x02)
5134#define alc880_dac_to_idx(nid) ((nid) - 0x02)
5135#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
5136#define alc880_idx_to_selector(nid) ((nid) + 0x10)
5137#define ALC880_PIN_CD_NID 0x1c
5138
5139/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005140static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
5141 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005142{
5143 hda_nid_t nid;
5144 int assigned[4];
5145 int i, j;
5146
5147 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02005148 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005149
5150 /* check the pins hardwired to audio widget */
5151 for (i = 0; i < cfg->line_outs; i++) {
5152 nid = cfg->line_out_pins[i];
5153 if (alc880_is_fixed_pin(nid)) {
5154 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01005155 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005156 assigned[idx] = 1;
5157 }
5158 }
5159 /* left pins can be connect to any audio widget */
5160 for (i = 0; i < cfg->line_outs; i++) {
5161 nid = cfg->line_out_pins[i];
5162 if (alc880_is_fixed_pin(nid))
5163 continue;
5164 /* search for an empty channel */
5165 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005166 if (!assigned[j]) {
5167 spec->multiout.dac_nids[i] =
5168 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005169 assigned[j] = 1;
5170 break;
5171 }
5172 }
5173 }
5174 spec->multiout.num_dacs = cfg->line_outs;
5175 return 0;
5176}
5177
Takashi Iwaice764ab2011-04-27 16:35:23 +02005178static const char *alc_get_line_out_pfx(struct alc_spec *spec,
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005179 bool can_be_master)
5180{
Takashi Iwaice764ab2011-04-27 16:35:23 +02005181 struct auto_pin_cfg *cfg = &spec->autocfg;
5182
5183 if (cfg->line_outs == 1 && !spec->multi_ios &&
5184 !cfg->hp_outs && !cfg->speaker_outs && can_be_master)
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005185 return "Master";
5186
5187 switch (cfg->line_out_type) {
5188 case AUTO_PIN_SPEAKER_OUT:
David Henningssonebbeb3d2011-03-04 14:08:30 +01005189 if (cfg->line_outs == 1)
5190 return "Speaker";
5191 break;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005192 case AUTO_PIN_HP_OUT:
5193 return "Headphone";
5194 default:
Takashi Iwaice764ab2011-04-27 16:35:23 +02005195 if (cfg->line_outs == 1 && !spec->multi_ios)
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005196 return "PCM";
5197 break;
5198 }
5199 return NULL;
5200}
5201
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005202/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01005203static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
5204 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005205{
Takashi Iwaiea734962011-01-17 11:29:34 +01005206 static const char * const chname[4] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005207 "Front", "Surround", NULL /*CLFE*/, "Side"
5208 };
Takashi Iwaice764ab2011-04-27 16:35:23 +02005209 const char *pfx = alc_get_line_out_pfx(spec, false);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005210 hda_nid_t nid;
Takashi Iwaice764ab2011-04-27 16:35:23 +02005211 int i, err, noutputs;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005212
Takashi Iwaice764ab2011-04-27 16:35:23 +02005213 noutputs = cfg->line_outs;
5214 if (spec->multi_ios > 0)
5215 noutputs += spec->multi_ios;
5216
5217 for (i = 0; i < noutputs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005218 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005219 continue;
5220 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005221 if (!pfx && i == 2) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005222 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005223 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5224 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005225 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
5226 HDA_OUTPUT));
5227 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005228 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005229 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5230 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005231 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
5232 HDA_OUTPUT));
5233 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005234 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005235 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5236 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005237 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
5238 HDA_INPUT));
5239 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005240 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005241 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5242 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005243 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
5244 HDA_INPUT));
5245 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005246 return err;
5247 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005248 const char *name = pfx;
David Henningsson7e59e092011-03-04 14:22:25 +01005249 int index = i;
5250 if (!name) {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005251 name = chname[i];
David Henningsson7e59e092011-03-04 14:22:25 +01005252 index = 0;
5253 }
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005254 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
David Henningsson7e59e092011-03-04 14:22:25 +01005255 name, index,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005256 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
5257 HDA_OUTPUT));
5258 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005259 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005260 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
David Henningsson7e59e092011-03-04 14:22:25 +01005261 name, index,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005262 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
5263 HDA_INPUT));
5264 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005265 return err;
5266 }
5267 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005268 return 0;
5269}
5270
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005271/* add playback controls for speaker and HP outputs */
5272static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
5273 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005274{
5275 hda_nid_t nid;
5276 int err;
5277
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005278 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005279 return 0;
5280
5281 if (alc880_is_fixed_pin(pin)) {
5282 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01005283 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005284 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005285 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005286 else
5287 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005288 /* control HP volume/switch on the output mixer amp */
5289 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005290 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005291 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
5292 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005293 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005294 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005295 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
5296 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005297 return err;
5298 } else if (alc880_is_multi_pin(pin)) {
5299 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005300 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005301 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005302 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
5303 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005304 return err;
5305 }
5306 return 0;
5307}
5308
5309/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005310static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005311 const char *ctlname, int ctlidx,
Kailang Yangdf694da2005-12-05 19:42:22 +01005312 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005313{
Kailang Yangdf694da2005-12-05 19:42:22 +01005314 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005315
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005316 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005317 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5318 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005319 return err;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005320 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005321 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5322 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005323 return err;
5324 return 0;
5325}
5326
Takashi Iwai05f5f472009-08-25 13:10:18 +02005327static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005328{
Takashi Iwai05f5f472009-08-25 13:10:18 +02005329 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
5330 return (pincap & AC_PINCAP_IN) != 0;
5331}
5332
5333/* create playback/capture controls for input pins */
5334static int alc_auto_create_input_ctls(struct hda_codec *codec,
5335 const struct auto_pin_cfg *cfg,
5336 hda_nid_t mixer,
5337 hda_nid_t cap1, hda_nid_t cap2)
5338{
5339 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005340 struct hda_input_mux *imux = &spec->private_imux[0];
David Henningsson5322bf22011-01-05 11:03:56 +01005341 int i, err, idx, type_idx = 0;
5342 const char *prev_label = NULL;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005343
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005344 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02005345 hda_nid_t pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005346 const char *label;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005347
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005348 pin = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005349 if (!alc_is_input_pin(codec, pin))
5350 continue;
5351
David Henningsson5322bf22011-01-05 11:03:56 +01005352 label = hda_get_autocfg_input_label(codec, cfg, i);
5353 if (prev_label && !strcmp(label, prev_label))
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005354 type_idx++;
5355 else
5356 type_idx = 0;
David Henningsson5322bf22011-01-05 11:03:56 +01005357 prev_label = label;
5358
Takashi Iwai05f5f472009-08-25 13:10:18 +02005359 if (mixer) {
5360 idx = get_connection_index(codec, mixer, pin);
5361 if (idx >= 0) {
5362 err = new_analog_input(spec, pin,
Takashi Iwai10a20af2010-09-09 16:28:02 +02005363 label, type_idx,
5364 idx, mixer);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005365 if (err < 0)
5366 return err;
5367 }
5368 }
5369
5370 if (!cap1)
5371 continue;
5372 idx = get_connection_index(codec, cap1, pin);
5373 if (idx < 0 && cap2)
5374 idx = get_connection_index(codec, cap2, pin);
Takashi Iwai10a20af2010-09-09 16:28:02 +02005375 if (idx >= 0)
5376 snd_hda_add_imux_item(imux, label, idx, NULL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005377 }
5378 return 0;
5379}
5380
Takashi Iwai05f5f472009-08-25 13:10:18 +02005381static int alc880_auto_create_input_ctls(struct hda_codec *codec,
5382 const struct auto_pin_cfg *cfg)
5383{
5384 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
5385}
5386
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005387static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
5388 unsigned int pin_type)
5389{
5390 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5391 pin_type);
5392 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01005393 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5394 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005395}
5396
Kailang Yangdf694da2005-12-05 19:42:22 +01005397static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
5398 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005399 int dac_idx)
5400{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005401 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005402 /* need the manual connection? */
5403 if (alc880_is_multi_pin(nid)) {
5404 struct alc_spec *spec = codec->spec;
5405 int idx = alc880_multi_pin_idx(nid);
5406 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
5407 AC_VERB_SET_CONNECT_SEL,
5408 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
5409 }
5410}
5411
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005412static int get_pin_type(int line_out_type)
5413{
5414 if (line_out_type == AUTO_PIN_HP_OUT)
5415 return PIN_HP;
5416 else
5417 return PIN_OUT;
5418}
5419
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005420static void alc880_auto_init_multi_out(struct hda_codec *codec)
5421{
5422 struct alc_spec *spec = codec->spec;
5423 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02005424
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005425 for (i = 0; i < spec->autocfg.line_outs; i++) {
5426 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005427 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5428 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005429 }
5430}
5431
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005432static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005433{
5434 struct alc_spec *spec = codec->spec;
5435 hda_nid_t pin;
5436
Takashi Iwai82bc9552006-03-21 11:24:42 +01005437 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005438 if (pin) /* connect to front */
5439 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005440 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005441 if (pin) /* connect to front */
5442 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5443}
5444
5445static void alc880_auto_init_analog_input(struct hda_codec *codec)
5446{
5447 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005448 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005449 int i;
5450
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005451 for (i = 0; i < cfg->num_inputs; i++) {
5452 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005453 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02005454 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005455 if (nid != ALC880_PIN_CD_NID &&
5456 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005457 snd_hda_codec_write(codec, nid, 0,
5458 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005459 AMP_OUT_MUTE);
5460 }
5461 }
5462}
5463
Takashi Iwai7f311a42010-04-09 17:32:23 +02005464static void alc880_auto_init_input_src(struct hda_codec *codec)
5465{
5466 struct alc_spec *spec = codec->spec;
5467 int c;
5468
5469 for (c = 0; c < spec->num_adc_nids; c++) {
5470 unsigned int mux_idx;
5471 const struct hda_input_mux *imux;
5472 mux_idx = c >= spec->num_mux_defs ? 0 : c;
5473 imux = &spec->input_mux[mux_idx];
5474 if (!imux->num_items && mux_idx > 0)
5475 imux = &spec->input_mux[0];
5476 if (imux)
5477 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
5478 AC_VERB_SET_CONNECT_SEL,
5479 imux->items[0].index);
5480 }
5481}
5482
Takashi Iwaice764ab2011-04-27 16:35:23 +02005483static int alc_auto_add_multi_channel_mode(struct hda_codec *codec);
5484
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005485/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005486/* return 1 if successful, 0 if the proper config is not found,
5487 * or a negative error code
5488 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005489static int alc880_parse_auto_config(struct hda_codec *codec)
5490{
5491 struct alc_spec *spec = codec->spec;
Takashi Iwai757899a2010-07-30 10:48:14 +02005492 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005493 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005494
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005495 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5496 alc880_ignore);
5497 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005498 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005499 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005500 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01005501
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005502 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
5503 if (err < 0)
5504 return err;
Takashi Iwaice764ab2011-04-27 16:35:23 +02005505 err = alc_auto_add_multi_channel_mode(codec);
5506 if (err < 0)
5507 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005508 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
5509 if (err < 0)
5510 return err;
5511 err = alc880_auto_create_extra_out(spec,
5512 spec->autocfg.speaker_pins[0],
5513 "Speaker");
5514 if (err < 0)
5515 return err;
5516 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
5517 "Headphone");
5518 if (err < 0)
5519 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005520 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005521 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005522 return err;
5523
5524 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5525
Takashi Iwai757899a2010-07-30 10:48:14 +02005526 alc_auto_parse_digital(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005527
Takashi Iwai603c4012008-07-30 15:01:44 +02005528 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005529 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005530
Takashi Iwaid88897e2008-10-31 15:01:37 +01005531 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005532
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005533 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005534 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005535
Kailang Yang6227cdc2010-02-25 08:36:52 +01005536 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005537
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005538 return 1;
5539}
5540
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005541/* additional initialization for auto-configuration model */
5542static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005543{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005544 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005545 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005546 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005547 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02005548 alc880_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02005549 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005550 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005551 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005552}
5553
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005554/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5555 * one of two digital mic pins, e.g. on ALC272
5556 */
5557static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005558{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005559 struct alc_spec *spec = codec->spec;
5560 int i;
5561
5562 for (i = 0; i < spec->num_adc_nids; i++) {
5563 hda_nid_t cap = spec->capsrc_nids ?
5564 spec->capsrc_nids[i] : spec->adc_nids[i];
5565 int iidx, eidx;
5566
5567 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5568 if (iidx < 0)
5569 continue;
5570 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5571 if (eidx < 0)
5572 continue;
5573 spec->int_mic.mux_idx = iidx;
5574 spec->ext_mic.mux_idx = eidx;
5575 if (spec->capsrc_nids)
5576 spec->capsrc_nids += i;
5577 spec->adc_nids += i;
5578 spec->num_adc_nids = 1;
5579 return;
5580 }
5581 snd_printd(KERN_INFO "hda_codec: %s: "
5582 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5583 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5584 spec->auto_mic = 0; /* disable auto-mic to be sure */
5585}
5586
Takashi Iwai748cce42010-08-04 07:37:39 +02005587/* select or unmute the given capsrc route */
5588static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
5589 int idx)
5590{
5591 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5592 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5593 HDA_AMP_MUTE, 0);
5594 } else {
5595 snd_hda_codec_write_cache(codec, cap, 0,
5596 AC_VERB_SET_CONNECT_SEL, idx);
5597 }
5598}
5599
Takashi Iwai840b64c2010-07-13 22:49:01 +02005600/* set the default connection to that pin */
5601static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
5602{
5603 struct alc_spec *spec = codec->spec;
5604 int i;
5605
5606 for (i = 0; i < spec->num_adc_nids; i++) {
5607 hda_nid_t cap = spec->capsrc_nids ?
5608 spec->capsrc_nids[i] : spec->adc_nids[i];
5609 int idx;
5610
5611 idx = get_connection_index(codec, cap, pin);
5612 if (idx < 0)
5613 continue;
Takashi Iwai748cce42010-08-04 07:37:39 +02005614 select_or_unmute_capsrc(codec, cap, idx);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005615 return i; /* return the found index */
5616 }
5617 return -1; /* not found */
5618}
5619
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005620/* choose the ADC/MUX containing the input pin and initialize the setup */
5621static void fixup_single_adc(struct hda_codec *codec)
5622{
5623 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005624 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005625 int i;
5626
5627 /* search for the input pin; there must be only one */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005628 if (cfg->num_inputs != 1)
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005629 return;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005630 i = init_capsrc_for_pin(codec, cfg->inputs[0].pin);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005631 if (i >= 0) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005632 /* use only this ADC */
5633 if (spec->capsrc_nids)
5634 spec->capsrc_nids += i;
5635 spec->adc_nids += i;
5636 spec->num_adc_nids = 1;
Takashi Iwai584c0c42011-03-10 12:51:11 +01005637 spec->single_input_src = 1;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005638 }
5639}
5640
Takashi Iwai840b64c2010-07-13 22:49:01 +02005641/* initialize dual adcs */
5642static void fixup_dual_adc_switch(struct hda_codec *codec)
5643{
5644 struct alc_spec *spec = codec->spec;
5645 init_capsrc_for_pin(codec, spec->ext_mic.pin);
5646 init_capsrc_for_pin(codec, spec->int_mic.pin);
5647}
5648
Takashi Iwai584c0c42011-03-10 12:51:11 +01005649/* initialize some special cases for input sources */
5650static void alc_init_special_input_src(struct hda_codec *codec)
5651{
5652 struct alc_spec *spec = codec->spec;
5653 if (spec->dual_adc_switch)
5654 fixup_dual_adc_switch(codec);
5655 else if (spec->single_input_src)
5656 init_capsrc_for_pin(codec, spec->autocfg.inputs[0].pin);
5657}
5658
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005659static void set_capture_mixer(struct hda_codec *codec)
5660{
5661 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005662 static struct snd_kcontrol_new *caps[2][3] = {
5663 { alc_capture_mixer_nosrc1,
5664 alc_capture_mixer_nosrc2,
5665 alc_capture_mixer_nosrc3 },
5666 { alc_capture_mixer1,
5667 alc_capture_mixer2,
5668 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005669 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005670 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005671 int mux = 0;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005672 int num_adcs = spec->num_adc_nids;
5673 if (spec->dual_adc_switch)
Takashi Iwai584c0c42011-03-10 12:51:11 +01005674 num_adcs = 1;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005675 else if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005676 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005677 else if (spec->input_mux) {
5678 if (spec->input_mux->num_items > 1)
5679 mux = 1;
5680 else if (spec->input_mux->num_items == 1)
5681 fixup_single_adc(codec);
5682 }
Takashi Iwai840b64c2010-07-13 22:49:01 +02005683 spec->cap_mixer = caps[mux][num_adcs - 1];
Takashi Iwaia23b6882009-03-23 15:21:36 +01005684 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005685}
5686
Takashi Iwai66946352010-03-29 17:21:45 +02005687/* fill adc_nids (and capsrc_nids) containing all active input pins */
5688static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5689 int num_nids)
5690{
5691 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005692 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai66946352010-03-29 17:21:45 +02005693 int n;
5694 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5695
5696 for (n = 0; n < num_nids; n++) {
5697 hda_nid_t adc, cap;
5698 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5699 int nconns, i, j;
5700
5701 adc = nids[n];
5702 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5703 continue;
5704 cap = adc;
5705 nconns = snd_hda_get_connections(codec, cap, conn,
5706 ARRAY_SIZE(conn));
5707 if (nconns == 1) {
5708 cap = conn[0];
5709 nconns = snd_hda_get_connections(codec, cap, conn,
5710 ARRAY_SIZE(conn));
5711 }
5712 if (nconns <= 0)
5713 continue;
5714 if (!fallback_adc) {
5715 fallback_adc = adc;
5716 fallback_cap = cap;
5717 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005718 for (i = 0; i < cfg->num_inputs; i++) {
5719 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai66946352010-03-29 17:21:45 +02005720 for (j = 0; j < nconns; j++) {
5721 if (conn[j] == nid)
5722 break;
5723 }
5724 if (j >= nconns)
5725 break;
5726 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005727 if (i >= cfg->num_inputs) {
Takashi Iwai66946352010-03-29 17:21:45 +02005728 int num_adcs = spec->num_adc_nids;
5729 spec->private_adc_nids[num_adcs] = adc;
5730 spec->private_capsrc_nids[num_adcs] = cap;
5731 spec->num_adc_nids++;
5732 spec->adc_nids = spec->private_adc_nids;
5733 if (adc != cap)
5734 spec->capsrc_nids = spec->private_capsrc_nids;
5735 }
5736 }
5737 if (!spec->num_adc_nids) {
5738 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005739 " using fallback 0x%x\n",
5740 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005741 spec->private_adc_nids[0] = fallback_adc;
5742 spec->adc_nids = spec->private_adc_nids;
5743 if (fallback_adc != fallback_cap) {
5744 spec->private_capsrc_nids[0] = fallback_cap;
5745 spec->capsrc_nids = spec->private_adc_nids;
5746 }
5747 }
5748}
5749
Takashi Iwai67d634c2009-11-16 15:35:59 +01005750#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005751#define set_beep_amp(spec, nid, idx, dir) \
5752 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005753
5754static struct snd_pci_quirk beep_white_list[] = {
5755 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai080dc7b2010-09-08 08:38:41 +02005756 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
Takashi Iwaie096c8e2010-08-03 17:20:35 +02005757 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005758 {}
5759};
5760
5761static inline int has_cdefine_beep(struct hda_codec *codec)
5762{
5763 struct alc_spec *spec = codec->spec;
5764 const struct snd_pci_quirk *q;
5765 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5766 if (q)
5767 return q->value;
5768 return spec->cdefine.enable_pcbeep;
5769}
Takashi Iwai67d634c2009-11-16 15:35:59 +01005770#else
5771#define set_beep_amp(spec, nid, idx, dir) /* NOP */
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005772#define has_cdefine_beep(codec) 0
Takashi Iwai67d634c2009-11-16 15:35:59 +01005773#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005774
5775/*
5776 * OK, here we have finally the patch for ALC880
5777 */
5778
Linus Torvalds1da177e2005-04-16 15:20:36 -07005779static int patch_alc880(struct hda_codec *codec)
5780{
5781 struct alc_spec *spec;
5782 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005783 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005784
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005785 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005786 if (spec == NULL)
5787 return -ENOMEM;
5788
5789 codec->spec = spec;
5790
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005791 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5792 alc880_models,
5793 alc880_cfg_tbl);
5794 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005795 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5796 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005797 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005798 }
5799
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005800 if (board_config == ALC880_AUTO) {
5801 /* automatic parse from the BIOS config */
5802 err = alc880_parse_auto_config(codec);
5803 if (err < 0) {
5804 alc_free(codec);
5805 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005806 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005807 printk(KERN_INFO
5808 "hda_codec: Cannot set up configuration "
5809 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005810 board_config = ALC880_3ST;
5811 }
5812 }
5813
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005814 err = snd_hda_attach_beep_device(codec, 0x1);
5815 if (err < 0) {
5816 alc_free(codec);
5817 return err;
5818 }
5819
Kailang Yangdf694da2005-12-05 19:42:22 +01005820 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005821 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005822
Linus Torvalds1da177e2005-04-16 15:20:36 -07005823 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5824 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005825 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005826
Linus Torvalds1da177e2005-04-16 15:20:36 -07005827 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5828 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5829
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005830 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005831 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005832 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005833 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005834 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005835 if (wcap != AC_WID_AUD_IN) {
5836 spec->adc_nids = alc880_adc_nids_alt;
5837 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005838 } else {
5839 spec->adc_nids = alc880_adc_nids;
5840 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005841 }
5842 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005843 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005844 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005845
Takashi Iwai2134ea42008-01-10 16:53:55 +01005846 spec->vmaster_nid = 0x0c;
5847
Linus Torvalds1da177e2005-04-16 15:20:36 -07005848 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005849 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005850 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005851#ifdef CONFIG_SND_HDA_POWER_SAVE
5852 if (!spec->loopback.amplist)
5853 spec->loopback.amplist = alc880_loopbacks;
5854#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005855
5856 return 0;
5857}
5858
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005859
Linus Torvalds1da177e2005-04-16 15:20:36 -07005860/*
5861 * ALC260 support
5862 */
5863
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005864static hda_nid_t alc260_dac_nids[1] = {
5865 /* front */
5866 0x02,
5867};
5868
5869static hda_nid_t alc260_adc_nids[1] = {
5870 /* ADC0 */
5871 0x04,
5872};
5873
Kailang Yangdf694da2005-12-05 19:42:22 +01005874static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005875 /* ADC1 */
5876 0x05,
5877};
5878
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005879/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5880 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5881 */
5882static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005883 /* ADC0, ADC1 */
5884 0x04, 0x05
5885};
5886
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005887#define ALC260_DIGOUT_NID 0x03
5888#define ALC260_DIGIN_NID 0x06
5889
5890static struct hda_input_mux alc260_capture_source = {
5891 .num_items = 4,
5892 .items = {
5893 { "Mic", 0x0 },
5894 { "Front Mic", 0x1 },
5895 { "Line", 0x2 },
5896 { "CD", 0x4 },
5897 },
5898};
5899
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005900/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005901 * headphone jack and the internal CD lines since these are the only pins at
5902 * which audio can appear. For flexibility, also allow the option of
5903 * recording the mixer output on the second ADC (ADC0 doesn't have a
5904 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005905 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005906static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5907 {
5908 .num_items = 3,
5909 .items = {
5910 { "Mic/Line", 0x0 },
5911 { "CD", 0x4 },
5912 { "Headphone", 0x2 },
5913 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005914 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005915 {
5916 .num_items = 4,
5917 .items = {
5918 { "Mic/Line", 0x0 },
5919 { "CD", 0x4 },
5920 { "Headphone", 0x2 },
5921 { "Mixer", 0x5 },
5922 },
5923 },
5924
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005925};
5926
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005927/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5928 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005929 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005930static struct hda_input_mux alc260_acer_capture_sources[2] = {
5931 {
5932 .num_items = 4,
5933 .items = {
5934 { "Mic", 0x0 },
5935 { "Line", 0x2 },
5936 { "CD", 0x4 },
5937 { "Headphone", 0x5 },
5938 },
5939 },
5940 {
5941 .num_items = 5,
5942 .items = {
5943 { "Mic", 0x0 },
5944 { "Line", 0x2 },
5945 { "CD", 0x4 },
5946 { "Headphone", 0x6 },
5947 { "Mixer", 0x5 },
5948 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005949 },
5950};
Michael Schwingencc959482009-02-22 18:58:45 +01005951
5952/* Maxdata Favorit 100XS */
5953static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5954 {
5955 .num_items = 2,
5956 .items = {
5957 { "Line/Mic", 0x0 },
5958 { "CD", 0x4 },
5959 },
5960 },
5961 {
5962 .num_items = 3,
5963 .items = {
5964 { "Line/Mic", 0x0 },
5965 { "CD", 0x4 },
5966 { "Mixer", 0x5 },
5967 },
5968 },
5969};
5970
Linus Torvalds1da177e2005-04-16 15:20:36 -07005971/*
5972 * This is just place-holder, so there's something for alc_build_pcms to look
5973 * at when it calculates the maximum number of channels. ALC260 has no mixer
5974 * element which allows changing the channel mode, so the verb list is
5975 * never used.
5976 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005977static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005978 { 2, NULL },
5979};
5980
Kailang Yangdf694da2005-12-05 19:42:22 +01005981
5982/* Mixer combinations
5983 *
5984 * basic: base_output + input + pc_beep + capture
5985 * HP: base_output + input + capture_alt
5986 * HP_3013: hp_3013 + input + capture
5987 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005988 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005989 */
5990
5991static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005992 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005993 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005994 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5995 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5996 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5997 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5998 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005999};
Kailang Yangdf694da2005-12-05 19:42:22 +01006000
6001static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006002 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6003 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6004 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6005 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6006 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6007 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6008 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
6009 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006010 { } /* end */
6011};
6012
Takashi Iwaibec15c32008-01-28 18:16:30 +01006013/* update HP, line and mono out pins according to the master switch */
Takashi Iwaie9427962011-04-28 15:46:07 +02006014static void alc260_hp_master_update(struct hda_codec *codec)
Takashi Iwaibec15c32008-01-28 18:16:30 +01006015{
6016 struct alc_spec *spec = codec->spec;
Takashi Iwaie9427962011-04-28 15:46:07 +02006017
6018 /* change HP pins */
6019 do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins),
6020 spec->autocfg.hp_pins, spec->master_mute, true);
6021 update_speakers(codec);
Takashi Iwaibec15c32008-01-28 18:16:30 +01006022}
6023
6024static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
6025 struct snd_ctl_elem_value *ucontrol)
6026{
6027 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6028 struct alc_spec *spec = codec->spec;
Takashi Iwaie9427962011-04-28 15:46:07 +02006029 *ucontrol->value.integer.value = !spec->master_mute;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006030 return 0;
6031}
6032
6033static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
6034 struct snd_ctl_elem_value *ucontrol)
6035{
6036 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6037 struct alc_spec *spec = codec->spec;
Takashi Iwaie9427962011-04-28 15:46:07 +02006038 int val = !*ucontrol->value.integer.value;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006039
Takashi Iwaie9427962011-04-28 15:46:07 +02006040 if (val == spec->master_mute)
Takashi Iwaibec15c32008-01-28 18:16:30 +01006041 return 0;
Takashi Iwaie9427962011-04-28 15:46:07 +02006042 spec->master_mute = val;
6043 alc260_hp_master_update(codec);
Takashi Iwaibec15c32008-01-28 18:16:30 +01006044 return 1;
6045}
6046
6047static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
6048 {
6049 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6050 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01006051 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006052 .info = snd_ctl_boolean_mono_info,
6053 .get = alc260_hp_master_sw_get,
6054 .put = alc260_hp_master_sw_put,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006055 },
6056 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6057 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
6058 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6059 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
6060 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
6061 HDA_OUTPUT),
6062 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6063 { } /* end */
6064};
6065
6066static struct hda_verb alc260_hp_unsol_verbs[] = {
6067 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6068 {},
6069};
6070
Takashi Iwaie9427962011-04-28 15:46:07 +02006071static void alc260_hp_setup(struct hda_codec *codec)
Takashi Iwaibec15c32008-01-28 18:16:30 +01006072{
6073 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006074
Takashi Iwaie9427962011-04-28 15:46:07 +02006075 spec->autocfg.hp_pins[0] = 0x0f;
6076 spec->autocfg.speaker_pins[0] = 0x10;
6077 spec->autocfg.speaker_pins[1] = 0x11;
6078 spec->automute = 1;
6079 spec->automute_mode = ALC_AUTOMUTE_PIN;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006080}
6081
Kailang Yangdf694da2005-12-05 19:42:22 +01006082static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006083 {
6084 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6085 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01006086 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006087 .info = snd_ctl_boolean_mono_info,
6088 .get = alc260_hp_master_sw_get,
6089 .put = alc260_hp_master_sw_put,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006090 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006091 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6092 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
6093 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
6094 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
6095 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6096 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01006097 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6098 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02006099 { } /* end */
6100};
6101
Takashi Iwaie9427962011-04-28 15:46:07 +02006102static void alc260_hp_3013_setup(struct hda_codec *codec)
6103{
6104 struct alc_spec *spec = codec->spec;
6105
6106 spec->autocfg.hp_pins[0] = 0x15;
6107 spec->autocfg.speaker_pins[0] = 0x10;
6108 spec->autocfg.speaker_pins[1] = 0x11;
6109 spec->automute = 1;
6110 spec->automute_mode = ALC_AUTOMUTE_PIN;
6111}
6112
Kailang Yang3f878302008-08-26 13:02:23 +02006113static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
6114 .ops = &snd_hda_bind_vol,
6115 .values = {
6116 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
6117 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
6118 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
6119 0
6120 },
6121};
6122
6123static struct hda_bind_ctls alc260_dc7600_bind_switch = {
6124 .ops = &snd_hda_bind_sw,
6125 .values = {
6126 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
6127 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
6128 0
6129 },
6130};
6131
6132static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
6133 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
6134 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
6135 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
6136 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
6137 { } /* end */
6138};
6139
Takashi Iwaibec15c32008-01-28 18:16:30 +01006140static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
6141 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6142 {},
6143};
6144
Takashi Iwaie9427962011-04-28 15:46:07 +02006145static void alc260_hp_3012_setup(struct hda_codec *codec)
Takashi Iwaibec15c32008-01-28 18:16:30 +01006146{
6147 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006148
Takashi Iwaie9427962011-04-28 15:46:07 +02006149 spec->autocfg.hp_pins[0] = 0x10;
6150 spec->autocfg.speaker_pins[0] = 0x0f;
6151 spec->autocfg.speaker_pins[1] = 0x11;
6152 spec->autocfg.speaker_pins[2] = 0x15;
6153 spec->automute = 1;
6154 spec->automute_mode = ALC_AUTOMUTE_PIN;
Kailang Yang3f878302008-08-26 13:02:23 +02006155}
6156
6157/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006158 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
6159 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006160static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006161 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006162 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006163 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006164 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6165 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6166 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
6167 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006168 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006169 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6170 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006171 { } /* end */
6172};
6173
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006174/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
6175 * versions of the ALC260 don't act on requests to enable mic bias from NID
6176 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
6177 * datasheet doesn't mention this restriction. At this stage it's not clear
6178 * whether this behaviour is intentional or is a hardware bug in chip
6179 * revisions available in early 2006. Therefore for now allow the
6180 * "Headphone Jack Mode" control to span all choices, but if it turns out
6181 * that the lack of mic bias for this NID is intentional we could change the
6182 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6183 *
6184 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
6185 * don't appear to make the mic bias available from the "line" jack, even
6186 * though the NID used for this jack (0x14) can supply it. The theory is
6187 * that perhaps Acer have included blocking capacitors between the ALC260
6188 * and the output jack. If this turns out to be the case for all such
6189 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
6190 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01006191 *
6192 * The C20x Tablet series have a mono internal speaker which is controlled
6193 * via the chip's Mono sum widget and pin complex, so include the necessary
6194 * controls for such models. On models without a "mono speaker" the control
6195 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006196 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006197static struct snd_kcontrol_new alc260_acer_mixer[] = {
6198 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6199 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006200 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006201 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01006202 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006203 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01006204 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006205 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6206 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6207 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6208 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6209 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6210 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6211 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6212 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006213 { } /* end */
6214};
6215
Michael Schwingencc959482009-02-22 18:58:45 +01006216/* Maxdata Favorit 100XS: one output and one input (0x12) jack
6217 */
6218static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
6219 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6220 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
6221 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
6222 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6223 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6224 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6225 { } /* end */
6226};
6227
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006228/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
6229 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
6230 */
6231static struct snd_kcontrol_new alc260_will_mixer[] = {
6232 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6233 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6234 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6235 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6236 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6237 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6238 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6239 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6240 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6241 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006242 { } /* end */
6243};
6244
6245/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
6246 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
6247 */
6248static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
6249 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6250 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6251 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6252 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6253 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6254 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
6255 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
6256 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6257 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6258 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6259 { } /* end */
6260};
6261
Kailang Yangdf694da2005-12-05 19:42:22 +01006262/*
6263 * initialization verbs
6264 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006265static struct hda_verb alc260_init_verbs[] = {
6266 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006267 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006268 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006269 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006270 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006271 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006272 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006273 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006274 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02006275 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006276 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01006277 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006278 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02006279 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006280 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02006281 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006282 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02006283 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6284 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02006285 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006286 /* set connection select to line in (default select for this ADC) */
6287 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02006288 /* mute capture amp left and right */
6289 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6290 /* set connection select to line in (default select for this ADC) */
6291 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02006292 /* set vol=0 Line-Out mixer amp left and right */
6293 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6294 /* unmute pin widget amp left and right (no gain on this amp) */
6295 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6296 /* set vol=0 HP mixer amp left and right */
6297 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6298 /* unmute pin widget amp left and right (no gain on this amp) */
6299 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6300 /* set vol=0 Mono mixer amp left and right */
6301 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6302 /* unmute pin widget amp left and right (no gain on this amp) */
6303 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6304 /* unmute LINE-2 out pin */
6305 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006306 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6307 * Line In 2 = 0x03
6308 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006309 /* mute analog inputs */
6310 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6311 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6312 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6313 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6314 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006315 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006316 /* mute Front out path */
6317 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6318 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6319 /* mute Headphone out path */
6320 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6321 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6322 /* mute Mono out path */
6323 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6324 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006325 { }
6326};
6327
Takashi Iwai474167d2006-05-17 17:17:43 +02006328#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01006329static struct hda_verb alc260_hp_init_verbs[] = {
6330 /* Headphone and output */
6331 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6332 /* mono output */
6333 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6334 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6335 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6336 /* Mic2 (front panel) pin widget for input and vref at 80% */
6337 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6338 /* Line In pin widget for input */
6339 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6340 /* Line-2 pin widget for output */
6341 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6342 /* CD pin widget for input */
6343 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6344 /* unmute amp left and right */
6345 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6346 /* set connection select to line in (default select for this ADC) */
6347 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6348 /* unmute Line-Out mixer amp left and right (volume = 0) */
6349 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6350 /* mute pin widget amp left and right (no gain on this amp) */
6351 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6352 /* unmute HP mixer amp left and right (volume = 0) */
6353 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6354 /* mute pin widget amp left and right (no gain on this amp) */
6355 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006356 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6357 * Line In 2 = 0x03
6358 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006359 /* mute analog inputs */
6360 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6361 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6362 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6363 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6364 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006365 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6366 /* Unmute Front out path */
6367 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6368 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6369 /* Unmute Headphone out path */
6370 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6371 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6372 /* Unmute Mono out path */
6373 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6374 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6375 { }
6376};
Takashi Iwai474167d2006-05-17 17:17:43 +02006377#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006378
6379static struct hda_verb alc260_hp_3013_init_verbs[] = {
6380 /* Line out and output */
6381 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6382 /* mono output */
6383 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6384 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6385 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6386 /* Mic2 (front panel) pin widget for input and vref at 80% */
6387 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6388 /* Line In pin widget for input */
6389 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6390 /* Headphone pin widget for output */
6391 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6392 /* CD pin widget for input */
6393 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6394 /* unmute amp left and right */
6395 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6396 /* set connection select to line in (default select for this ADC) */
6397 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6398 /* unmute Line-Out mixer amp left and right (volume = 0) */
6399 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6400 /* mute pin widget amp left and right (no gain on this amp) */
6401 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6402 /* unmute HP mixer amp left and right (volume = 0) */
6403 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6404 /* mute pin widget amp left and right (no gain on this amp) */
6405 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006406 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6407 * Line In 2 = 0x03
6408 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006409 /* mute analog inputs */
6410 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6411 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6412 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6413 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6414 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006415 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6416 /* Unmute Front out path */
6417 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6418 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6419 /* Unmute Headphone out path */
6420 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6421 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6422 /* Unmute Mono out path */
6423 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6424 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6425 { }
6426};
6427
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006428/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006429 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
6430 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006431 */
6432static struct hda_verb alc260_fujitsu_init_verbs[] = {
6433 /* Disable all GPIOs */
6434 {0x01, AC_VERB_SET_GPIO_MASK, 0},
6435 /* Internal speaker is connected to headphone pin */
6436 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6437 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
6438 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006439 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
6440 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6441 /* Ensure all other unused pins are disabled and muted. */
6442 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6443 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006444 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006445 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006446 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006447 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6448 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6449 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006450
Jonathan Woithef7ace402006-02-28 11:46:14 +01006451 /* Disable digital (SPDIF) pins */
6452 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6453 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006454
Kailang Yangea1fb292008-08-26 12:58:38 +02006455 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01006456 * when acting as an output.
6457 */
6458 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6459
6460 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01006461 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6462 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6463 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6464 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6465 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6466 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6467 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6468 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6469 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006470
Jonathan Woithef7ace402006-02-28 11:46:14 +01006471 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
6472 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6473 /* Unmute Line1 pin widget output buffer since it starts as an output.
6474 * If the pin mode is changed by the user the pin mode control will
6475 * take care of enabling the pin's input/output buffers as needed.
6476 * Therefore there's no need to enable the input buffer at this
6477 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006478 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006479 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02006480 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006481 * mixer ctrl)
6482 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006483 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006484
Jonathan Woithef7ace402006-02-28 11:46:14 +01006485 /* Mute capture amp left and right */
6486 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006487 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01006488 * in (on mic1 pin)
6489 */
6490 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006491
Jonathan Woithef7ace402006-02-28 11:46:14 +01006492 /* Do the same for the second ADC: mute capture input amp and
6493 * set ADC connection to line in (on mic1 pin)
6494 */
6495 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6496 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006497
Jonathan Woithef7ace402006-02-28 11:46:14 +01006498 /* Mute all inputs to mixer widget (even unconnected ones) */
6499 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6500 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6501 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6502 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6503 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6504 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6505 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6506 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006507
6508 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006509};
6510
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006511/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
6512 * similar laptops (adapted from Fujitsu init verbs).
6513 */
6514static struct hda_verb alc260_acer_init_verbs[] = {
6515 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
6516 * the headphone jack. Turn this on and rely on the standard mute
6517 * methods whenever the user wants to turn these outputs off.
6518 */
6519 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6520 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6521 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6522 /* Internal speaker/Headphone jack is connected to Line-out pin */
6523 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6524 /* Internal microphone/Mic jack is connected to Mic1 pin */
6525 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6526 /* Line In jack is connected to Line1 pin */
6527 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01006528 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
6529 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006530 /* Ensure all other unused pins are disabled and muted. */
6531 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6532 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006533 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6534 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6535 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6536 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6537 /* Disable digital (SPDIF) pins */
6538 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6539 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6540
Kailang Yangea1fb292008-08-26 12:58:38 +02006541 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006542 * bus when acting as outputs.
6543 */
6544 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6545 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6546
6547 /* Start with output sum widgets muted and their output gains at min */
6548 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6549 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6550 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6551 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6552 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6553 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6554 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6555 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6556 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6557
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006558 /* Unmute Line-out pin widget amp left and right
6559 * (no equiv mixer ctrl)
6560 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006561 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01006562 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6563 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006564 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6565 * inputs. If the pin mode is changed by the user the pin mode control
6566 * will take care of enabling the pin's input/output buffers as needed.
6567 * Therefore there's no need to enable the input buffer at this
6568 * stage.
6569 */
6570 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6571 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6572
6573 /* Mute capture amp left and right */
6574 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6575 /* Set ADC connection select to match default mixer setting - mic
6576 * (on mic1 pin)
6577 */
6578 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6579
6580 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006581 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006582 */
6583 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006584 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006585
6586 /* Mute all inputs to mixer widget (even unconnected ones) */
6587 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6588 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6589 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6590 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6591 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6592 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6593 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6594 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6595
6596 { }
6597};
6598
Michael Schwingencc959482009-02-22 18:58:45 +01006599/* Initialisation sequence for Maxdata Favorit 100XS
6600 * (adapted from Acer init verbs).
6601 */
6602static struct hda_verb alc260_favorit100_init_verbs[] = {
6603 /* GPIO 0 enables the output jack.
6604 * Turn this on and rely on the standard mute
6605 * methods whenever the user wants to turn these outputs off.
6606 */
6607 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6608 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6609 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6610 /* Line/Mic input jack is connected to Mic1 pin */
6611 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6612 /* Ensure all other unused pins are disabled and muted. */
6613 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6614 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6615 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6616 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6617 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6618 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6619 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6620 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6621 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6622 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6623 /* Disable digital (SPDIF) pins */
6624 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6625 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6626
6627 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6628 * bus when acting as outputs.
6629 */
6630 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6631 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6632
6633 /* Start with output sum widgets muted and their output gains at min */
6634 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6635 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6636 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6637 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6638 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6639 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6640 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6641 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6642 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6643
6644 /* Unmute Line-out pin widget amp left and right
6645 * (no equiv mixer ctrl)
6646 */
6647 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6648 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6649 * inputs. If the pin mode is changed by the user the pin mode control
6650 * will take care of enabling the pin's input/output buffers as needed.
6651 * Therefore there's no need to enable the input buffer at this
6652 * stage.
6653 */
6654 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6655
6656 /* Mute capture amp left and right */
6657 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6658 /* Set ADC connection select to match default mixer setting - mic
6659 * (on mic1 pin)
6660 */
6661 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6662
6663 /* Do similar with the second ADC: mute capture input amp and
6664 * set ADC connection to mic to match ALSA's default state.
6665 */
6666 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6667 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6668
6669 /* Mute all inputs to mixer widget (even unconnected ones) */
6670 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6671 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6672 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6673 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6674 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6675 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6676 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6677 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6678
6679 { }
6680};
6681
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006682static struct hda_verb alc260_will_verbs[] = {
6683 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6684 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6685 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6686 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6687 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6688 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6689 {}
6690};
6691
6692static struct hda_verb alc260_replacer_672v_verbs[] = {
6693 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6694 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6695 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6696
6697 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6698 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6699 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6700
6701 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6702 {}
6703};
6704
6705/* toggle speaker-output according to the hp-jack state */
6706static void alc260_replacer_672v_automute(struct hda_codec *codec)
6707{
6708 unsigned int present;
6709
6710 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006711 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006712 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006713 snd_hda_codec_write_cache(codec, 0x01, 0,
6714 AC_VERB_SET_GPIO_DATA, 1);
6715 snd_hda_codec_write_cache(codec, 0x0f, 0,
6716 AC_VERB_SET_PIN_WIDGET_CONTROL,
6717 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006718 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006719 snd_hda_codec_write_cache(codec, 0x01, 0,
6720 AC_VERB_SET_GPIO_DATA, 0);
6721 snd_hda_codec_write_cache(codec, 0x0f, 0,
6722 AC_VERB_SET_PIN_WIDGET_CONTROL,
6723 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006724 }
6725}
6726
6727static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6728 unsigned int res)
6729{
6730 if ((res >> 26) == ALC880_HP_EVENT)
6731 alc260_replacer_672v_automute(codec);
6732}
6733
Kailang Yang3f878302008-08-26 13:02:23 +02006734static struct hda_verb alc260_hp_dc7600_verbs[] = {
6735 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6736 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6737 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6738 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6739 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6740 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6741 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6742 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6743 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6744 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6745 {}
6746};
6747
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006748/* Test configuration for debugging, modelled after the ALC880 test
6749 * configuration.
6750 */
6751#ifdef CONFIG_SND_DEBUG
6752static hda_nid_t alc260_test_dac_nids[1] = {
6753 0x02,
6754};
6755static hda_nid_t alc260_test_adc_nids[2] = {
6756 0x04, 0x05,
6757};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006758/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006759 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006760 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006761 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006762static struct hda_input_mux alc260_test_capture_sources[2] = {
6763 {
6764 .num_items = 7,
6765 .items = {
6766 { "MIC1 pin", 0x0 },
6767 { "MIC2 pin", 0x1 },
6768 { "LINE1 pin", 0x2 },
6769 { "LINE2 pin", 0x3 },
6770 { "CD pin", 0x4 },
6771 { "LINE-OUT pin", 0x5 },
6772 { "HP-OUT pin", 0x6 },
6773 },
6774 },
6775 {
6776 .num_items = 8,
6777 .items = {
6778 { "MIC1 pin", 0x0 },
6779 { "MIC2 pin", 0x1 },
6780 { "LINE1 pin", 0x2 },
6781 { "LINE2 pin", 0x3 },
6782 { "CD pin", 0x4 },
6783 { "Mixer", 0x5 },
6784 { "LINE-OUT pin", 0x6 },
6785 { "HP-OUT pin", 0x7 },
6786 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006787 },
6788};
6789static struct snd_kcontrol_new alc260_test_mixer[] = {
6790 /* Output driver widgets */
6791 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6792 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6793 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6794 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6795 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6796 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6797
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006798 /* Modes for retasking pin widgets
6799 * Note: the ALC260 doesn't seem to act on requests to enable mic
6800 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6801 * mention this restriction. At this stage it's not clear whether
6802 * this behaviour is intentional or is a hardware bug in chip
6803 * revisions available at least up until early 2006. Therefore for
6804 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6805 * choices, but if it turns out that the lack of mic bias for these
6806 * NIDs is intentional we could change their modes from
6807 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6808 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006809 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6810 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6811 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6812 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6813 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6814 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6815
6816 /* Loopback mixer controls */
6817 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6818 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6819 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6820 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6821 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6822 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6823 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6824 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6825 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6826 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006827 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6828 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6829 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6830 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006831
6832 /* Controls for GPIO pins, assuming they are configured as outputs */
6833 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6834 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6835 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6836 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6837
Jonathan Woithe92621f12006-02-28 11:47:47 +01006838 /* Switches to allow the digital IO pins to be enabled. The datasheet
6839 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006840 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006841 */
6842 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6843 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6844
Jonathan Woithef8225f62008-01-08 12:16:54 +01006845 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6846 * this output to turn on an external amplifier.
6847 */
6848 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6849 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6850
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006851 { } /* end */
6852};
6853static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006854 /* Enable all GPIOs as outputs with an initial value of 0 */
6855 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6856 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6857 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6858
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006859 /* Enable retasking pins as output, initially without power amp */
6860 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6861 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6862 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6863 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6864 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6865 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6866
Jonathan Woithe92621f12006-02-28 11:47:47 +01006867 /* Disable digital (SPDIF) pins initially, but users can enable
6868 * them via a mixer switch. In the case of SPDIF-out, this initverb
6869 * payload also sets the generation to 0, output to be in "consumer"
6870 * PCM format, copyright asserted, no pre-emphasis and no validity
6871 * control.
6872 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006873 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6874 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6875
Kailang Yangea1fb292008-08-26 12:58:38 +02006876 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006877 * OUT1 sum bus when acting as an output.
6878 */
6879 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6880 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6881 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6882 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6883
6884 /* Start with output sum widgets muted and their output gains at min */
6885 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6886 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6887 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6888 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6889 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6890 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6891 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6892 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6893 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6894
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006895 /* Unmute retasking pin widget output buffers since the default
6896 * state appears to be output. As the pin mode is changed by the
6897 * user the pin mode control will take care of enabling the pin's
6898 * input/output buffers as needed.
6899 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006900 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6901 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6902 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6903 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6904 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6905 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6906 /* Also unmute the mono-out pin widget */
6907 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6908
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006909 /* Mute capture amp left and right */
6910 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006911 /* Set ADC connection select to match default mixer setting (mic1
6912 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006913 */
6914 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6915
6916 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006917 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006918 */
6919 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6920 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6921
6922 /* Mute all inputs to mixer widget (even unconnected ones) */
6923 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6924 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6925 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6926 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6927 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6928 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6929 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6930 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6931
6932 { }
6933};
6934#endif
6935
Takashi Iwai63300792008-01-24 15:31:36 +01006936#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6937#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006938
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006939#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6940#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6941
Kailang Yangdf694da2005-12-05 19:42:22 +01006942/*
6943 * for BIOS auto-configuration
6944 */
6945
6946static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006947 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006948{
6949 hda_nid_t nid_vol;
6950 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006951 int err;
6952
6953 if (nid >= 0x0f && nid < 0x11) {
6954 nid_vol = nid - 0x7;
6955 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6956 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6957 } else if (nid == 0x11) {
6958 nid_vol = nid - 0x7;
6959 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6960 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6961 } else if (nid >= 0x12 && nid <= 0x15) {
6962 nid_vol = 0x08;
6963 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6964 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6965 } else
6966 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006967
Takashi Iwai863b4512008-10-21 17:01:47 +02006968 if (!(*vol_bits & (1 << nid_vol))) {
6969 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006970 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006971 if (err < 0)
6972 return err;
6973 *vol_bits |= (1 << nid_vol);
6974 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006975 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006976 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006977 return err;
6978 return 1;
6979}
6980
6981/* add playback controls from the parsed DAC table */
6982static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6983 const struct auto_pin_cfg *cfg)
6984{
6985 hda_nid_t nid;
6986 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006987 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006988
6989 spec->multiout.num_dacs = 1;
6990 spec->multiout.dac_nids = spec->private_dac_nids;
6991 spec->multiout.dac_nids[0] = 0x02;
6992
6993 nid = cfg->line_out_pins[0];
6994 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006995 const char *pfx;
6996 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6997 pfx = "Master";
6998 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6999 pfx = "Speaker";
7000 else
7001 pfx = "Front";
7002 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01007003 if (err < 0)
7004 return err;
7005 }
7006
Takashi Iwai82bc9552006-03-21 11:24:42 +01007007 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007008 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02007009 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01007010 if (err < 0)
7011 return err;
7012 }
7013
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007014 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007015 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02007016 err = alc260_add_playback_controls(spec, nid, "Headphone",
7017 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01007018 if (err < 0)
7019 return err;
7020 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007021 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01007022}
7023
7024/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02007025static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01007026 const struct auto_pin_cfg *cfg)
7027{
Takashi Iwai05f5f472009-08-25 13:10:18 +02007028 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01007029}
7030
7031static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
7032 hda_nid_t nid, int pin_type,
7033 int sel_idx)
7034{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007035 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007036 /* need the manual connection? */
7037 if (nid >= 0x12) {
7038 int idx = nid - 0x12;
7039 snd_hda_codec_write(codec, idx + 0x0b, 0,
7040 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01007041 }
7042}
7043
7044static void alc260_auto_init_multi_out(struct hda_codec *codec)
7045{
7046 struct alc_spec *spec = codec->spec;
7047 hda_nid_t nid;
7048
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007049 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007050 if (nid) {
7051 int pin_type = get_pin_type(spec->autocfg.line_out_type);
7052 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
7053 }
Kailang Yangea1fb292008-08-26 12:58:38 +02007054
Takashi Iwai82bc9552006-03-21 11:24:42 +01007055 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007056 if (nid)
7057 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
7058
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007059 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007060 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007061 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007062}
Kailang Yangdf694da2005-12-05 19:42:22 +01007063
7064#define ALC260_PIN_CD_NID 0x16
7065static void alc260_auto_init_analog_input(struct hda_codec *codec)
7066{
7067 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02007068 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +01007069 int i;
7070
Takashi Iwai66ceeb62010-08-30 13:05:52 +02007071 for (i = 0; i < cfg->num_inputs; i++) {
7072 hda_nid_t nid = cfg->inputs[i].pin;
Kailang Yangdf694da2005-12-05 19:42:22 +01007073 if (nid >= 0x12) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02007074 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01007075 if (nid != ALC260_PIN_CD_NID &&
7076 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007077 snd_hda_codec_write(codec, nid, 0,
7078 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01007079 AMP_OUT_MUTE);
7080 }
7081 }
7082}
7083
Takashi Iwai7f311a42010-04-09 17:32:23 +02007084#define alc260_auto_init_input_src alc880_auto_init_input_src
7085
Kailang Yangdf694da2005-12-05 19:42:22 +01007086/*
7087 * generic initialization of ADC, input mixers and output mixers
7088 */
7089static struct hda_verb alc260_volume_init_verbs[] = {
7090 /*
7091 * Unmute ADC0-1 and set the default input to mic-in
7092 */
7093 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
7094 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7095 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
7096 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02007097
Kailang Yangdf694da2005-12-05 19:42:22 +01007098 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7099 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007100 * Note: PASD motherboards uses the Line In 2 as the input for
7101 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007102 */
7103 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007104 /* mute analog inputs */
7105 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7106 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7107 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7108 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7109 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007110
7111 /*
7112 * Set up output mixers (0x08 - 0x0a)
7113 */
7114 /* set vol=0 to output mixers */
7115 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7116 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7117 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7118 /* set up input amps for analog loopback */
7119 /* Amp Indices: DAC = 0, mixer = 1 */
7120 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7121 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7122 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7123 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7124 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7125 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02007126
Kailang Yangdf694da2005-12-05 19:42:22 +01007127 { }
7128};
7129
7130static int alc260_parse_auto_config(struct hda_codec *codec)
7131{
7132 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007133 int err;
7134 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
7135
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007136 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7137 alc260_ignore);
7138 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007139 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007140 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
7141 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01007142 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02007143 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01007144 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02007145 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007146 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007147 return err;
7148
7149 spec->multiout.max_channels = 2;
7150
Takashi Iwai0852d7a2009-02-11 11:35:15 +01007151 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007152 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02007153 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01007154 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01007155
Takashi Iwaid88897e2008-10-31 15:01:37 +01007156 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01007157
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007158 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007159 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007160
Kailang Yang6227cdc2010-02-25 08:36:52 +01007161 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02007162
Kailang Yangdf694da2005-12-05 19:42:22 +01007163 return 1;
7164}
7165
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007166/* additional initialization for auto-configuration model */
7167static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007168{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007169 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007170 alc260_auto_init_multi_out(codec);
7171 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02007172 alc260_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02007173 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007174 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007175 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007176}
7177
Takashi Iwaicb53c622007-08-10 17:21:45 +02007178#ifdef CONFIG_SND_HDA_POWER_SAVE
7179static struct hda_amp_list alc260_loopbacks[] = {
7180 { 0x07, HDA_INPUT, 0 },
7181 { 0x07, HDA_INPUT, 1 },
7182 { 0x07, HDA_INPUT, 2 },
7183 { 0x07, HDA_INPUT, 3 },
7184 { 0x07, HDA_INPUT, 4 },
7185 { } /* end */
7186};
7187#endif
7188
Kailang Yangdf694da2005-12-05 19:42:22 +01007189/*
Takashi Iwaifc091762010-08-04 23:53:36 +02007190 * Pin config fixes
7191 */
7192enum {
7193 PINFIX_HP_DC5750,
7194};
7195
Takashi Iwaifc091762010-08-04 23:53:36 +02007196static const struct alc_fixup alc260_fixups[] = {
7197 [PINFIX_HP_DC5750] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007198 .type = ALC_FIXUP_PINS,
7199 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +02007200 { 0x11, 0x90130110 }, /* speaker */
7201 { }
7202 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007203 },
7204};
7205
7206static struct snd_pci_quirk alc260_fixup_tbl[] = {
7207 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
7208 {}
7209};
7210
7211/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007212 * ALC260 configurations
7213 */
Takashi Iwaiea734962011-01-17 11:29:34 +01007214static const char * const alc260_models[ALC260_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007215 [ALC260_BASIC] = "basic",
7216 [ALC260_HP] = "hp",
7217 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02007218 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007219 [ALC260_FUJITSU_S702X] = "fujitsu",
7220 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007221 [ALC260_WILL] = "will",
7222 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01007223 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007224#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007225 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007226#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007227 [ALC260_AUTO] = "auto",
7228};
7229
7230static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01007231 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05007232 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007233 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01007234 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01007235 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01007236 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007237 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02007238 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02007239 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007240 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
7241 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
7242 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
7243 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
7244 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
7245 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
7246 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
7247 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
7248 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007249 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007250 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02007251 {}
7252};
7253
Kailang Yangdf694da2005-12-05 19:42:22 +01007254static struct alc_config_preset alc260_presets[] = {
7255 [ALC260_BASIC] = {
7256 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007257 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007258 .init_verbs = { alc260_init_verbs },
7259 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7260 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007261 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01007262 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007263 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7264 .channel_mode = alc260_modes,
7265 .input_mux = &alc260_capture_source,
7266 },
7267 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01007268 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007269 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007270 .init_verbs = { alc260_init_verbs,
7271 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007272 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7273 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007274 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7275 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007276 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7277 .channel_mode = alc260_modes,
7278 .input_mux = &alc260_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +02007279 .unsol_event = alc_sku_unsol_event,
7280 .setup = alc260_hp_setup,
7281 .init_hook = alc_inithook,
Kailang Yangdf694da2005-12-05 19:42:22 +01007282 },
Kailang Yang3f878302008-08-26 13:02:23 +02007283 [ALC260_HP_DC7600] = {
7284 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007285 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02007286 .init_verbs = { alc260_init_verbs,
7287 alc260_hp_dc7600_verbs },
7288 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7289 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007290 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7291 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02007292 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7293 .channel_mode = alc260_modes,
7294 .input_mux = &alc260_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +02007295 .unsol_event = alc_sku_unsol_event,
7296 .setup = alc260_hp_3012_setup,
7297 .init_hook = alc_inithook,
Kailang Yang3f878302008-08-26 13:02:23 +02007298 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007299 [ALC260_HP_3013] = {
7300 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007301 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007302 .init_verbs = { alc260_hp_3013_init_verbs,
7303 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007304 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7305 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007306 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7307 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007308 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7309 .channel_mode = alc260_modes,
7310 .input_mux = &alc260_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +02007311 .unsol_event = alc_sku_unsol_event,
7312 .setup = alc260_hp_3013_setup,
7313 .init_hook = alc_inithook,
Kailang Yangdf694da2005-12-05 19:42:22 +01007314 },
7315 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007316 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007317 .init_verbs = { alc260_fujitsu_init_verbs },
7318 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7319 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01007320 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7321 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007322 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7323 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007324 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
7325 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01007326 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007327 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007328 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007329 .init_verbs = { alc260_acer_init_verbs },
7330 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7331 .dac_nids = alc260_dac_nids,
7332 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7333 .adc_nids = alc260_dual_adc_nids,
7334 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7335 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007336 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
7337 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007338 },
Michael Schwingencc959482009-02-22 18:58:45 +01007339 [ALC260_FAVORIT100] = {
7340 .mixers = { alc260_favorit100_mixer },
7341 .init_verbs = { alc260_favorit100_init_verbs },
7342 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7343 .dac_nids = alc260_dac_nids,
7344 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7345 .adc_nids = alc260_dual_adc_nids,
7346 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7347 .channel_mode = alc260_modes,
7348 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
7349 .input_mux = alc260_favorit100_capture_sources,
7350 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007351 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007352 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007353 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
7354 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7355 .dac_nids = alc260_dac_nids,
7356 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7357 .adc_nids = alc260_adc_nids,
7358 .dig_out_nid = ALC260_DIGOUT_NID,
7359 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7360 .channel_mode = alc260_modes,
7361 .input_mux = &alc260_capture_source,
7362 },
7363 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007364 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007365 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
7366 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7367 .dac_nids = alc260_dac_nids,
7368 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7369 .adc_nids = alc260_adc_nids,
7370 .dig_out_nid = ALC260_DIGOUT_NID,
7371 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7372 .channel_mode = alc260_modes,
7373 .input_mux = &alc260_capture_source,
7374 .unsol_event = alc260_replacer_672v_unsol_event,
7375 .init_hook = alc260_replacer_672v_automute,
7376 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007377#ifdef CONFIG_SND_DEBUG
7378 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007379 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007380 .init_verbs = { alc260_test_init_verbs },
7381 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
7382 .dac_nids = alc260_test_dac_nids,
7383 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
7384 .adc_nids = alc260_test_adc_nids,
7385 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7386 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007387 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
7388 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007389 },
7390#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01007391};
7392
Linus Torvalds1da177e2005-04-16 15:20:36 -07007393static int patch_alc260(struct hda_codec *codec)
7394{
7395 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007396 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007397
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007398 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007399 if (spec == NULL)
7400 return -ENOMEM;
7401
7402 codec->spec = spec;
7403
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007404 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
7405 alc260_models,
7406 alc260_cfg_tbl);
7407 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02007408 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02007409 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01007410 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02007411 }
7412
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007413 if (board_config == ALC260_AUTO) {
7414 alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups);
7415 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
7416 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007417
Kailang Yangdf694da2005-12-05 19:42:22 +01007418 if (board_config == ALC260_AUTO) {
7419 /* automatic parse from the BIOS config */
7420 err = alc260_parse_auto_config(codec);
7421 if (err < 0) {
7422 alc_free(codec);
7423 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007424 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007425 printk(KERN_INFO
7426 "hda_codec: Cannot set up configuration "
7427 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007428 board_config = ALC260_BASIC;
7429 }
Takashi Iwai16ded522005-06-10 19:58:24 +02007430 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007431
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007432 err = snd_hda_attach_beep_device(codec, 0x1);
7433 if (err < 0) {
7434 alc_free(codec);
7435 return err;
7436 }
7437
Kailang Yangdf694da2005-12-05 19:42:22 +01007438 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02007439 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007440
Linus Torvalds1da177e2005-04-16 15:20:36 -07007441 spec->stream_analog_playback = &alc260_pcm_analog_playback;
7442 spec->stream_analog_capture = &alc260_pcm_analog_capture;
Jonathan Woithe53bacfb2010-08-08 00:17:05 +09307443 spec->stream_analog_alt_capture = &alc260_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007444
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007445 spec->stream_digital_playback = &alc260_pcm_digital_playback;
7446 spec->stream_digital_capture = &alc260_pcm_digital_capture;
7447
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007448 if (!spec->adc_nids && spec->input_mux) {
7449 /* check whether NID 0x04 is valid */
7450 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02007451 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007452 /* get type */
7453 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
7454 spec->adc_nids = alc260_adc_nids_alt;
7455 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
7456 } else {
7457 spec->adc_nids = alc260_adc_nids;
7458 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
7459 }
7460 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02007461 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007462 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007463
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007464 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwaifc091762010-08-04 23:53:36 +02007465
Takashi Iwai2134ea42008-01-10 16:53:55 +01007466 spec->vmaster_nid = 0x08;
7467
Linus Torvalds1da177e2005-04-16 15:20:36 -07007468 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007469 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007470 spec->init_hook = alc260_auto_init;
Takashi Iwai1c7161532011-04-07 10:37:16 +02007471 spec->shutup = alc_eapd_shutup;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007472#ifdef CONFIG_SND_HDA_POWER_SAVE
7473 if (!spec->loopback.amplist)
7474 spec->loopback.amplist = alc260_loopbacks;
7475#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07007476
7477 return 0;
7478}
7479
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007480
Linus Torvalds1da177e2005-04-16 15:20:36 -07007481/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007482 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07007483 *
7484 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
7485 * configuration. Each pin widget can choose any input DACs and a mixer.
7486 * Each ADC is connected from a mixer of all inputs. This makes possible
7487 * 6-channel independent captures.
7488 *
7489 * In addition, an independent DAC for the multi-playback (not used in this
7490 * driver yet).
7491 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007492#define ALC882_DIGOUT_NID 0x06
7493#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02007494#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
7495#define ALC883_DIGIN_NID ALC882_DIGIN_NID
7496#define ALC1200_DIGOUT_NID 0x10
7497
Linus Torvalds1da177e2005-04-16 15:20:36 -07007498
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01007499static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007500 { 8, NULL }
7501};
7502
Takashi Iwai4953550a2009-06-30 15:28:30 +02007503/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007504static hda_nid_t alc882_dac_nids[4] = {
7505 /* front, rear, clfe, rear_surr */
7506 0x02, 0x03, 0x04, 0x05
7507};
Takashi Iwai4953550a2009-06-30 15:28:30 +02007508#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007509
Takashi Iwai4953550a2009-06-30 15:28:30 +02007510/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01007511#define alc882_adc_nids alc880_adc_nids
7512#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02007513#define alc883_adc_nids alc882_adc_nids_alt
7514static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
7515static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
7516#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007517
Takashi Iwaie1406342008-02-11 18:32:32 +01007518static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
7519static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007520#define alc883_capsrc_nids alc882_capsrc_nids_alt
7521static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7522#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01007523
Linus Torvalds1da177e2005-04-16 15:20:36 -07007524/* input MUX */
7525/* FIXME: should be a matrix-type input source selection */
7526
7527static struct hda_input_mux alc882_capture_source = {
7528 .num_items = 4,
7529 .items = {
7530 { "Mic", 0x0 },
7531 { "Front Mic", 0x1 },
7532 { "Line", 0x2 },
7533 { "CD", 0x4 },
7534 },
7535};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007536
Takashi Iwai4953550a2009-06-30 15:28:30 +02007537#define alc883_capture_source alc882_capture_source
7538
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007539static struct hda_input_mux alc889_capture_source = {
7540 .num_items = 3,
7541 .items = {
7542 { "Front Mic", 0x0 },
7543 { "Mic", 0x3 },
7544 { "Line", 0x2 },
7545 },
7546};
7547
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007548static struct hda_input_mux mb5_capture_source = {
7549 .num_items = 3,
7550 .items = {
7551 { "Mic", 0x1 },
Alex Murrayb8f171e2010-06-14 12:08:43 +09307552 { "Line", 0x7 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007553 { "CD", 0x4 },
7554 },
7555};
7556
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007557static struct hda_input_mux macmini3_capture_source = {
7558 .num_items = 2,
7559 .items = {
7560 { "Line", 0x2 },
7561 { "CD", 0x4 },
7562 },
7563};
7564
Takashi Iwai4953550a2009-06-30 15:28:30 +02007565static struct hda_input_mux alc883_3stack_6ch_intel = {
7566 .num_items = 4,
7567 .items = {
7568 { "Mic", 0x1 },
7569 { "Front Mic", 0x0 },
7570 { "Line", 0x2 },
7571 { "CD", 0x4 },
7572 },
7573};
7574
7575static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7576 .num_items = 2,
7577 .items = {
7578 { "Mic", 0x1 },
7579 { "Line", 0x2 },
7580 },
7581};
7582
7583static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7584 .num_items = 4,
7585 .items = {
7586 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +01007587 { "Internal Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007588 { "Line", 0x2 },
7589 { "CD", 0x4 },
7590 },
7591};
7592
7593static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7594 .num_items = 2,
7595 .items = {
7596 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +01007597 { "Internal Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007598 },
7599};
7600
7601static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7602 .num_items = 3,
7603 .items = {
7604 { "Mic", 0x0 },
7605 { "Front Mic", 0x1 },
7606 { "Line", 0x4 },
7607 },
7608};
7609
7610static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7611 .num_items = 2,
7612 .items = {
7613 { "Mic", 0x0 },
7614 { "Line", 0x2 },
7615 },
7616};
7617
7618static struct hda_input_mux alc889A_mb31_capture_source = {
7619 .num_items = 2,
7620 .items = {
7621 { "Mic", 0x0 },
7622 /* Front Mic (0x01) unused */
7623 { "Line", 0x2 },
7624 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007625 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007626 },
7627};
7628
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007629static struct hda_input_mux alc889A_imac91_capture_source = {
7630 .num_items = 2,
7631 .items = {
7632 { "Mic", 0x01 },
7633 { "Line", 0x2 }, /* Not sure! */
7634 },
7635};
7636
Takashi Iwai4953550a2009-06-30 15:28:30 +02007637/*
7638 * 2ch mode
7639 */
7640static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7641 { 2, NULL }
7642};
7643
Kailang Yangdf694da2005-12-05 19:42:22 +01007644/*
Kailang Yang272a5272007-05-14 11:00:38 +02007645 * 2ch mode
7646 */
7647static struct hda_verb alc882_3ST_ch2_init[] = {
7648 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7649 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7650 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7651 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7652 { } /* end */
7653};
7654
7655/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007656 * 4ch mode
7657 */
7658static struct hda_verb alc882_3ST_ch4_init[] = {
7659 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7660 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7661 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7662 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7663 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7664 { } /* end */
7665};
7666
7667/*
Kailang Yang272a5272007-05-14 11:00:38 +02007668 * 6ch mode
7669 */
7670static struct hda_verb alc882_3ST_ch6_init[] = {
7671 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7672 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7673 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7674 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7675 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7676 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7677 { } /* end */
7678};
7679
Takashi Iwai4953550a2009-06-30 15:28:30 +02007680static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007681 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007682 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007683 { 6, alc882_3ST_ch6_init },
7684};
7685
Takashi Iwai4953550a2009-06-30 15:28:30 +02007686#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7687
Kailang Yang272a5272007-05-14 11:00:38 +02007688/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307689 * 2ch mode
7690 */
7691static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7692 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7693 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7694 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7695 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7696 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7697 { } /* end */
7698};
7699
7700/*
7701 * 4ch mode
7702 */
7703static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7704 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7705 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7706 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7707 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7708 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7709 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7710 { } /* end */
7711};
7712
7713/*
7714 * 6ch mode
7715 */
7716static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7717 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7718 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7719 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7720 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7721 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7722 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7723 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7724 { } /* end */
7725};
7726
7727static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7728 { 2, alc883_3ST_ch2_clevo_init },
7729 { 4, alc883_3ST_ch4_clevo_init },
7730 { 6, alc883_3ST_ch6_clevo_init },
7731};
7732
7733
7734/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007735 * 6ch mode
7736 */
7737static struct hda_verb alc882_sixstack_ch6_init[] = {
7738 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7739 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7740 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7741 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7742 { } /* end */
7743};
7744
7745/*
7746 * 8ch mode
7747 */
7748static struct hda_verb alc882_sixstack_ch8_init[] = {
7749 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7750 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7751 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7752 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7753 { } /* end */
7754};
7755
7756static struct hda_channel_mode alc882_sixstack_modes[2] = {
7757 { 6, alc882_sixstack_ch6_init },
7758 { 8, alc882_sixstack_ch8_init },
7759};
7760
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007761
7762/* Macbook Air 2,1 */
7763
7764static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7765 { 2, NULL },
7766};
7767
Takashi Iwai87350ad2007-08-16 18:19:38 +02007768/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007769 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007770 */
7771
7772/*
7773 * 2ch mode
7774 */
7775static struct hda_verb alc885_mbp_ch2_init[] = {
7776 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7777 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7778 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7779 { } /* end */
7780};
7781
7782/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007783 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007784 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007785static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007786 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7787 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7788 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7789 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7790 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7791 { } /* end */
7792};
7793
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007794static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007795 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007796 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007797};
7798
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007799/*
7800 * 2ch
7801 * Speakers/Woofer/HP = Front
7802 * LineIn = Input
7803 */
7804static struct hda_verb alc885_mb5_ch2_init[] = {
7805 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7806 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7807 { } /* end */
7808};
7809
7810/*
7811 * 6ch mode
7812 * Speakers/HP = Front
7813 * Woofer = LFE
7814 * LineIn = Surround
7815 */
7816static struct hda_verb alc885_mb5_ch6_init[] = {
7817 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7818 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7819 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7820 { } /* end */
7821};
7822
7823static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7824 { 2, alc885_mb5_ch2_init },
7825 { 6, alc885_mb5_ch6_init },
7826};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007827
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007828#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007829
7830/*
7831 * 2ch mode
7832 */
7833static struct hda_verb alc883_4ST_ch2_init[] = {
7834 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7835 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7836 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7837 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7838 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7839 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7840 { } /* end */
7841};
7842
7843/*
7844 * 4ch mode
7845 */
7846static struct hda_verb alc883_4ST_ch4_init[] = {
7847 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7848 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7849 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7850 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7851 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7852 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7853 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7854 { } /* end */
7855};
7856
7857/*
7858 * 6ch mode
7859 */
7860static struct hda_verb alc883_4ST_ch6_init[] = {
7861 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7862 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7863 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7864 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7865 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7866 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7867 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7868 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7869 { } /* end */
7870};
7871
7872/*
7873 * 8ch mode
7874 */
7875static struct hda_verb alc883_4ST_ch8_init[] = {
7876 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7877 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7878 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7879 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7880 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7881 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7882 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7883 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7884 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7885 { } /* end */
7886};
7887
7888static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7889 { 2, alc883_4ST_ch2_init },
7890 { 4, alc883_4ST_ch4_init },
7891 { 6, alc883_4ST_ch6_init },
7892 { 8, alc883_4ST_ch8_init },
7893};
7894
7895
7896/*
7897 * 2ch mode
7898 */
7899static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7900 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7901 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7902 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7903 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7904 { } /* end */
7905};
7906
7907/*
7908 * 4ch mode
7909 */
7910static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7911 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7912 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7913 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7914 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7915 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7916 { } /* end */
7917};
7918
7919/*
7920 * 6ch mode
7921 */
7922static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7923 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7924 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7925 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7926 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7927 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7928 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7929 { } /* end */
7930};
7931
7932static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7933 { 2, alc883_3ST_ch2_intel_init },
7934 { 4, alc883_3ST_ch4_intel_init },
7935 { 6, alc883_3ST_ch6_intel_init },
7936};
7937
7938/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007939 * 2ch mode
7940 */
7941static struct hda_verb alc889_ch2_intel_init[] = {
7942 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7943 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7944 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7945 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7946 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7947 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7948 { } /* end */
7949};
7950
7951/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007952 * 6ch mode
7953 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007954static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007955 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7956 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7957 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7958 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7959 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007960 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7961 { } /* end */
7962};
7963
7964/*
7965 * 8ch mode
7966 */
7967static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007968 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7969 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7970 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7971 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7972 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007973 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7974 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007975 { } /* end */
7976};
7977
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007978static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7979 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007980 { 6, alc889_ch6_intel_init },
7981 { 8, alc889_ch8_intel_init },
7982};
7983
7984/*
7985 * 6ch mode
7986 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007987static struct hda_verb alc883_sixstack_ch6_init[] = {
7988 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7989 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7990 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7991 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7992 { } /* end */
7993};
7994
7995/*
7996 * 8ch mode
7997 */
7998static struct hda_verb alc883_sixstack_ch8_init[] = {
7999 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8000 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8001 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8002 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8003 { } /* end */
8004};
8005
8006static struct hda_channel_mode alc883_sixstack_modes[2] = {
8007 { 6, alc883_sixstack_ch6_init },
8008 { 8, alc883_sixstack_ch8_init },
8009};
8010
8011
Linus Torvalds1da177e2005-04-16 15:20:36 -07008012/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
8013 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
8014 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01008015static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02008016 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01008017 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02008018 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01008019 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02008020 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8021 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01008022 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8023 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02008024 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01008025 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07008026 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8027 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8028 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8029 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8030 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8031 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008032 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07008033 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8034 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008035 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07008036 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07008037 { } /* end */
8038};
8039
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008040/* Macbook Air 2,1 same control for HP and internal Speaker */
8041
8042static struct snd_kcontrol_new alc885_mba21_mixer[] = {
8043 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8044 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
8045 { }
8046};
8047
8048
Takashi Iwai87350ad2007-08-16 18:19:38 +02008049static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008050 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8051 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
8052 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
8053 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
8054 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01008055 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8056 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02008057 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8058 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008059 HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
8060 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02008061 { } /* end */
8062};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008063
8064static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008065 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8066 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8067 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8068 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8069 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
8070 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10308071 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
8072 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Alex Murrayb8f171e2010-06-14 12:08:43 +09308073 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
8074 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008075 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8076 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008077 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
8078 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0x00, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008079 { } /* end */
8080};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008081
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008082static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
8083 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8084 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8085 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8086 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8087 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
8088 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
8089 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
8090 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
8091 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
8092 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008093 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008094 { } /* end */
8095};
8096
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008097static struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008098 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8099 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008100 { } /* end */
8101};
8102
8103
Kailang Yangbdd148a2007-05-08 15:19:08 +02008104static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
8105 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8106 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8107 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8108 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8109 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8110 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8111 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008112 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02008113 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02008114 { } /* end */
8115};
8116
Kailang Yang272a5272007-05-14 11:00:38 +02008117static struct snd_kcontrol_new alc882_targa_mixer[] = {
8118 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8119 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8120 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8121 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8122 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8123 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8124 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8125 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8126 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008127 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008128 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8129 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008130 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008131 { } /* end */
8132};
8133
8134/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
8135 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
8136 */
8137static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
8138 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8139 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8140 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8141 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
8142 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8143 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8144 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8145 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8146 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
8147 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
8148 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8149 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008150 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008151 { } /* end */
8152};
8153
Takashi Iwai914759b2007-09-06 14:52:04 +02008154static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
8155 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8156 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8157 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8158 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8159 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8160 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8161 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8162 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008163 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008164 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008165 { } /* end */
8166};
8167
Kailang Yangdf694da2005-12-05 19:42:22 +01008168static struct snd_kcontrol_new alc882_chmode_mixer[] = {
8169 {
8170 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8171 .name = "Channel Mode",
8172 .info = alc_ch_mode_info,
8173 .get = alc_ch_mode_get,
8174 .put = alc_ch_mode_put,
8175 },
8176 { } /* end */
8177};
8178
Takashi Iwai4953550a2009-06-30 15:28:30 +02008179static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07008180 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008181 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8182 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008183 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008184 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8185 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008186 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008187 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8188 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008189 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008190 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8191 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008192
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008193 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008194 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008195 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008196 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008197 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008198 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008199 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008200 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008201 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008202 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008203 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008204 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008205 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008206 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008207 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008208 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008209 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008210 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008211 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8212 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008213 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008214 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8215 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008216 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008217 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8218 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8219 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8220 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8221 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008222 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008223 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008224
8225 /* FIXME: use matrix-type input source selection */
8226 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008227 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008228 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008229 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008230 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02008231 /* ADC2: mute amp left and right */
8232 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008233 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02008234 /* ADC3: mute amp left and right */
8235 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008236 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008237
8238 { }
8239};
8240
Takashi Iwai4953550a2009-06-30 15:28:30 +02008241static struct hda_verb alc882_adc1_init_verbs[] = {
8242 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8243 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8244 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8245 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8246 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8247 /* ADC1: mute amp left and right */
8248 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8249 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8250 { }
8251};
8252
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008253static struct hda_verb alc882_eapd_verbs[] = {
8254 /* change to EAPD mode */
8255 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008256 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008257 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008258};
8259
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008260static struct hda_verb alc889_eapd_verbs[] = {
8261 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8262 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8263 { }
8264};
8265
Wu Fengguang6732bd02009-07-30 09:19:14 +02008266static struct hda_verb alc_hp15_unsol_verbs[] = {
8267 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8268 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8269 {}
8270};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008271
8272static struct hda_verb alc885_init_verbs[] = {
8273 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01008274 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8275 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008276 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008277 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8278 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008279 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008280 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8281 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008282 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008283 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8284 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008285
8286 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02008287 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008288 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8289 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8290 /* Front Pin: output 0 (0x0c) */
8291 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8292 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8293 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8294 /* Rear Pin: output 1 (0x0d) */
8295 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8296 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8297 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
8298 /* CLFE Pin: output 2 (0x0e) */
8299 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8300 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8301 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8302 /* Side Pin: output 3 (0x0f) */
8303 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8304 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8305 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8306 /* Mic (rear) pin: input vref at 80% */
8307 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8308 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8309 /* Front Mic pin: input vref at 80% */
8310 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8311 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8312 /* Line In pin: input */
8313 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8314 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8315
8316 /* Mixer elements: 0x18, , 0x1a, 0x1b */
8317 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01008318 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008319 /* Input mixer2 */
8320 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008321 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008322 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008323 /* ADC2: mute amp left and right */
8324 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8325 /* ADC3: mute amp left and right */
8326 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8327
8328 { }
8329};
8330
8331static struct hda_verb alc885_init_input_verbs[] = {
8332 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8333 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8334 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8335 { }
8336};
8337
8338
8339/* Unmute Selector 24h and set the default input to front mic */
8340static struct hda_verb alc889_init_input_verbs[] = {
8341 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
8342 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8343 { }
8344};
8345
8346
Takashi Iwai4953550a2009-06-30 15:28:30 +02008347#define alc883_init_verbs alc882_base_init_verbs
8348
Tobin Davis9102cd12006-12-15 10:02:12 +01008349/* Mac Pro test */
8350static struct snd_kcontrol_new alc882_macpro_mixer[] = {
8351 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8352 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8353 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
8354 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8355 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008356 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01008357 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
8358 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008359 */
Tobin Davis9102cd12006-12-15 10:02:12 +01008360 { } /* end */
8361};
8362
8363static struct hda_verb alc882_macpro_init_verbs[] = {
8364 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8365 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8366 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8367 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8368 /* Front Pin: output 0 (0x0c) */
8369 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8370 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8371 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8372 /* Front Mic pin: input vref at 80% */
8373 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8374 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8375 /* Speaker: output */
8376 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8377 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8378 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
8379 /* Headphone output (output 0 - 0x0c) */
8380 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8381 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8382 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8383
8384 /* FIXME: use matrix-type input source selection */
8385 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8386 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8387 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8388 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8389 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8390 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8391 /* Input mixer2 */
8392 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8393 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8394 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8395 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8396 /* Input mixer3 */
8397 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8398 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8399 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8400 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8401 /* ADC1: mute amp left and right */
8402 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8403 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8404 /* ADC2: mute amp left and right */
8405 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8406 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8407 /* ADC3: mute amp left and right */
8408 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8409 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8410
8411 { }
8412};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008413
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008414/* Macbook 5,1 */
8415static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008416 /* DACs */
8417 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8418 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8419 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8420 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008421 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008422 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8423 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8424 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008425 /* Surround mixer */
8426 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8427 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8428 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8429 /* LFE mixer */
8430 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8431 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8432 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8433 /* HP mixer */
8434 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8435 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8436 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8437 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008438 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8439 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008440 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8441 /* LFE Pin (0x0e) */
8442 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8443 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8444 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8445 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008446 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8447 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008448 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10308449 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008450 /* Front Mic pin: input vref at 80% */
8451 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8452 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8453 /* Line In pin */
8454 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8455 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8456
Alex Murrayb8f171e2010-06-14 12:08:43 +09308457 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
8458 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
8459 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008460 { }
8461};
8462
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008463/* Macmini 3,1 */
8464static struct hda_verb alc885_macmini3_init_verbs[] = {
8465 /* DACs */
8466 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8467 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8468 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8469 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8470 /* Front mixer */
8471 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8472 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8473 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8474 /* Surround mixer */
8475 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8476 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8477 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8478 /* LFE mixer */
8479 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8480 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8481 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8482 /* HP mixer */
8483 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8484 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8485 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8486 /* Front Pin (0x0c) */
8487 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8488 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8489 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8490 /* LFE Pin (0x0e) */
8491 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8492 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8493 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8494 /* HP Pin (0x0f) */
8495 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8496 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8497 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
8498 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8499 /* Line In pin */
8500 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8501 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8502
8503 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8504 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8505 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8506 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8507 { }
8508};
8509
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008510
8511static struct hda_verb alc885_mba21_init_verbs[] = {
8512 /*Internal and HP Speaker Mixer*/
8513 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8514 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8515 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8516 /*Internal Speaker Pin (0x0c)*/
8517 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8518 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8519 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8520 /* HP Pin: output 0 (0x0e) */
8521 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
8522 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8523 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8524 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8525 /* Line in (is hp when jack connected)*/
8526 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8527 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8528
8529 { }
8530 };
8531
8532
Takashi Iwai87350ad2007-08-16 18:19:38 +02008533/* Macbook Pro rev3 */
8534static struct hda_verb alc885_mbp3_init_verbs[] = {
8535 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8536 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8537 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8538 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8539 /* Rear mixer */
8540 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8541 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8542 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008543 /* HP mixer */
8544 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8545 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8546 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008547 /* Front Pin: output 0 (0x0c) */
8548 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8549 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8550 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008551 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02008552 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008553 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8554 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008555 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8556 /* Mic (rear) pin: input vref at 80% */
8557 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8558 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8559 /* Front Mic pin: input vref at 80% */
8560 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8561 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8562 /* Line In pin: use output 1 when in LineOut mode */
8563 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8564 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8565 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8566
8567 /* FIXME: use matrix-type input source selection */
8568 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8569 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8570 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8571 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8572 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8573 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8574 /* Input mixer2 */
8575 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8576 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8577 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8578 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8579 /* Input mixer3 */
8580 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8581 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8582 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8583 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8584 /* ADC1: mute amp left and right */
8585 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8586 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8587 /* ADC2: mute amp left and right */
8588 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8589 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8590 /* ADC3: mute amp left and right */
8591 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8592 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8593
8594 { }
8595};
8596
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008597/* iMac 9,1 */
8598static struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008599 /* Internal Speaker Pin (0x0c) */
8600 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8601 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8602 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8603 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8604 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8605 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8606 /* HP Pin: Rear */
8607 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8608 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8609 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8610 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8611 /* Line in Rear */
8612 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8613 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8614 /* Front Mic pin: input vref at 80% */
8615 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8616 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008617 /* Rear mixer */
8618 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8619 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8620 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008621 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8622 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8623 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8624 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8625 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008626 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8627 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8628 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8629 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008630 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008631 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8632 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8633 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8634 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008635 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008636 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8637 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8638 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8639 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008640 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008641 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8642 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008643 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008644 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8645 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008646 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008647 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8648 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008649 { }
8650};
8651
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008652/* iMac 24 mixer. */
8653static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8654 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8655 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8656 { } /* end */
8657};
8658
8659/* iMac 24 init verbs. */
8660static struct hda_verb alc885_imac24_init_verbs[] = {
8661 /* Internal speakers: output 0 (0x0c) */
8662 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8663 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8664 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8665 /* Internal speakers: output 0 (0x0c) */
8666 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8667 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8668 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8669 /* Headphone: output 0 (0x0c) */
8670 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8671 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8672 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8673 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8674 /* Front Mic: input vref at 80% */
8675 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8676 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8677 { }
8678};
8679
8680/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008681static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008682{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008683 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008684
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008685 spec->autocfg.hp_pins[0] = 0x14;
8686 spec->autocfg.speaker_pins[0] = 0x18;
8687 spec->autocfg.speaker_pins[1] = 0x1a;
Takashi Iwaid922b512011-04-28 12:18:53 +02008688 spec->automute = 1;
8689 spec->automute_mode = ALC_AUTOMUTE_AMP;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008690}
8691
Takashi Iwai9d54f082010-02-22 08:34:40 +01008692#define alc885_mb5_setup alc885_imac24_setup
8693#define alc885_macmini3_setup alc885_imac24_setup
8694
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008695/* Macbook Air 2,1 */
8696static void alc885_mba21_setup(struct hda_codec *codec)
8697{
8698 struct alc_spec *spec = codec->spec;
8699
8700 spec->autocfg.hp_pins[0] = 0x14;
8701 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwaid922b512011-04-28 12:18:53 +02008702 spec->automute = 1;
8703 spec->automute_mode = ALC_AUTOMUTE_AMP;
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008704}
8705
8706
8707
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008708static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008709{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008710 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008711
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008712 spec->autocfg.hp_pins[0] = 0x15;
8713 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +02008714 spec->automute = 1;
8715 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008716}
8717
Takashi Iwai9d54f082010-02-22 08:34:40 +01008718static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308719{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008720 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308721
Takashi Iwai9d54f082010-02-22 08:34:40 +01008722 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008723 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008724 spec->autocfg.speaker_pins[1] = 0x1a;
Takashi Iwaid922b512011-04-28 12:18:53 +02008725 spec->automute = 1;
8726 spec->automute_mode = ALC_AUTOMUTE_AMP;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008727}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008728
Kailang Yang272a5272007-05-14 11:00:38 +02008729static struct hda_verb alc882_targa_verbs[] = {
8730 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8731 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8732
8733 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8734 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008735
Kailang Yang272a5272007-05-14 11:00:38 +02008736 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8737 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8738 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8739
8740 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008741 { } /* end */
8742};
8743
8744/* toggle speaker-output according to the hp-jack state */
8745static void alc882_targa_automute(struct hda_codec *codec)
8746{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008747 struct alc_spec *spec = codec->spec;
Takashi Iwaid922b512011-04-28 12:18:53 +02008748 alc_hp_automute(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008749 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008750 spec->jack_present ? 1 : 3);
8751}
8752
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008753static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008754{
8755 struct alc_spec *spec = codec->spec;
8756
8757 spec->autocfg.hp_pins[0] = 0x14;
8758 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaid922b512011-04-28 12:18:53 +02008759 spec->automute = 1;
8760 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yang272a5272007-05-14 11:00:38 +02008761}
8762
8763static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8764{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008765 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008766 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008767}
8768
8769static struct hda_verb alc882_asus_a7j_verbs[] = {
8770 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8771 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8772
8773 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8774 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8775 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008776
Kailang Yang272a5272007-05-14 11:00:38 +02008777 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8778 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8779 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8780
8781 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8782 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8783 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8784 { } /* end */
8785};
8786
Takashi Iwai914759b2007-09-06 14:52:04 +02008787static struct hda_verb alc882_asus_a7m_verbs[] = {
8788 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8789 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8790
8791 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8792 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8793 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008794
Takashi Iwai914759b2007-09-06 14:52:04 +02008795 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8796 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8797 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8798
8799 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8800 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8801 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8802 { } /* end */
8803};
8804
Tobin Davis9102cd12006-12-15 10:02:12 +01008805static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8806{
8807 unsigned int gpiostate, gpiomask, gpiodir;
8808
8809 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8810 AC_VERB_GET_GPIO_DATA, 0);
8811
8812 if (!muted)
8813 gpiostate |= (1 << pin);
8814 else
8815 gpiostate &= ~(1 << pin);
8816
8817 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8818 AC_VERB_GET_GPIO_MASK, 0);
8819 gpiomask |= (1 << pin);
8820
8821 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8822 AC_VERB_GET_GPIO_DIRECTION, 0);
8823 gpiodir |= (1 << pin);
8824
8825
8826 snd_hda_codec_write(codec, codec->afg, 0,
8827 AC_VERB_SET_GPIO_MASK, gpiomask);
8828 snd_hda_codec_write(codec, codec->afg, 0,
8829 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8830
8831 msleep(1);
8832
8833 snd_hda_codec_write(codec, codec->afg, 0,
8834 AC_VERB_SET_GPIO_DATA, gpiostate);
8835}
8836
Takashi Iwai7debbe52007-08-16 15:01:03 +02008837/* set up GPIO at initialization */
8838static void alc885_macpro_init_hook(struct hda_codec *codec)
8839{
8840 alc882_gpio_mute(codec, 0, 0);
8841 alc882_gpio_mute(codec, 1, 0);
8842}
8843
8844/* set up GPIO and update auto-muting at initialization */
8845static void alc885_imac24_init_hook(struct hda_codec *codec)
8846{
8847 alc885_macpro_init_hook(codec);
Takashi Iwaid922b512011-04-28 12:18:53 +02008848 alc_hp_automute(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008849}
8850
Kailang Yangdf694da2005-12-05 19:42:22 +01008851/*
8852 * generic initialization of ADC, input mixers and output mixers
8853 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008854static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008855 /*
8856 * Unmute ADC0-2 and set the default input to mic-in
8857 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008858 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8859 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8860 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8861 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8862
Kailang Yangdf694da2005-12-05 19:42:22 +01008863 /*
8864 * Set up output mixers (0x0c - 0x0f)
8865 */
8866 /* set vol=0 to output mixers */
8867 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8868 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8869 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8870 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8871 /* set up input amps for analog loopback */
8872 /* Amp Indices: DAC = 0, mixer = 1 */
8873 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8874 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8875 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8876 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8877 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8878 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8879 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8880 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8881 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8882 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8883
8884 /* FIXME: use matrix-type input source selection */
8885 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008886 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008887 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008888 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008889 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008890 { }
8891};
8892
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008893/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8894static struct hda_verb alc889A_mb31_ch2_init[] = {
8895 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8896 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8897 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8898 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8899 { } /* end */
8900};
8901
8902/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8903static struct hda_verb alc889A_mb31_ch4_init[] = {
8904 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8905 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8906 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8907 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8908 { } /* end */
8909};
8910
8911/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8912static struct hda_verb alc889A_mb31_ch5_init[] = {
8913 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8914 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8915 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8916 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8917 { } /* end */
8918};
8919
8920/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8921static struct hda_verb alc889A_mb31_ch6_init[] = {
8922 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8923 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8924 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8925 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8926 { } /* end */
8927};
8928
8929static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8930 { 2, alc889A_mb31_ch2_init },
8931 { 4, alc889A_mb31_ch4_init },
8932 { 5, alc889A_mb31_ch5_init },
8933 { 6, alc889A_mb31_ch6_init },
8934};
8935
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008936static struct hda_verb alc883_medion_eapd_verbs[] = {
8937 /* eanable EAPD on medion laptop */
8938 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8939 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8940 { }
8941};
8942
Takashi Iwai4953550a2009-06-30 15:28:30 +02008943#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008944
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008945static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8946 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8947 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8948 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8949 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8950 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8951 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8952 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8953 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008954 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008955 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8956 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008957 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008958 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008959 { } /* end */
8960};
8961
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008962static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008963 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8964 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8965 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8966 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8967 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008968 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008969 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008970 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008971 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008972 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008973 { } /* end */
8974};
8975
Jiang zhefb97dc62008-03-06 11:07:11 +01008976static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8977 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8978 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8979 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8980 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8981 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008982 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008983 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008984 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008985 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008986 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008987 { } /* end */
8988};
8989
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008990static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8991 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8992 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8993 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8994 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8995 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8996 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8997 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8998 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008999 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009000 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9001 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009002 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009003 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009004 { } /* end */
9005};
9006
9007static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
9008 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9009 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9010 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9011 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9012 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9013 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9014 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9015 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9016 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9017 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9018 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9019 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9020 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9021 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009022 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009023 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9024 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009025 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009026 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009027 { } /* end */
9028};
9029
Jiang zhe17bba1b2008-06-04 12:11:07 +02009030static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
9031 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9032 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9033 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9034 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9035 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
9036 HDA_OUTPUT),
9037 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9038 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9039 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9040 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9041 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9042 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9043 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9044 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9045 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009046 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02009047 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9048 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009049 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02009050 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02009051 { } /* end */
9052};
9053
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009054static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
9055 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9056 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9057 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9058 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9059 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
9060 HDA_OUTPUT),
9061 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9062 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9063 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9064 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9065 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
9066 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9067 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9068 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9069 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009070 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1b, 0, HDA_INPUT),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009071 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
9072 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009073 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009074 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9075 { } /* end */
9076};
9077
Takashi Iwaid1d985f2006-11-23 19:27:12 +01009078static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02009079 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02009080 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009081 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02009082 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009083 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9084 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02009085 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9086 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009087 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9088 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9089 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9090 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9091 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9092 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009093 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009094 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9095 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009096 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009097 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009098 { } /* end */
9099};
9100
Sasha Alexandrc2592492009-06-16 14:52:54 -04009101static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009102 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009103 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009104 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009105 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009106 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9107 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9108 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9109 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9110 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9111 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9112 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9113 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9114 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9115 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9116 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009117 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009118 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009119 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009120};
Kailang Yangccc656c2006-10-17 12:32:26 +02009121
Sasha Alexandrc2592492009-06-16 14:52:54 -04009122static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009123 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009124 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009125 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009126 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009127 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9128 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9129 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009130 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009131 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009132 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009133 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009134 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009135 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009136};
Kailang Yangccc656c2006-10-17 12:32:26 +02009137
Takashi Iwaib99dba32009-09-17 18:23:00 +02009138static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
9139 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9140 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009141 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009142 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009143 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009144 { } /* end */
9145};
9146
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009147static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
9148 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9149 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009150 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9151 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009152 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9153 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009154 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009155 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009156 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009157};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009158
Kailang Yang272a5272007-05-14 11:00:38 +02009159static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
9160 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9161 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
9162 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 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("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9166 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009167 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9168 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02009169 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02009170};
Kailang Yang272a5272007-05-14 11:00:38 +02009171
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009172static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
9173 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9174 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9175 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9176 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
9177 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
9178 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
9179 { } /* end */
9180};
9181
9182static struct hda_verb alc883_medion_wim2160_verbs[] = {
9183 /* Unmute front mixer */
9184 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9185 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9186
9187 /* Set speaker pin to front mixer */
9188 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9189
9190 /* Init headphone pin */
9191 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9192 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9193 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9194 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9195
9196 { } /* end */
9197};
9198
9199/* toggle speaker-output according to the hp-jack state */
9200static void alc883_medion_wim2160_setup(struct hda_codec *codec)
9201{
9202 struct alc_spec *spec = codec->spec;
9203
9204 spec->autocfg.hp_pins[0] = 0x1a;
9205 spec->autocfg.speaker_pins[0] = 0x15;
Takashi Iwaid922b512011-04-28 12:18:53 +02009206 spec->automute = 1;
9207 spec->automute_mode = ALC_AUTOMUTE_AMP;
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009208}
9209
Tobin Davis2880a862007-08-07 11:50:26 +02009210static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02009211 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9212 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009213 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009214 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9215 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009216 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009217 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009218 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009219 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02009220};
Tobin Davis2880a862007-08-07 11:50:26 +02009221
Tony Vroond2fd4b02009-06-21 00:40:10 +01009222static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
9223 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009224 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01009225 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9226 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009227 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9228 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9229 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009230 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009231 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9232 { } /* end */
9233};
9234
Kailang Yange2757d52008-08-26 13:17:46 +02009235static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
9236 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9237 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9238 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9239 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
9240 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
9241 0x0d, 1, 0x0, HDA_OUTPUT),
9242 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
9243 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
9244 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
9245 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9246 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009247 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9248 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9249 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9250 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, 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 Yange2757d52008-08-26 13:17:46 +02009253 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9254 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009255 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009256 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009257 { } /* end */
9258};
9259
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009260static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
9261 /* Output mixers */
9262 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
9263 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
9264 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
9265 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
9266 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
9267 HDA_OUTPUT),
9268 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
9269 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
9270 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
9271 /* Output switches */
9272 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
9273 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
9274 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
9275 /* Boost mixers */
David Henningsson5f99f862011-01-04 15:24:24 +01009276 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
9277 HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009278 /* Input mixers */
9279 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
9280 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
9281 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9282 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9283 { } /* end */
9284};
9285
Guido Günther3e1647c52009-06-05 00:47:26 +02009286static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
9287 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9288 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9289 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9290 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009291 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
Guido Günther3e1647c52009-06-05 00:47:26 +02009292 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9293 { } /* end */
9294};
9295
Kailang Yange2757d52008-08-26 13:17:46 +02009296static struct hda_bind_ctls alc883_bind_cap_vol = {
9297 .ops = &snd_hda_bind_vol,
9298 .values = {
9299 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9300 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9301 0
9302 },
9303};
9304
9305static struct hda_bind_ctls alc883_bind_cap_switch = {
9306 .ops = &snd_hda_bind_sw,
9307 .values = {
9308 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9309 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9310 0
9311 },
9312};
9313
9314static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
9315 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9316 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9317 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9318 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9319 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9320 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009321 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009322 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009323 { } /* end */
9324};
9325
9326static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009327 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
9328 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
9329 {
9330 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9331 /* .name = "Capture Source", */
9332 .name = "Input Source",
9333 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009334 .info = alc_mux_enum_info,
9335 .get = alc_mux_enum_get,
9336 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02009337 },
9338 { } /* end */
9339};
9340
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009341static struct snd_kcontrol_new alc883_chmode_mixer[] = {
9342 {
9343 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9344 .name = "Channel Mode",
9345 .info = alc_ch_mode_info,
9346 .get = alc_ch_mode_get,
9347 .put = alc_ch_mode_put,
9348 },
9349 { } /* end */
9350};
9351
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009352/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009353static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009354{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009355 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009356
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009357 spec->autocfg.hp_pins[0] = 0x15;
9358 spec->autocfg.speaker_pins[0] = 0x14;
9359 spec->autocfg.speaker_pins[1] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02009360 spec->automute = 1;
9361 spec->automute_mode = ALC_AUTOMUTE_AMP;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009362}
9363
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009364static struct hda_verb alc883_mitac_verbs[] = {
9365 /* HP */
9366 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9367 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9368 /* Subwoofer */
9369 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9370 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9371
9372 /* enable unsolicited event */
9373 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9374 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
9375
9376 { } /* end */
9377};
9378
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309379static struct hda_verb alc883_clevo_m540r_verbs[] = {
9380 /* HP */
9381 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9382 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9383 /* Int speaker */
9384 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
9385
9386 /* enable unsolicited event */
9387 /*
9388 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9389 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9390 */
9391
9392 { } /* end */
9393};
9394
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009395static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009396 /* HP */
9397 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9398 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9399 /* Int speaker */
9400 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
9401 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9402
9403 /* enable unsolicited event */
9404 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009405 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01009406
9407 { } /* end */
9408};
9409
Jiang zhefb97dc62008-03-06 11:07:11 +01009410static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
9411 /* HP */
9412 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9413 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9414 /* Subwoofer */
9415 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9416 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9417
9418 /* enable unsolicited event */
9419 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9420
9421 { } /* end */
9422};
9423
Sasha Alexandrc2592492009-06-16 14:52:54 -04009424static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009425 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9426 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9427
9428 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9429 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02009430
David Heidelberger64a8be72009-06-08 16:15:18 +02009431/* Connect Line-Out side jack (SPDIF) to Side */
9432 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9433 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9434 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9435/* Connect Mic jack to CLFE */
9436 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9437 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9438 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
9439/* Connect Line-in jack to Surround */
9440 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9441 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9442 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
9443/* Connect HP out jack to Front */
9444 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9445 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9446 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02009447
9448 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02009449
9450 { } /* end */
9451};
9452
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009453static struct hda_verb alc883_lenovo_101e_verbs[] = {
9454 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9455 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
9456 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
9457 { } /* end */
9458};
9459
Kailang Yang272a5272007-05-14 11:00:38 +02009460static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
9461 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9462 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9463 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9464 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9465 { } /* end */
9466};
9467
9468static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
9469 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9470 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9471 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9472 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
9473 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9474 { } /* end */
9475};
9476
Kailang Yang189609a2007-08-20 11:31:23 +02009477static struct hda_verb alc883_haier_w66_verbs[] = {
9478 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9479 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9480
9481 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9482
9483 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9484 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9485 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9486 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9487 { } /* end */
9488};
9489
Kailang Yange2757d52008-08-26 13:17:46 +02009490static struct hda_verb alc888_lenovo_sky_verbs[] = {
9491 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9492 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9493 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9494 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9495 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9496 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9497 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9498 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9499 { } /* end */
9500};
9501
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009502static struct hda_verb alc888_6st_dell_verbs[] = {
9503 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9504 { }
9505};
9506
Guido Günther3e1647c52009-06-05 00:47:26 +02009507static struct hda_verb alc883_vaiott_verbs[] = {
9508 /* HP */
9509 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9510 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9511
9512 /* enable unsolicited event */
9513 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9514
9515 { } /* end */
9516};
9517
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009518static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009519{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009520 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009521
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009522 spec->autocfg.hp_pins[0] = 0x1b;
9523 spec->autocfg.speaker_pins[0] = 0x14;
9524 spec->autocfg.speaker_pins[1] = 0x16;
9525 spec->autocfg.speaker_pins[2] = 0x18;
Takashi Iwaid922b512011-04-28 12:18:53 +02009526 spec->automute = 1;
9527 spec->automute_mode = ALC_AUTOMUTE_AMP;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009528}
9529
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009530static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009531 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01009532 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
9533 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009534 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009535 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009536};
9537
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009538/*
9539 * 2ch mode
9540 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009541static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009542 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9543 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9544 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9545 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009546 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009547};
9548
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009549/*
9550 * 4ch mode
9551 */
9552static struct hda_verb alc888_3st_hp_4ch_init[] = {
9553 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9554 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9555 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9556 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9557 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9558 { } /* end */
9559};
9560
9561/*
9562 * 6ch mode
9563 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009564static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009565 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9566 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009567 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009568 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9569 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009570 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9571 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009572};
9573
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009574static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009575 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009576 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009577 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009578};
9579
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02009580static void alc888_lenovo_ms7195_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009581{
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02009582 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009583
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02009584 spec->autocfg.hp_pins[0] = 0x1b;
9585 spec->autocfg.line_out_pins[0] = 0x14;
9586 spec->autocfg.speaker_pins[0] = 0x15;
9587 spec->automute = 1;
9588 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yang272a5272007-05-14 11:00:38 +02009589}
9590
Kailang Yang272a5272007-05-14 11:00:38 +02009591/* toggle speaker-output according to the hp-jack state */
Takashi Iwaidc4271702010-11-29 07:42:59 +01009592static void alc883_lenovo_nb0763_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009593{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009594 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009595
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009596 spec->autocfg.hp_pins[0] = 0x14;
9597 spec->autocfg.speaker_pins[0] = 0x15;
Takashi Iwaid922b512011-04-28 12:18:53 +02009598 spec->automute = 1;
9599 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yang272a5272007-05-14 11:00:38 +02009600}
9601
Kailang Yangccc656c2006-10-17 12:32:26 +02009602/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009603#define alc883_targa_init_hook alc882_targa_init_hook
9604#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009605
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009606static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009607{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009608 struct alc_spec *spec = codec->spec;
9609
9610 spec->autocfg.hp_pins[0] = 0x15;
9611 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +02009612 spec->automute = 1;
9613 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009614}
9615
9616static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9617{
Takashi Iwaid922b512011-04-28 12:18:53 +02009618 alc_hp_automute(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +01009619 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009620}
9621
9622static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009623 unsigned int res)
9624{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009625 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009626 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +01009627 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009628 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009629 default:
Takashi Iwaid922b512011-04-28 12:18:53 +02009630 alc_sku_unsol_event(codec, res);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009631 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009632 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009633}
9634
Jiang zhefb97dc62008-03-06 11:07:11 +01009635/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009636static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009637{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009638 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009639
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009640 spec->autocfg.hp_pins[0] = 0x14;
9641 spec->autocfg.speaker_pins[0] = 0x15;
Takashi Iwaid922b512011-04-28 12:18:53 +02009642 spec->automute = 1;
9643 spec->automute_mode = ALC_AUTOMUTE_AMP;
Jiang zhefb97dc62008-03-06 11:07:11 +01009644}
9645
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009646static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009647{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009648 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009649
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009650 spec->autocfg.hp_pins[0] = 0x1b;
9651 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +02009652 spec->automute = 1;
9653 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yang189609a2007-08-20 11:31:23 +02009654}
9655
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02009656static void alc883_lenovo_101e_setup(struct hda_codec *codec)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009657{
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02009658 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009659
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02009660 spec->autocfg.hp_pins[0] = 0x1b;
9661 spec->autocfg.line_out_pins[0] = 0x14;
9662 spec->autocfg.speaker_pins[0] = 0x15;
9663 spec->automute = 1;
9664 spec->detect_line = 1;
9665 spec->automute_lines = 1;
9666 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009667}
9668
Takashi Iwai676a9b52007-08-16 15:23:35 +02009669/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009670static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009671{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009672 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009673
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009674 spec->autocfg.hp_pins[0] = 0x14;
9675 spec->autocfg.speaker_pins[0] = 0x15;
9676 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwaid922b512011-04-28 12:18:53 +02009677 spec->automute = 1;
9678 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009679}
9680
Kailang Yangd1a991a2007-08-15 16:21:59 +02009681static struct hda_verb alc883_acer_eapd_verbs[] = {
9682 /* HP Pin: output 0 (0x0c) */
9683 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9684 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9685 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9686 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009687 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9688 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009689 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009690 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9691 /* eanable EAPD on medion laptop */
9692 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9693 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009694 /* enable unsolicited event */
9695 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009696 { }
9697};
9698
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009699static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009700{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009701 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009702
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009703 spec->autocfg.hp_pins[0] = 0x1b;
9704 spec->autocfg.speaker_pins[0] = 0x14;
9705 spec->autocfg.speaker_pins[1] = 0x15;
9706 spec->autocfg.speaker_pins[2] = 0x16;
9707 spec->autocfg.speaker_pins[3] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02009708 spec->automute = 1;
9709 spec->automute_mode = ALC_AUTOMUTE_AMP;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009710}
9711
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009712static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009713{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009714 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009715
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009716 spec->autocfg.hp_pins[0] = 0x1b;
9717 spec->autocfg.speaker_pins[0] = 0x14;
9718 spec->autocfg.speaker_pins[1] = 0x15;
9719 spec->autocfg.speaker_pins[2] = 0x16;
9720 spec->autocfg.speaker_pins[3] = 0x17;
9721 spec->autocfg.speaker_pins[4] = 0x1a;
Takashi Iwaid922b512011-04-28 12:18:53 +02009722 spec->automute = 1;
9723 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yange2757d52008-08-26 13:17:46 +02009724}
9725
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009726static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c52009-06-05 00:47:26 +02009727{
9728 struct alc_spec *spec = codec->spec;
9729
9730 spec->autocfg.hp_pins[0] = 0x15;
9731 spec->autocfg.speaker_pins[0] = 0x14;
9732 spec->autocfg.speaker_pins[1] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02009733 spec->automute = 1;
9734 spec->automute_mode = ALC_AUTOMUTE_AMP;
Guido Günther3e1647c52009-06-05 00:47:26 +02009735}
9736
Kailang Yange2757d52008-08-26 13:17:46 +02009737static struct hda_verb alc888_asus_m90v_verbs[] = {
9738 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9739 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9740 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9741 /* enable unsolicited event */
9742 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9743 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9744 { } /* end */
9745};
9746
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009747static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009748{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009749 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009750
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009751 spec->autocfg.hp_pins[0] = 0x1b;
9752 spec->autocfg.speaker_pins[0] = 0x14;
9753 spec->autocfg.speaker_pins[1] = 0x15;
9754 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009755 spec->ext_mic.pin = 0x18;
9756 spec->int_mic.pin = 0x19;
9757 spec->ext_mic.mux_idx = 0;
9758 spec->int_mic.mux_idx = 1;
9759 spec->auto_mic = 1;
Takashi Iwaid922b512011-04-28 12:18:53 +02009760 spec->automute = 1;
9761 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yange2757d52008-08-26 13:17:46 +02009762}
9763
9764static struct hda_verb alc888_asus_eee1601_verbs[] = {
9765 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9766 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9767 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9768 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9769 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9770 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9771 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9772 /* enable unsolicited event */
9773 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9774 { } /* end */
9775};
9776
Kailang Yange2757d52008-08-26 13:17:46 +02009777static void alc883_eee1601_inithook(struct hda_codec *codec)
9778{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009779 struct alc_spec *spec = codec->spec;
9780
9781 spec->autocfg.hp_pins[0] = 0x14;
9782 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaid922b512011-04-28 12:18:53 +02009783 alc_hp_automute(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009784}
9785
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009786static struct hda_verb alc889A_mb31_verbs[] = {
9787 /* Init rear pin (used as headphone output) */
9788 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9789 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9790 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9791 /* Init line pin (used as output in 4ch and 6ch mode) */
9792 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9793 /* Init line 2 pin (used as headphone out by default) */
9794 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9795 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9796 { } /* end */
9797};
9798
9799/* Mute speakers according to the headphone jack state */
9800static void alc889A_mb31_automute(struct hda_codec *codec)
9801{
9802 unsigned int present;
9803
9804 /* Mute only in 2ch or 4ch mode */
9805 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9806 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009807 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009808 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9809 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9810 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9811 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9812 }
9813}
9814
9815static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9816{
9817 if ((res >> 26) == ALC880_HP_EVENT)
9818 alc889A_mb31_automute(codec);
9819}
9820
Takashi Iwai4953550a2009-06-30 15:28:30 +02009821
Takashi Iwaicb53c622007-08-10 17:21:45 +02009822#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009823#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009824#endif
9825
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009826/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009827#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9828#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9829#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9830#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9831
9832static hda_nid_t alc883_slave_dig_outs[] = {
9833 ALC1200_DIGOUT_NID, 0,
9834};
9835
9836static hda_nid_t alc1200_slave_dig_outs[] = {
9837 ALC883_DIGOUT_NID, 0,
9838};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009839
9840/*
9841 * configuration and preset
9842 */
Takashi Iwaiea734962011-01-17 11:29:34 +01009843static const char * const alc882_models[ALC882_MODEL_LAST] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02009844 [ALC882_3ST_DIG] = "3stack-dig",
9845 [ALC882_6ST_DIG] = "6stack-dig",
9846 [ALC882_ARIMA] = "arima",
9847 [ALC882_W2JC] = "w2jc",
9848 [ALC882_TARGA] = "targa",
9849 [ALC882_ASUS_A7J] = "asus-a7j",
9850 [ALC882_ASUS_A7M] = "asus-a7m",
9851 [ALC885_MACPRO] = "macpro",
9852 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009853 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009854 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009855 [ALC885_MBP3] = "mbp3",
9856 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009857 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009858 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009859 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9860 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009861 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009862 [ALC883_TARGA_DIG] = "targa-dig",
9863 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009864 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009865 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009866 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009867 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009868 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009869 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009870 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009871 [ALC883_MEDION] = "medion",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009872 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009873 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009874 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009875 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9876 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009877 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009878 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009879 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009880 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009881 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309882 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009883 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009884 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009885 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009886 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009887 [ALC889A_INTEL] = "intel-alc889a",
9888 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009889 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009890 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c52009-06-05 00:47:26 +02009891 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009892 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009893};
9894
Takashi Iwai4953550a2009-06-30 15:28:30 +02009895static struct snd_pci_quirk alc882_cfg_tbl[] = {
9896 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9897
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009898 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009899 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009900 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009901 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9902 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009903 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009904 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9905 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009906 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009907 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009908 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9909 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009910 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9911 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009912 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9913 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009914 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009915 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009916 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009917 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009918 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9919 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009920 /* default Acer -- disabled as it causes more problems.
9921 * model=auto should work fine now
9922 */
9923 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009924
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009925 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009926
Tobin Davisfebe3372007-06-12 11:27:46 +02009927 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009928 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9929 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009930 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009931 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009932 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009933
9934 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9935 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9936 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009937 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009938 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9939 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9940 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009941 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009942 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009943 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009944 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009945
9946 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009947 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009948 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009949 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009950 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9951 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009952 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009953 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009954
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009955 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9956 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9957 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009958 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009959 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009960 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009961 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009962 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009963 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9964 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9965 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9966 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9967 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9968 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009969 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009970 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9971 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9972 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009973 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009974 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009975 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9976 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009977 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009978 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009979 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009980 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009981 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009982 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009983 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009984 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009985 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009986
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009987 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +02009988 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009989 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9990 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309991 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009992 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009993 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009994 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009995 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009996 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009997 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009998 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009999 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +020010000 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +020010001 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010002 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
10003 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +020010004 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Takashi Iwai959973b2008-11-05 11:30:56 +010010005 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +010010006 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +020010007 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010008
Jiang zhe17bba1b2008-06-04 12:11:07 +020010009 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
10010 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +110010011 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010012 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
10013 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
10014 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -040010015 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010016
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010017 {}
10018};
10019
Takashi Iwai4953550a2009-06-30 15:28:30 +020010020/* codec SSID table for Intel Mac */
10021static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
10022 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
10023 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
10024 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
10025 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
10026 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
10027 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
10028 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -040010029 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -070010030 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -070010031 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -070010032 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010033 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
10034 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
10035 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010036 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010037 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Luke Yelavich3bfea982010-06-22 11:04:19 +100010038 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -050010039 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
10040 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +020010041 */
10042 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -050010043 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010044 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010045 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010046};
10047
Takashi Iwai4953550a2009-06-30 15:28:30 +020010048static struct alc_config_preset alc882_presets[] = {
10049 [ALC882_3ST_DIG] = {
10050 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010051 .init_verbs = { alc882_base_init_verbs,
10052 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010053 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10054 .dac_nids = alc882_dac_nids,
10055 .dig_out_nid = ALC882_DIGOUT_NID,
10056 .dig_in_nid = ALC882_DIGIN_NID,
10057 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10058 .channel_mode = alc882_ch_modes,
10059 .need_dac_fix = 1,
10060 .input_mux = &alc882_capture_source,
10061 },
10062 [ALC882_6ST_DIG] = {
10063 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010064 .init_verbs = { alc882_base_init_verbs,
10065 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010066 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10067 .dac_nids = alc882_dac_nids,
10068 .dig_out_nid = ALC882_DIGOUT_NID,
10069 .dig_in_nid = ALC882_DIGIN_NID,
10070 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
10071 .channel_mode = alc882_sixstack_modes,
10072 .input_mux = &alc882_capture_source,
10073 },
10074 [ALC882_ARIMA] = {
10075 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010076 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10077 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010078 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10079 .dac_nids = alc882_dac_nids,
10080 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
10081 .channel_mode = alc882_sixstack_modes,
10082 .input_mux = &alc882_capture_source,
10083 },
10084 [ALC882_W2JC] = {
10085 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010086 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10087 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010088 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10089 .dac_nids = alc882_dac_nids,
10090 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10091 .channel_mode = alc880_threestack_modes,
10092 .need_dac_fix = 1,
10093 .input_mux = &alc882_capture_source,
10094 .dig_out_nid = ALC882_DIGOUT_NID,
10095 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -080010096 [ALC885_MBA21] = {
10097 .mixers = { alc885_mba21_mixer },
10098 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
10099 .num_dacs = 2,
10100 .dac_nids = alc882_dac_nids,
10101 .channel_mode = alc885_mba21_ch_modes,
10102 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10103 .input_mux = &alc882_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010104 .unsol_event = alc_sku_unsol_event,
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -080010105 .setup = alc885_mba21_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010106 .init_hook = alc_hp_automute,
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -080010107 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010108 [ALC885_MBP3] = {
10109 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
10110 .init_verbs = { alc885_mbp3_init_verbs,
10111 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +020010112 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010113 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +020010114 .hp_nid = 0x04,
10115 .channel_mode = alc885_mbp_4ch_modes,
10116 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010117 .input_mux = &alc882_capture_source,
10118 .dig_out_nid = ALC882_DIGOUT_NID,
10119 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaid922b512011-04-28 12:18:53 +020010120 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010121 .setup = alc885_mbp3_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010122 .init_hook = alc_hp_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010123 },
10124 [ALC885_MB5] = {
10125 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
10126 .init_verbs = { alc885_mb5_init_verbs,
10127 alc880_gpio1_init_verbs },
10128 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10129 .dac_nids = alc882_dac_nids,
10130 .channel_mode = alc885_mb5_6ch_modes,
10131 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
10132 .input_mux = &mb5_capture_source,
10133 .dig_out_nid = ALC882_DIGOUT_NID,
10134 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaid922b512011-04-28 12:18:53 +020010135 .unsol_event = alc_sku_unsol_event,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010136 .setup = alc885_mb5_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010137 .init_hook = alc_hp_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010138 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010139 [ALC885_MACMINI3] = {
10140 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
10141 .init_verbs = { alc885_macmini3_init_verbs,
10142 alc880_gpio1_init_verbs },
10143 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10144 .dac_nids = alc882_dac_nids,
10145 .channel_mode = alc885_macmini3_6ch_modes,
10146 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
10147 .input_mux = &macmini3_capture_source,
10148 .dig_out_nid = ALC882_DIGOUT_NID,
10149 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaid922b512011-04-28 12:18:53 +020010150 .unsol_event = alc_sku_unsol_event,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010151 .setup = alc885_macmini3_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010152 .init_hook = alc_hp_automute,
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010153 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010154 [ALC885_MACPRO] = {
10155 .mixers = { alc882_macpro_mixer },
10156 .init_verbs = { alc882_macpro_init_verbs },
10157 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10158 .dac_nids = alc882_dac_nids,
10159 .dig_out_nid = ALC882_DIGOUT_NID,
10160 .dig_in_nid = ALC882_DIGIN_NID,
10161 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10162 .channel_mode = alc882_ch_modes,
10163 .input_mux = &alc882_capture_source,
10164 .init_hook = alc885_macpro_init_hook,
10165 },
10166 [ALC885_IMAC24] = {
10167 .mixers = { alc885_imac24_mixer },
10168 .init_verbs = { alc885_imac24_init_verbs },
10169 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10170 .dac_nids = alc882_dac_nids,
10171 .dig_out_nid = ALC882_DIGOUT_NID,
10172 .dig_in_nid = ALC882_DIGIN_NID,
10173 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10174 .channel_mode = alc882_ch_modes,
10175 .input_mux = &alc882_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010176 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010177 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010178 .init_hook = alc885_imac24_init_hook,
10179 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010180 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010181 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010182 .init_verbs = { alc885_imac91_init_verbs,
10183 alc880_gpio1_init_verbs },
10184 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10185 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010186 .channel_mode = alc885_mba21_ch_modes,
10187 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10188 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010189 .dig_out_nid = ALC882_DIGOUT_NID,
10190 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaid922b512011-04-28 12:18:53 +020010191 .unsol_event = alc_sku_unsol_event,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010192 .setup = alc885_imac91_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010193 .init_hook = alc_hp_automute,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010194 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010195 [ALC882_TARGA] = {
10196 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010197 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +020010198 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010199 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10200 .dac_nids = alc882_dac_nids,
10201 .dig_out_nid = ALC882_DIGOUT_NID,
10202 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10203 .adc_nids = alc882_adc_nids,
10204 .capsrc_nids = alc882_capsrc_nids,
10205 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10206 .channel_mode = alc882_3ST_6ch_modes,
10207 .need_dac_fix = 1,
10208 .input_mux = &alc882_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010209 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010210 .setup = alc882_targa_setup,
10211 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010212 },
10213 [ALC882_ASUS_A7J] = {
10214 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010215 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10216 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010217 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10218 .dac_nids = alc882_dac_nids,
10219 .dig_out_nid = ALC882_DIGOUT_NID,
10220 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10221 .adc_nids = alc882_adc_nids,
10222 .capsrc_nids = alc882_capsrc_nids,
10223 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10224 .channel_mode = alc882_3ST_6ch_modes,
10225 .need_dac_fix = 1,
10226 .input_mux = &alc882_capture_source,
10227 },
10228 [ALC882_ASUS_A7M] = {
10229 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010230 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10231 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010232 alc882_asus_a7m_verbs },
10233 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10234 .dac_nids = alc882_dac_nids,
10235 .dig_out_nid = ALC882_DIGOUT_NID,
10236 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10237 .channel_mode = alc880_threestack_modes,
10238 .need_dac_fix = 1,
10239 .input_mux = &alc882_capture_source,
10240 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010241 [ALC883_3ST_2ch_DIG] = {
10242 .mixers = { alc883_3ST_2ch_mixer },
10243 .init_verbs = { alc883_init_verbs },
10244 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10245 .dac_nids = alc883_dac_nids,
10246 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010247 .dig_in_nid = ALC883_DIGIN_NID,
10248 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10249 .channel_mode = alc883_3ST_2ch_modes,
10250 .input_mux = &alc883_capture_source,
10251 },
10252 [ALC883_3ST_6ch_DIG] = {
10253 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10254 .init_verbs = { alc883_init_verbs },
10255 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10256 .dac_nids = alc883_dac_nids,
10257 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010258 .dig_in_nid = ALC883_DIGIN_NID,
10259 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10260 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010261 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010262 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010263 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010264 [ALC883_3ST_6ch] = {
10265 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10266 .init_verbs = { alc883_init_verbs },
10267 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10268 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010269 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10270 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010271 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010272 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010273 },
Jiang zhe17bba1b2008-06-04 12:11:07 +020010274 [ALC883_3ST_6ch_INTEL] = {
10275 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
10276 .init_verbs = { alc883_init_verbs },
10277 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10278 .dac_nids = alc883_dac_nids,
10279 .dig_out_nid = ALC883_DIGOUT_NID,
10280 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010281 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +020010282 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
10283 .channel_mode = alc883_3ST_6ch_intel_modes,
10284 .need_dac_fix = 1,
10285 .input_mux = &alc883_3stack_6ch_intel,
10286 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010287 [ALC889A_INTEL] = {
10288 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020010289 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
10290 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010291 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10292 .dac_nids = alc883_dac_nids,
10293 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10294 .adc_nids = alc889_adc_nids,
10295 .dig_out_nid = ALC883_DIGOUT_NID,
10296 .dig_in_nid = ALC883_DIGIN_NID,
10297 .slave_dig_outs = alc883_slave_dig_outs,
10298 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10299 .channel_mode = alc889_8ch_intel_modes,
10300 .capsrc_nids = alc889_capsrc_nids,
10301 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010302 .setup = alc889_automute_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010303 .init_hook = alc_hp_automute,
10304 .unsol_event = alc_sku_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010305 .need_dac_fix = 1,
10306 },
10307 [ALC889_INTEL] = {
10308 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
10309 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010310 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010311 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10312 .dac_nids = alc883_dac_nids,
10313 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10314 .adc_nids = alc889_adc_nids,
10315 .dig_out_nid = ALC883_DIGOUT_NID,
10316 .dig_in_nid = ALC883_DIGIN_NID,
10317 .slave_dig_outs = alc883_slave_dig_outs,
10318 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10319 .channel_mode = alc889_8ch_intel_modes,
10320 .capsrc_nids = alc889_capsrc_nids,
10321 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010322 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010323 .init_hook = alc889_intel_init_hook,
Takashi Iwaid922b512011-04-28 12:18:53 +020010324 .unsol_event = alc_sku_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010325 .need_dac_fix = 1,
10326 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010327 [ALC883_6ST_DIG] = {
10328 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10329 .init_verbs = { alc883_init_verbs },
10330 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10331 .dac_nids = alc883_dac_nids,
10332 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010333 .dig_in_nid = ALC883_DIGIN_NID,
10334 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10335 .channel_mode = alc883_sixstack_modes,
10336 .input_mux = &alc883_capture_source,
10337 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010338 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010339 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +020010340 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10341 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010342 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10343 .dac_nids = alc883_dac_nids,
10344 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010345 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10346 .channel_mode = alc883_3ST_6ch_modes,
10347 .need_dac_fix = 1,
10348 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010349 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010350 .setup = alc882_targa_setup,
10351 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010352 },
10353 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010354 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +020010355 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10356 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010357 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10358 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010359 .adc_nids = alc883_adc_nids_alt,
10360 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010361 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +020010362 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010363 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10364 .channel_mode = alc883_3ST_2ch_modes,
10365 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010366 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010367 .setup = alc882_targa_setup,
10368 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010369 },
David Heidelberger64a8be72009-06-08 16:15:18 +020010370 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +020010371 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
10372 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +020010373 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010374 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +020010375 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10376 .dac_nids = alc883_dac_nids,
10377 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10378 .adc_nids = alc883_adc_nids_rev,
10379 .capsrc_nids = alc883_capsrc_nids_rev,
10380 .dig_out_nid = ALC883_DIGOUT_NID,
10381 .dig_in_nid = ALC883_DIGIN_NID,
10382 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
10383 .channel_mode = alc883_4ST_8ch_modes,
10384 .need_dac_fix = 1,
10385 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010386 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010387 .setup = alc882_targa_setup,
10388 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +020010389 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010390 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010391 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010392 /* On TravelMate laptops, GPIO 0 enables the internal speaker
10393 * and the headphone jack. Turn this on and rely on the
10394 * standard mute methods whenever the user wants to turn
10395 * these outputs off.
10396 */
10397 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
10398 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10399 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010400 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10401 .channel_mode = alc883_3ST_2ch_modes,
10402 .input_mux = &alc883_capture_source,
10403 },
Tobin Davis2880a862007-08-07 11:50:26 +020010404 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010405 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010406 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +020010407 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10408 .dac_nids = alc883_dac_nids,
10409 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +020010410 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10411 .channel_mode = alc883_3ST_2ch_modes,
10412 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010413 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010414 .setup = alc883_acer_aspire_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010415 .init_hook = alc_hp_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010416 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010417 [ALC888_ACER_ASPIRE_4930G] = {
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +010010418 .mixers = { alc888_acer_aspire_4930g_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010419 alc883_chmode_mixer },
10420 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10421 alc888_acer_aspire_4930g_verbs },
10422 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10423 .dac_nids = alc883_dac_nids,
10424 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10425 .adc_nids = alc883_adc_nids_rev,
10426 .capsrc_nids = alc883_capsrc_nids_rev,
10427 .dig_out_nid = ALC883_DIGOUT_NID,
10428 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10429 .channel_mode = alc883_3ST_6ch_modes,
10430 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +010010431 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010432 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010433 ARRAY_SIZE(alc888_2_capture_sources),
10434 .input_mux = alc888_2_capture_sources,
Takashi Iwaid922b512011-04-28 12:18:53 +020010435 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010436 .setup = alc888_acer_aspire_4930g_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010437 .init_hook = alc_hp_automute,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010438 },
Tony Vroond2fd4b02009-06-21 00:40:10 +010010439 [ALC888_ACER_ASPIRE_6530G] = {
10440 .mixers = { alc888_acer_aspire_6530_mixer },
10441 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10442 alc888_acer_aspire_6530g_verbs },
10443 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10444 .dac_nids = alc883_dac_nids,
10445 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10446 .adc_nids = alc883_adc_nids_rev,
10447 .capsrc_nids = alc883_capsrc_nids_rev,
10448 .dig_out_nid = ALC883_DIGOUT_NID,
10449 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10450 .channel_mode = alc883_3ST_2ch_modes,
10451 .num_mux_defs =
10452 ARRAY_SIZE(alc888_2_capture_sources),
10453 .input_mux = alc888_acer_aspire_6530_sources,
Takashi Iwaid922b512011-04-28 12:18:53 +020010454 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010455 .setup = alc888_acer_aspire_6530g_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010456 .init_hook = alc_hp_automute,
Tony Vroond2fd4b02009-06-21 00:40:10 +010010457 },
Hector Martin3b315d72009-06-02 10:54:19 +020010458 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +010010459 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +020010460 alc883_chmode_mixer },
10461 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +010010462 alc889_acer_aspire_8930g_verbs,
10463 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +020010464 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10465 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +020010466 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10467 .adc_nids = alc889_adc_nids,
10468 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +020010469 .dig_out_nid = ALC883_DIGOUT_NID,
10470 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10471 .channel_mode = alc883_3ST_6ch_modes,
10472 .need_dac_fix = 1,
10473 .const_channel_count = 6,
10474 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +020010475 ARRAY_SIZE(alc889_capture_sources),
10476 .input_mux = alc889_capture_sources,
Takashi Iwaid922b512011-04-28 12:18:53 +020010477 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010478 .setup = alc889_acer_aspire_8930g_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010479 .init_hook = alc_hp_automute,
Hector Martinf5de24b2009-12-20 22:51:31 +010010480#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050010481 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +010010482#endif
Hector Martin3b315d72009-06-02 10:54:19 +020010483 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010484 [ALC888_ACER_ASPIRE_7730G] = {
10485 .mixers = { alc883_3ST_6ch_mixer,
10486 alc883_chmode_mixer },
10487 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10488 alc888_acer_aspire_7730G_verbs },
10489 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10490 .dac_nids = alc883_dac_nids,
10491 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10492 .adc_nids = alc883_adc_nids_rev,
10493 .capsrc_nids = alc883_capsrc_nids_rev,
10494 .dig_out_nid = ALC883_DIGOUT_NID,
10495 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10496 .channel_mode = alc883_3ST_6ch_modes,
10497 .need_dac_fix = 1,
10498 .const_channel_count = 6,
10499 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010500 .unsol_event = alc_sku_unsol_event,
Denis Kuplyakovd9477202010-11-24 06:01:09 +010010501 .setup = alc888_acer_aspire_7730g_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010502 .init_hook = alc_hp_automute,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010503 },
Tobin Davisc07584c2006-10-13 12:32:16 +020010504 [ALC883_MEDION] = {
10505 .mixers = { alc883_fivestack_mixer,
10506 alc883_chmode_mixer },
10507 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010508 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +020010509 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10510 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010511 .adc_nids = alc883_adc_nids_alt,
10512 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010513 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +020010514 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10515 .channel_mode = alc883_sixstack_modes,
10516 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010517 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010518 [ALC883_MEDION_WIM2160] = {
10519 .mixers = { alc883_medion_wim2160_mixer },
10520 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
10521 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10522 .dac_nids = alc883_dac_nids,
10523 .dig_out_nid = ALC883_DIGOUT_NID,
10524 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
10525 .adc_nids = alc883_adc_nids,
10526 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10527 .channel_mode = alc883_3ST_2ch_modes,
10528 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010529 .unsol_event = alc_sku_unsol_event,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010530 .setup = alc883_medion_wim2160_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010531 .init_hook = alc_hp_automute,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010532 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010533 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010534 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010535 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10536 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10537 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010538 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10539 .channel_mode = alc883_3ST_2ch_modes,
10540 .input_mux = &alc883_capture_source,
10541 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010542 [ALC883_CLEVO_M540R] = {
10543 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10544 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10545 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10546 .dac_nids = alc883_dac_nids,
10547 .dig_out_nid = ALC883_DIGOUT_NID,
10548 .dig_in_nid = ALC883_DIGIN_NID,
10549 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10550 .channel_mode = alc883_3ST_6ch_clevo_modes,
10551 .need_dac_fix = 1,
10552 .input_mux = &alc883_capture_source,
10553 /* This machine has the hardware HP auto-muting, thus
10554 * we need no software mute via unsol event
10555 */
10556 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010557 [ALC883_CLEVO_M720] = {
10558 .mixers = { alc883_clevo_m720_mixer },
10559 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010560 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10561 .dac_nids = alc883_dac_nids,
10562 .dig_out_nid = ALC883_DIGOUT_NID,
10563 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10564 .channel_mode = alc883_3ST_2ch_modes,
10565 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010566 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010567 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010568 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010569 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010570 [ALC883_LENOVO_101E_2ch] = {
10571 .mixers = { alc883_lenovo_101e_2ch_mixer},
10572 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10573 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10574 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010575 .adc_nids = alc883_adc_nids_alt,
10576 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010577 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010578 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10579 .channel_mode = alc883_3ST_2ch_modes,
10580 .input_mux = &alc883_lenovo_101e_capture_source,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020010581 .setup = alc883_lenovo_101e_setup,
10582 .unsol_event = alc_sku_unsol_event,
10583 .init_hook = alc_inithook,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010584 },
Kailang Yang272a5272007-05-14 11:00:38 +020010585 [ALC883_LENOVO_NB0763] = {
10586 .mixers = { alc883_lenovo_nb0763_mixer },
10587 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10588 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10589 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010590 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10591 .channel_mode = alc883_3ST_2ch_modes,
10592 .need_dac_fix = 1,
10593 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010594 .unsol_event = alc_sku_unsol_event,
Takashi Iwaidc4271702010-11-29 07:42:59 +010010595 .setup = alc883_lenovo_nb0763_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010596 .init_hook = alc_hp_automute,
Kailang Yang272a5272007-05-14 11:00:38 +020010597 },
10598 [ALC888_LENOVO_MS7195_DIG] = {
10599 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10600 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10601 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10602 .dac_nids = alc883_dac_nids,
10603 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010604 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10605 .channel_mode = alc883_3ST_6ch_modes,
10606 .need_dac_fix = 1,
10607 .input_mux = &alc883_capture_source,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020010608 .unsol_event = alc_sku_unsol_event,
10609 .setup = alc888_lenovo_ms7195_setup,
10610 .init_hook = alc_inithook,
Kailang Yang189609a2007-08-20 11:31:23 +020010611 },
10612 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010613 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010614 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10615 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10616 .dac_nids = alc883_dac_nids,
10617 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010618 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10619 .channel_mode = alc883_3ST_2ch_modes,
10620 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010621 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010622 .setup = alc883_haier_w66_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010623 .init_hook = alc_hp_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010624 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010625 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010626 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010627 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010628 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10629 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010630 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10631 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010632 .need_dac_fix = 1,
10633 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010634 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010635 .setup = alc888_3st_hp_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010636 .init_hook = alc_hp_automute,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010637 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010638 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010639 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010640 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10641 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10642 .dac_nids = alc883_dac_nids,
10643 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010644 .dig_in_nid = ALC883_DIGIN_NID,
10645 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10646 .channel_mode = alc883_sixstack_modes,
10647 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010648 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010649 .setup = alc888_6st_dell_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010650 .init_hook = alc_hp_automute,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010651 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010652 [ALC883_MITAC] = {
10653 .mixers = { alc883_mitac_mixer },
10654 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10655 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10656 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010657 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10658 .channel_mode = alc883_3ST_2ch_modes,
10659 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010660 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010661 .setup = alc883_mitac_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010662 .init_hook = alc_hp_automute,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010663 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010664 [ALC883_FUJITSU_PI2515] = {
10665 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10666 .init_verbs = { alc883_init_verbs,
10667 alc883_2ch_fujitsu_pi2515_verbs},
10668 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10669 .dac_nids = alc883_dac_nids,
10670 .dig_out_nid = ALC883_DIGOUT_NID,
10671 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10672 .channel_mode = alc883_3ST_2ch_modes,
10673 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010674 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010675 .setup = alc883_2ch_fujitsu_pi2515_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010676 .init_hook = alc_hp_automute,
Jiang zhefb97dc62008-03-06 11:07:11 +010010677 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010678 [ALC888_FUJITSU_XA3530] = {
10679 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10680 .init_verbs = { alc883_init_verbs,
10681 alc888_fujitsu_xa3530_verbs },
10682 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10683 .dac_nids = alc883_dac_nids,
10684 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10685 .adc_nids = alc883_adc_nids_rev,
10686 .capsrc_nids = alc883_capsrc_nids_rev,
10687 .dig_out_nid = ALC883_DIGOUT_NID,
10688 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10689 .channel_mode = alc888_4ST_8ch_intel_modes,
10690 .num_mux_defs =
10691 ARRAY_SIZE(alc888_2_capture_sources),
10692 .input_mux = alc888_2_capture_sources,
Takashi Iwaid922b512011-04-28 12:18:53 +020010693 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010694 .setup = alc888_fujitsu_xa3530_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010695 .init_hook = alc_hp_automute,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010696 },
Kailang Yange2757d52008-08-26 13:17:46 +020010697 [ALC888_LENOVO_SKY] = {
10698 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10699 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10700 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10701 .dac_nids = alc883_dac_nids,
10702 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010703 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10704 .channel_mode = alc883_sixstack_modes,
10705 .need_dac_fix = 1,
10706 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010707 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010708 .setup = alc888_lenovo_sky_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010709 .init_hook = alc_hp_automute,
Kailang Yange2757d52008-08-26 13:17:46 +020010710 },
10711 [ALC888_ASUS_M90V] = {
10712 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10713 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10714 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10715 .dac_nids = alc883_dac_nids,
10716 .dig_out_nid = ALC883_DIGOUT_NID,
10717 .dig_in_nid = ALC883_DIGIN_NID,
10718 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10719 .channel_mode = alc883_3ST_6ch_modes,
10720 .need_dac_fix = 1,
10721 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010722 .unsol_event = alc_sku_unsol_event,
10723 .setup = alc883_mode2_setup,
10724 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010725 },
10726 [ALC888_ASUS_EEE1601] = {
10727 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010728 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010729 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10730 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10731 .dac_nids = alc883_dac_nids,
10732 .dig_out_nid = ALC883_DIGOUT_NID,
10733 .dig_in_nid = ALC883_DIGIN_NID,
10734 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10735 .channel_mode = alc883_3ST_2ch_modes,
10736 .need_dac_fix = 1,
10737 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010738 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010739 .init_hook = alc883_eee1601_inithook,
10740 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010741 [ALC1200_ASUS_P5Q] = {
10742 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10743 .init_verbs = { alc883_init_verbs },
10744 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10745 .dac_nids = alc883_dac_nids,
10746 .dig_out_nid = ALC1200_DIGOUT_NID,
10747 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010748 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010749 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10750 .channel_mode = alc883_sixstack_modes,
10751 .input_mux = &alc883_capture_source,
10752 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010753 [ALC889A_MB31] = {
10754 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10755 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10756 alc880_gpio1_init_verbs },
10757 .adc_nids = alc883_adc_nids,
10758 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010759 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010760 .dac_nids = alc883_dac_nids,
10761 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10762 .channel_mode = alc889A_mb31_6ch_modes,
10763 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10764 .input_mux = &alc889A_mb31_capture_source,
10765 .dig_out_nid = ALC883_DIGOUT_NID,
10766 .unsol_event = alc889A_mb31_unsol_event,
10767 .init_hook = alc889A_mb31_automute,
10768 },
Guido Günther3e1647c52009-06-05 00:47:26 +020010769 [ALC883_SONY_VAIO_TT] = {
10770 .mixers = { alc883_vaiott_mixer },
10771 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10772 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10773 .dac_nids = alc883_dac_nids,
10774 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10775 .channel_mode = alc883_3ST_2ch_modes,
10776 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010777 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010778 .setup = alc883_vaiott_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010779 .init_hook = alc_hp_automute,
Guido Günther3e1647c52009-06-05 00:47:26 +020010780 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010781};
10782
10783
10784/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010785 * Pin config fixes
10786 */
10787enum {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010788 PINFIX_ABIT_AW9D_MAX,
David Henningsson32eea382011-03-04 13:37:50 +010010789 PINFIX_LENOVO_Y530,
Takashi Iwai954a29c2010-07-30 10:55:44 +020010790 PINFIX_PB_M5210,
David Henningssonc3d226a2010-10-14 15:42:08 +020010791 PINFIX_ACER_ASPIRE_7736,
Takashi Iwaic6b35872011-03-28 12:05:31 +020010792 PINFIX_GIGABYTE_880GM,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010793};
10794
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010795static const struct alc_fixup alc882_fixups[] = {
10796 [PINFIX_ABIT_AW9D_MAX] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010797 .type = ALC_FIXUP_PINS,
10798 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020010799 { 0x15, 0x01080104 }, /* side */
10800 { 0x16, 0x01011012 }, /* rear */
10801 { 0x17, 0x01016011 }, /* clfe */
10802 { }
10803 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010804 },
David Henningsson32eea382011-03-04 13:37:50 +010010805 [PINFIX_LENOVO_Y530] = {
10806 .type = ALC_FIXUP_PINS,
10807 .v.pins = (const struct alc_pincfg[]) {
10808 { 0x15, 0x99130112 }, /* rear int speakers */
10809 { 0x16, 0x99130111 }, /* subwoofer */
10810 { }
10811 }
10812 },
Takashi Iwai954a29c2010-07-30 10:55:44 +020010813 [PINFIX_PB_M5210] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010814 .type = ALC_FIXUP_VERBS,
10815 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020010816 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
10817 {}
10818 }
Takashi Iwai954a29c2010-07-30 10:55:44 +020010819 },
David Henningssonc3d226a2010-10-14 15:42:08 +020010820 [PINFIX_ACER_ASPIRE_7736] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010821 .type = ALC_FIXUP_SKU,
10822 .v.sku = ALC_FIXUP_SKU_IGNORE,
David Henningssonc3d226a2010-10-14 15:42:08 +020010823 },
Takashi Iwaic6b35872011-03-28 12:05:31 +020010824 [PINFIX_GIGABYTE_880GM] = {
10825 .type = ALC_FIXUP_PINS,
10826 .v.pins = (const struct alc_pincfg[]) {
10827 { 0x14, 0x1114410 }, /* set as speaker */
10828 { }
10829 }
10830 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010831};
10832
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010833static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010834 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
David Henningsson32eea382011-03-04 13:37:50 +010010835 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", PINFIX_LENOVO_Y530),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010836 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
David Henningssonc3d226a2010-10-14 15:42:08 +020010837 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736),
Takashi Iwaic6b35872011-03-28 12:05:31 +020010838 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte", PINFIX_GIGABYTE_880GM),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010839 {}
10840};
10841
10842/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010843 * BIOS auto configuration
10844 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010845static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10846 const struct auto_pin_cfg *cfg)
10847{
10848 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10849}
10850
Takashi Iwai4953550a2009-06-30 15:28:30 +020010851static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010852 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010853 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010854{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010855 int idx;
10856
Takashi Iwai489008c2010-04-07 09:06:00 +020010857 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010858 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010859
Takashi Iwai489008c2010-04-07 09:06:00 +020010860 if (dac == 0x25)
10861 idx = 4;
10862 else if (dac >= 0x02 && dac <= 0x05)
10863 idx = dac - 2;
10864 else
10865 return;
10866 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010867}
10868
Takashi Iwai4953550a2009-06-30 15:28:30 +020010869static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010870{
10871 struct alc_spec *spec = codec->spec;
10872 int i;
10873
10874 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010875 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010876 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010877 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010878 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010879 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010880 }
10881}
10882
Takashi Iwai4953550a2009-06-30 15:28:30 +020010883static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010884{
10885 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020010886 hda_nid_t pin, dac;
Takashi Iwai5855fb82010-09-16 18:24:02 +020010887 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010888
David Henningsson0a3fabe2011-03-04 16:54:52 +010010889 if (spec->autocfg.line_out_type != AUTO_PIN_HP_OUT) {
10890 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
10891 pin = spec->autocfg.hp_pins[i];
10892 if (!pin)
10893 break;
10894 dac = spec->multiout.hp_nid;
10895 if (!dac)
10896 dac = spec->multiout.dac_nids[0]; /* to front */
10897 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10898 }
Takashi Iwai489008c2010-04-07 09:06:00 +020010899 }
David Henningsson0a3fabe2011-03-04 16:54:52 +010010900
10901 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT) {
10902 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
10903 pin = spec->autocfg.speaker_pins[i];
10904 if (!pin)
10905 break;
10906 dac = spec->multiout.extra_out_nid[0];
10907 if (!dac)
10908 dac = spec->multiout.dac_nids[0]; /* to front */
10909 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10910 }
Takashi Iwai489008c2010-04-07 09:06:00 +020010911 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010912}
10913
Takashi Iwai4953550a2009-06-30 15:28:30 +020010914static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010915{
10916 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010917 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010918 int i;
10919
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010920 for (i = 0; i < cfg->num_inputs; i++) {
10921 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai30ea0982010-09-16 18:47:56 +020010922 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010923 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10924 snd_hda_codec_write(codec, nid, 0,
10925 AC_VERB_SET_AMP_GAIN_MUTE,
10926 AMP_OUT_MUTE);
10927 }
10928}
10929
10930static void alc882_auto_init_input_src(struct hda_codec *codec)
10931{
10932 struct alc_spec *spec = codec->spec;
10933 int c;
10934
10935 for (c = 0; c < spec->num_adc_nids; c++) {
10936 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10937 hda_nid_t nid = spec->capsrc_nids[c];
10938 unsigned int mux_idx;
10939 const struct hda_input_mux *imux;
10940 int conns, mute, idx, item;
10941
Takashi Iwai10696aa2011-04-07 12:46:45 +020010942 /* mute ADC */
10943 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
10944 AC_VERB_SET_AMP_GAIN_MUTE,
10945 AMP_IN_MUTE(0));
10946
Takashi Iwai4953550a2009-06-30 15:28:30 +020010947 conns = snd_hda_get_connections(codec, nid, conn_list,
10948 ARRAY_SIZE(conn_list));
10949 if (conns < 0)
10950 continue;
10951 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10952 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010953 if (!imux->num_items && mux_idx > 0)
10954 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010955 for (idx = 0; idx < conns; idx++) {
10956 /* if the current connection is the selected one,
10957 * unmute it as default - otherwise mute it
10958 */
10959 mute = AMP_IN_MUTE(idx);
10960 for (item = 0; item < imux->num_items; item++) {
10961 if (imux->items[item].index == idx) {
10962 if (spec->cur_mux[c] == item)
10963 mute = AMP_IN_UNMUTE(idx);
10964 break;
10965 }
10966 }
10967 /* check if we have a selector or mixer
10968 * we could check for the widget type instead, but
10969 * just check for Amp-In presence (in case of mixer
10970 * without amp-in there is something wrong, this
10971 * function shouldn't be used or capsrc nid is wrong)
10972 */
10973 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010974 snd_hda_codec_write(codec, nid, 0,
10975 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010976 mute);
10977 else if (mute != AMP_IN_MUTE(idx))
10978 snd_hda_codec_write(codec, nid, 0,
10979 AC_VERB_SET_CONNECT_SEL,
10980 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010981 }
10982 }
10983}
10984
Takashi Iwai4953550a2009-06-30 15:28:30 +020010985/* add mic boosts if needed */
10986static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010987{
10988 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010989 struct auto_pin_cfg *cfg = &spec->autocfg;
David Henningsson5322bf22011-01-05 11:03:56 +010010990 int i, err;
Takashi Iwai53e8c322010-12-17 15:23:41 +010010991 int type_idx = 0;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010992 hda_nid_t nid;
David Henningsson5322bf22011-01-05 11:03:56 +010010993 const char *prev_label = NULL;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010994
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010995 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +020010996 if (cfg->inputs[i].type > AUTO_PIN_MIC)
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010997 break;
10998 nid = cfg->inputs[i].pin;
10999 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
David Henningsson5322bf22011-01-05 11:03:56 +010011000 const char *label;
11001 char boost_label[32];
11002
11003 label = hda_get_autocfg_input_label(codec, cfg, i);
11004 if (prev_label && !strcmp(label, prev_label))
Takashi Iwai53e8c322010-12-17 15:23:41 +010011005 type_idx++;
11006 else
11007 type_idx = 0;
David Henningsson5322bf22011-01-05 11:03:56 +010011008 prev_label = label;
11009
11010 snprintf(boost_label, sizeof(boost_label),
11011 "%s Boost Volume", label);
11012 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11013 boost_label, type_idx,
Takashi Iwai4953550a2009-06-30 15:28:30 +020011014 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020011015 if (err < 0)
11016 return err;
11017 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011018 }
11019 return 0;
11020}
11021
11022/* almost identical with ALC880 parser... */
11023static int alc882_parse_auto_config(struct hda_codec *codec)
11024{
11025 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011026 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai757899a2010-07-30 10:48:14 +020011027 int err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011028
Takashi Iwai05f5f472009-08-25 13:10:18 +020011029 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11030 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011031 if (err < 0)
11032 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011033 if (!spec->autocfg.line_outs)
11034 return 0; /* can't find valid BIOS pin config */
11035
11036 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
11037 if (err < 0)
11038 return err;
Takashi Iwaice764ab2011-04-27 16:35:23 +020011039 err = alc_auto_add_multi_channel_mode(codec);
11040 if (err < 0)
11041 return err;
Takashi Iwai569ed342011-01-19 10:14:46 +010011042 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
Takashi Iwai05f5f472009-08-25 13:10:18 +020011043 if (err < 0)
11044 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020011045 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
11046 "Headphone");
11047 if (err < 0)
11048 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011049 err = alc880_auto_create_extra_out(spec,
11050 spec->autocfg.speaker_pins[0],
11051 "Speaker");
11052 if (err < 0)
11053 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011054 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
11055 if (err < 0)
11056 return err;
11057
11058 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11059
Takashi Iwai757899a2010-07-30 10:48:14 +020011060 alc_auto_parse_digital(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020011061
11062 if (spec->kctls.list)
11063 add_mixer(spec, spec->kctls.list);
11064
11065 add_verb(spec, alc883_auto_init_verbs);
11066 /* if ADC 0x07 is available, initialize it, too */
11067 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
11068 add_verb(spec, alc882_adc1_init_verbs);
11069
11070 spec->num_mux_defs = 1;
11071 spec->input_mux = &spec->private_imux[0];
11072
Kailang Yang6227cdc2010-02-25 08:36:52 +010011073 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020011074
11075 err = alc_auto_add_mic_boost(codec);
11076 if (err < 0)
11077 return err;
11078
Takashi Iwai776e1842007-08-29 15:07:11 +020011079 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011080}
11081
11082/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020011083static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011084{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011085 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011086 alc882_auto_init_multi_out(codec);
11087 alc882_auto_init_hp_out(codec);
11088 alc882_auto_init_analog_input(codec);
11089 alc882_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020011090 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011091 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011092 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011093}
11094
Takashi Iwai4953550a2009-06-30 15:28:30 +020011095static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011096{
11097 struct alc_spec *spec;
11098 int err, board_config;
11099
11100 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11101 if (spec == NULL)
11102 return -ENOMEM;
11103
11104 codec->spec = spec;
11105
Takashi Iwai4953550a2009-06-30 15:28:30 +020011106 switch (codec->vendor_id) {
11107 case 0x10ec0882:
11108 case 0x10ec0885:
11109 break;
11110 default:
11111 /* ALC883 and variants */
11112 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11113 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011114 }
11115
Takashi Iwai4953550a2009-06-30 15:28:30 +020011116 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
11117 alc882_models,
11118 alc882_cfg_tbl);
11119
11120 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
11121 board_config = snd_hda_check_board_codec_sid_config(codec,
11122 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
11123
11124 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020011125 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020011126 codec->chip_name);
11127 board_config = ALC882_AUTO;
11128 }
11129
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010011130 if (board_config == ALC882_AUTO) {
11131 alc_pick_fixup(codec, NULL, alc882_fixup_tbl, alc882_fixups);
11132 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
11133 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011134
David Henningsson90622912010-10-14 14:50:18 +020011135 alc_auto_parse_customize_define(codec);
11136
Takashi Iwai4953550a2009-06-30 15:28:30 +020011137 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011138 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020011139 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011140 if (err < 0) {
11141 alc_free(codec);
11142 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011143 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011144 printk(KERN_INFO
11145 "hda_codec: Cannot set up configuration "
11146 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020011147 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011148 }
11149 }
11150
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011151 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020011152 err = snd_hda_attach_beep_device(codec, 0x1);
11153 if (err < 0) {
11154 alc_free(codec);
11155 return err;
11156 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011157 }
11158
Takashi Iwai4953550a2009-06-30 15:28:30 +020011159 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011160 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011161
Takashi Iwai4953550a2009-06-30 15:28:30 +020011162 spec->stream_analog_playback = &alc882_pcm_analog_playback;
11163 spec->stream_analog_capture = &alc882_pcm_analog_capture;
11164 /* FIXME: setup DAC5 */
11165 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
11166 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
11167
11168 spec->stream_digital_playback = &alc882_pcm_digital_playback;
11169 spec->stream_digital_capture = &alc882_pcm_digital_capture;
11170
Takashi Iwai4953550a2009-06-30 15:28:30 +020011171 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011172 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011173 spec->num_adc_nids = 0;
11174 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011175 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011176 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011177 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020011178 hda_nid_t nid = alc882_adc_nids[i];
11179 unsigned int wcap = get_wcaps(codec, nid);
11180 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011181 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020011182 if (wcap != AC_WID_AUD_IN)
11183 continue;
11184 spec->private_adc_nids[spec->num_adc_nids] = nid;
11185 err = snd_hda_get_connections(codec, nid, &cap, 1);
11186 if (err < 0)
11187 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011188 err = snd_hda_get_connections(codec, cap, items,
11189 ARRAY_SIZE(items));
11190 if (err < 0)
11191 continue;
11192 for (j = 0; j < imux->num_items; j++)
11193 if (imux->items[j].index >= err)
11194 break;
11195 if (j < imux->num_items)
11196 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011197 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
11198 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011199 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011200 spec->adc_nids = spec->private_adc_nids;
11201 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020011202 }
11203
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011204 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010011205
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011206 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010011207 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011208
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010011209 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020011210
Takashi Iwai2134ea42008-01-10 16:53:55 +010011211 spec->vmaster_nid = 0x0c;
11212
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011213 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011214 if (board_config == ALC882_AUTO)
11215 spec->init_hook = alc882_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020011216
11217 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020011218#ifdef CONFIG_SND_HDA_POWER_SAVE
11219 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020011220 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011221#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011222
11223 return 0;
11224}
11225
Takashi Iwai4953550a2009-06-30 15:28:30 +020011226
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011227/*
Kailang Yangdf694da2005-12-05 19:42:22 +010011228 * ALC262 support
11229 */
11230
11231#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
11232#define ALC262_DIGIN_NID ALC880_DIGIN_NID
11233
11234#define alc262_dac_nids alc260_dac_nids
11235#define alc262_adc_nids alc882_adc_nids
11236#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010011237#define alc262_capsrc_nids alc882_capsrc_nids
11238#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010011239
11240#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010011241#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010011242
Kailang Yang4e555fe2008-08-26 13:05:55 +020011243static hda_nid_t alc262_dmic_adc_nids[1] = {
11244 /* ADC0 */
11245 0x09
11246};
11247
11248static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
11249
Kailang Yangdf694da2005-12-05 19:42:22 +010011250static struct snd_kcontrol_new alc262_base_mixer[] = {
11251 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11252 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11253 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11254 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11255 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11256 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11257 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11258 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011259 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011260 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11261 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011262 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011263 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
11264 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11265 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
11266 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011267 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010011268};
11269
Takashi Iwaice875f02008-01-28 18:17:43 +010011270/* update HP, line and mono-out pins according to the master switch */
Takashi Iwaie9427962011-04-28 15:46:07 +020011271#define alc262_hp_master_update alc260_hp_master_update
Takashi Iwaice875f02008-01-28 18:17:43 +010011272
Takashi Iwaie9427962011-04-28 15:46:07 +020011273static void alc262_hp_bpc_setup(struct hda_codec *codec)
Takashi Iwaice875f02008-01-28 18:17:43 +010011274{
11275 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011276
Takashi Iwaie9427962011-04-28 15:46:07 +020011277 spec->autocfg.hp_pins[0] = 0x1b;
11278 spec->autocfg.speaker_pins[0] = 0x16;
11279 spec->automute = 1;
11280 spec->automute_mode = ALC_AUTOMUTE_PIN;
Takashi Iwaice875f02008-01-28 18:17:43 +010011281}
11282
Takashi Iwaie9427962011-04-28 15:46:07 +020011283static void alc262_hp_wildwest_setup(struct hda_codec *codec)
Takashi Iwaice875f02008-01-28 18:17:43 +010011284{
11285 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011286
Takashi Iwaie9427962011-04-28 15:46:07 +020011287 spec->autocfg.hp_pins[0] = 0x15;
11288 spec->autocfg.speaker_pins[0] = 0x16;
11289 spec->automute = 1;
11290 spec->automute_mode = ALC_AUTOMUTE_PIN;
Takashi Iwaice875f02008-01-28 18:17:43 +010011291}
11292
Takashi Iwaib72519b2009-05-08 14:31:55 +020011293#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaie9427962011-04-28 15:46:07 +020011294#define alc262_hp_master_sw_put alc260_hp_master_sw_put
Takashi Iwaice875f02008-01-28 18:17:43 +010011295
Takashi Iwaib72519b2009-05-08 14:31:55 +020011296#define ALC262_HP_MASTER_SWITCH \
11297 { \
11298 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11299 .name = "Master Playback Switch", \
11300 .info = snd_ctl_boolean_mono_info, \
11301 .get = alc262_hp_master_sw_get, \
11302 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011303 }, \
11304 { \
11305 .iface = NID_MAPPING, \
11306 .name = "Master Playback Switch", \
11307 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020011308 }
11309
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011310
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011311static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011312 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011313 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11314 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11315 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011316 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11317 HDA_OUTPUT),
11318 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11319 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011320 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11321 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011322 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011323 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11324 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011325 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011326 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11327 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11328 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11329 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011330 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
11331 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
11332 { } /* end */
11333};
11334
Kailang Yangcd7509a2007-01-26 18:33:17 +010011335static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011336 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010011337 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11338 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11339 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11340 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011341 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11342 HDA_OUTPUT),
11343 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11344 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011345 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
11346 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011347 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011348 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11349 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11350 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11351 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011352 { } /* end */
11353};
11354
11355static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
11356 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11357 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011358 HDA_CODEC_VOLUME("Rear Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011359 { } /* end */
11360};
11361
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011362/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011363static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011364{
11365 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011366
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011367 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010011368 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +020011369 spec->automute = 1;
11370 spec->automute_mode = ALC_AUTOMUTE_PIN;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011371}
11372
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011373static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010011374 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11375 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011376 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11377 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11378 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11379 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011380 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011381 { } /* end */
11382};
11383
11384static struct hda_verb alc262_hp_t5735_verbs[] = {
11385 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11386 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11387
11388 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11389 { }
11390};
11391
Kailang Yang8c427222008-01-10 13:03:59 +010011392static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010011393 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11394 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010011395 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11396 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010011397 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11398 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11399 { } /* end */
11400};
11401
11402static struct hda_verb alc262_hp_rp5700_verbs[] = {
11403 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11404 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11405 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11406 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11407 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11408 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11409 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11410 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11411 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11412 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11413 {}
11414};
11415
11416static struct hda_input_mux alc262_hp_rp5700_capture_source = {
11417 .num_items = 1,
11418 .items = {
11419 { "Line", 0x1 },
11420 },
11421};
11422
Takashi Iwai42171c12009-05-08 14:11:43 +020011423/* bind hp and internal speaker mute (with plug check) as master switch */
Takashi Iwaie9427962011-04-28 15:46:07 +020011424#define alc262_hippo_master_update alc262_hp_master_update
Takashi Iwai42171c12009-05-08 14:11:43 +020011425#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
Takashi Iwaie9427962011-04-28 15:46:07 +020011426#define alc262_hippo_master_sw_put alc262_hp_master_sw_put
Takashi Iwai5b319542007-07-26 11:49:22 +020011427
Takashi Iwai42171c12009-05-08 14:11:43 +020011428#define ALC262_HIPPO_MASTER_SWITCH \
11429 { \
11430 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11431 .name = "Master Playback Switch", \
11432 .info = snd_ctl_boolean_mono_info, \
11433 .get = alc262_hippo_master_sw_get, \
11434 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011435 }, \
11436 { \
11437 .iface = NID_MAPPING, \
11438 .name = "Master Playback Switch", \
11439 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
11440 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020011441 }
11442
11443static struct snd_kcontrol_new alc262_hippo_mixer[] = {
11444 ALC262_HIPPO_MASTER_SWITCH,
11445 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11446 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11447 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11448 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("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11451 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011452 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011453 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11454 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011455 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011456 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11457 { } /* end */
11458};
11459
11460static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
11461 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11462 ALC262_HIPPO_MASTER_SWITCH,
11463 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11464 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11465 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11466 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11467 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11468 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011469 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011470 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11471 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011472 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011473 { } /* end */
11474};
11475
11476/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011477static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011478{
11479 struct alc_spec *spec = codec->spec;
11480
11481 spec->autocfg.hp_pins[0] = 0x15;
11482 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaie9427962011-04-28 15:46:07 +020011483 spec->automute = 1;
11484 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai42171c12009-05-08 14:11:43 +020011485}
11486
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011487static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011488{
11489 struct alc_spec *spec = codec->spec;
11490
11491 spec->autocfg.hp_pins[0] = 0x1b;
11492 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaie9427962011-04-28 15:46:07 +020011493 spec->automute = 1;
11494 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai42171c12009-05-08 14:11:43 +020011495}
11496
11497
Kailang Yang272a5272007-05-14 11:00:38 +020011498static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011499 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011500 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011501 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11502 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11503 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11504 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11505 { } /* end */
11506};
11507
Kailang Yang83c34212007-07-05 11:43:05 +020011508static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011509 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11510 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011511 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11512 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11513 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11514 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11515 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11516 { } /* end */
11517};
Kailang Yang272a5272007-05-14 11:00:38 +020011518
Tony Vroonba340e82009-02-02 19:01:30 +000011519static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11520 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11521 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11522 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11523 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11524 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11525 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11526 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11527 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011528 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroonba340e82009-02-02 19:01:30 +000011529 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11530 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011531 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tony Vroonba340e82009-02-02 19:01:30 +000011532 { } /* end */
11533};
11534
11535static struct hda_verb alc262_tyan_verbs[] = {
11536 /* Headphone automute */
11537 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11538 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11539 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11540
11541 /* P11 AUX_IN, white 4-pin connector */
11542 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11543 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11544 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11545 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11546
11547 {}
11548};
11549
11550/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011551static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011552{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011553 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011554
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011555 spec->autocfg.hp_pins[0] = 0x1b;
11556 spec->autocfg.speaker_pins[0] = 0x15;
Takashi Iwaid922b512011-04-28 12:18:53 +020011557 spec->automute = 1;
11558 spec->automute_mode = ALC_AUTOMUTE_AMP;
Tony Vroonba340e82009-02-02 19:01:30 +000011559}
11560
Tony Vroonba340e82009-02-02 19:01:30 +000011561
Kailang Yangdf694da2005-12-05 19:42:22 +010011562#define alc262_capture_mixer alc882_capture_mixer
11563#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11564
11565/*
11566 * generic initialization of ADC, input mixers and output mixers
11567 */
11568static struct hda_verb alc262_init_verbs[] = {
11569 /*
11570 * Unmute ADC0-2 and set the default input to mic-in
11571 */
11572 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11573 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11574 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11575 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11576 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11577 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11578
Takashi Iwaicb53c622007-08-10 17:21:45 +020011579 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011580 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011581 * Note: PASD motherboards uses the Line In 2 as the input for
11582 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011583 */
11584 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011585 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11586 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11587 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11588 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11589 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011590
11591 /*
11592 * Set up output mixers (0x0c - 0x0e)
11593 */
11594 /* set vol=0 to output mixers */
11595 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11596 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11597 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11598 /* set up input amps for analog loopback */
11599 /* Amp Indices: DAC = 0, mixer = 1 */
11600 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11601 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11602 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11603 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11604 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11605 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11606
11607 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11608 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11609 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11610 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11611 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11612 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11613
11614 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11615 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11616 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11617 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11618 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011619
Kailang Yangdf694da2005-12-05 19:42:22 +010011620 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11621 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011622
Kailang Yangdf694da2005-12-05 19:42:22 +010011623 /* FIXME: use matrix-type input source selection */
11624 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11625 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11626 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11627 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11628 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11629 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11630 /* Input mixer2 */
11631 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11632 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11633 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11634 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11635 /* Input mixer3 */
11636 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11637 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11638 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011639 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011640
11641 { }
11642};
11643
Kailang Yang4e555fe2008-08-26 13:05:55 +020011644static struct hda_verb alc262_eapd_verbs[] = {
11645 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11646 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11647 { }
11648};
11649
Kailang Yangccc656c2006-10-17 12:32:26 +020011650static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11651 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11652 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11653 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11654
11655 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11656 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11657 {}
11658};
11659
Kailang Yang272a5272007-05-14 11:00:38 +020011660static struct hda_verb alc262_sony_unsol_verbs[] = {
11661 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11662 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11663 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11664
11665 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11666 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011667 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011668};
11669
Kailang Yang4e555fe2008-08-26 13:05:55 +020011670static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11671 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11672 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11673 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11674 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11675 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011676 { } /* end */
11677};
11678
11679static struct hda_verb alc262_toshiba_s06_verbs[] = {
11680 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11681 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11682 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11683 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11684 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11685 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11686 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11687 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11688 {}
11689};
11690
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011691static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011692{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011693 struct alc_spec *spec = codec->spec;
11694
11695 spec->autocfg.hp_pins[0] = 0x15;
11696 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011697 spec->ext_mic.pin = 0x18;
11698 spec->ext_mic.mux_idx = 0;
11699 spec->int_mic.pin = 0x12;
11700 spec->int_mic.mux_idx = 9;
11701 spec->auto_mic = 1;
Takashi Iwaid922b512011-04-28 12:18:53 +020011702 spec->automute = 1;
11703 spec->automute_mode = ALC_AUTOMUTE_PIN;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011704}
11705
Takashi Iwai834be882006-03-01 14:16:17 +010011706/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011707 * nec model
11708 * 0x15 = headphone
11709 * 0x16 = internal speaker
11710 * 0x18 = external mic
11711 */
11712
11713static struct snd_kcontrol_new alc262_nec_mixer[] = {
11714 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11715 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11716
11717 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11718 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011719 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011720
11721 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11722 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11723 { } /* end */
11724};
11725
11726static struct hda_verb alc262_nec_verbs[] = {
11727 /* Unmute Speaker */
11728 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11729
11730 /* Headphone */
11731 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11732 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11733
11734 /* External mic to headphone */
11735 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11736 /* External mic to speaker */
11737 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11738 {}
11739};
11740
11741/*
Takashi Iwai834be882006-03-01 14:16:17 +010011742 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011743 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11744 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011745 */
11746
11747#define ALC_HP_EVENT 0x37
11748
11749static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11750 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11751 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011752 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11753 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011754 {}
11755};
11756
Jiang zhe0e31daf2008-03-20 12:12:39 +010011757static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11758 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11759 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11760 {}
11761};
11762
Daniel T Chene2595322009-12-19 18:19:02 -050011763static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11764 /* Front Mic pin: input vref at 50% */
11765 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11766 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11767 {}
11768};
11769
Takashi Iwai834be882006-03-01 14:16:17 +010011770static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011771 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011772 .items = {
11773 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +010011774 { "Internal Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011775 { "CD", 0x4 },
11776 },
11777};
11778
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011779static struct hda_input_mux alc262_HP_capture_source = {
11780 .num_items = 5,
11781 .items = {
11782 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011783 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011784 { "Line", 0x2 },
11785 { "CD", 0x4 },
11786 { "AUX IN", 0x6 },
11787 },
11788};
11789
zhejiangaccbe492007-08-31 12:36:05 +020011790static struct hda_input_mux alc262_HP_D7000_capture_source = {
11791 .num_items = 4,
11792 .items = {
11793 { "Mic", 0x0 },
11794 { "Front Mic", 0x2 },
11795 { "Line", 0x1 },
11796 { "CD", 0x4 },
11797 },
11798};
11799
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011800/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011801static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11802{
11803 struct alc_spec *spec = codec->spec;
11804 unsigned int mute;
11805
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011806 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011807 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11808 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011809 spec->sense_updated = 1;
11810 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011811 /* unmute internal speaker only if both HPs are unplugged and
11812 * master switch is on
11813 */
11814 if (spec->jack_present)
11815 mute = HDA_AMP_MUTE;
11816 else
Takashi Iwai834be882006-03-01 14:16:17 +010011817 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011818 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11819 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011820}
11821
11822/* unsolicited event for HP jack sensing */
11823static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11824 unsigned int res)
11825{
11826 if ((res >> 26) != ALC_HP_EVENT)
11827 return;
11828 alc262_fujitsu_automute(codec, 1);
11829}
11830
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011831static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11832{
11833 alc262_fujitsu_automute(codec, 1);
11834}
11835
Takashi Iwai834be882006-03-01 14:16:17 +010011836/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011837static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11838 .ops = &snd_hda_bind_vol,
11839 .values = {
11840 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11841 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11842 0
11843 },
11844};
Takashi Iwai834be882006-03-01 14:16:17 +010011845
Jiang zhe0e31daf2008-03-20 12:12:39 +010011846/* mute/unmute internal speaker according to the hp jack and mute state */
11847static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11848{
11849 struct alc_spec *spec = codec->spec;
11850 unsigned int mute;
11851
11852 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011853 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011854 spec->sense_updated = 1;
11855 }
11856 if (spec->jack_present) {
11857 /* mute internal speaker */
11858 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11859 HDA_AMP_MUTE, HDA_AMP_MUTE);
11860 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11861 HDA_AMP_MUTE, HDA_AMP_MUTE);
11862 } else {
11863 /* unmute internal speaker if necessary */
11864 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11865 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11866 HDA_AMP_MUTE, mute);
11867 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11868 HDA_AMP_MUTE, mute);
11869 }
11870}
11871
11872/* unsolicited event for HP jack sensing */
11873static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11874 unsigned int res)
11875{
11876 if ((res >> 26) != ALC_HP_EVENT)
11877 return;
11878 alc262_lenovo_3000_automute(codec, 1);
11879}
11880
Takashi Iwai8de56b72009-07-24 16:51:47 +020011881static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11882 int dir, int idx, long *valp)
11883{
11884 int i, change = 0;
11885
11886 for (i = 0; i < 2; i++, valp++)
11887 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11888 HDA_AMP_MUTE,
11889 *valp ? 0 : HDA_AMP_MUTE);
11890 return change;
11891}
11892
Takashi Iwai834be882006-03-01 14:16:17 +010011893/* bind hp and internal speaker mute (with plug check) */
11894static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11895 struct snd_ctl_elem_value *ucontrol)
11896{
11897 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11898 long *valp = ucontrol->value.integer.value;
11899 int change;
11900
Takashi Iwai8de56b72009-07-24 16:51:47 +020011901 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11902 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011903 if (change)
11904 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011905 return change;
11906}
11907
11908static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011909 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011910 {
11911 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11912 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011913 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011914 .info = snd_hda_mixer_amp_switch_info,
11915 .get = snd_hda_mixer_amp_switch_get,
11916 .put = alc262_fujitsu_master_sw_put,
11917 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11918 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011919 {
11920 .iface = NID_MAPPING,
11921 .name = "Master Playback Switch",
11922 .private_value = 0x1b,
11923 },
Takashi Iwai834be882006-03-01 14:16:17 +010011924 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11925 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011926 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011927 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11928 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011929 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010011930 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11931 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011932 { } /* end */
11933};
11934
Jiang zhe0e31daf2008-03-20 12:12:39 +010011935/* bind hp and internal speaker mute (with plug check) */
11936static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11937 struct snd_ctl_elem_value *ucontrol)
11938{
11939 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11940 long *valp = ucontrol->value.integer.value;
11941 int change;
11942
Takashi Iwai8de56b72009-07-24 16:51:47 +020011943 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011944 if (change)
11945 alc262_lenovo_3000_automute(codec, 0);
11946 return change;
11947}
11948
11949static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11950 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11951 {
11952 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11953 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011954 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011955 .info = snd_hda_mixer_amp_switch_info,
11956 .get = snd_hda_mixer_amp_switch_get,
11957 .put = alc262_lenovo_3000_master_sw_put,
11958 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11959 },
11960 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11961 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011962 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011963 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11964 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011965 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010011966 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11967 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011968 { } /* end */
11969};
11970
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011971static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11972 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011973 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011974 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11975 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011976 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011977 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11978 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011979 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011980 { } /* end */
11981};
11982
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011983/* additional init verbs for Benq laptops */
11984static struct hda_verb alc262_EAPD_verbs[] = {
11985 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11986 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11987 {}
11988};
11989
Kailang Yang83c34212007-07-05 11:43:05 +020011990static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11991 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11992 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11993
11994 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11995 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11996 {}
11997};
11998
Tobin Davisf651b502007-10-26 12:40:47 +020011999/* Samsung Q1 Ultra Vista model setup */
12000static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012001 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
12002 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020012003 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12004 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010012005 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
12006 HDA_CODEC_VOLUME("Headphone Mic Boost Volume", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020012007 { } /* end */
12008};
12009
12010static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012011 /* output mixer */
12012 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12013 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12014 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12015 /* speaker */
12016 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12017 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12018 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12019 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12020 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020012021 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012022 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12023 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12024 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12025 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12026 /* internal mic */
12027 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12028 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12029 /* ADC, choose mic */
12030 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12031 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12032 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12033 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12034 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12035 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12036 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12037 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12038 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
12039 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020012040 {}
12041};
12042
Tobin Davisf651b502007-10-26 12:40:47 +020012043/* mute/unmute internal speaker according to the hp jack and mute state */
12044static void alc262_ultra_automute(struct hda_codec *codec)
12045{
12046 struct alc_spec *spec = codec->spec;
12047 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020012048
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012049 mute = 0;
12050 /* auto-mute only when HP is used as HP */
12051 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012052 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012053 if (spec->jack_present)
12054 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020012055 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012056 /* mute/unmute internal speaker */
12057 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12058 HDA_AMP_MUTE, mute);
12059 /* mute/unmute HP */
12060 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12061 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020012062}
12063
12064/* unsolicited event for HP jack sensing */
12065static void alc262_ultra_unsol_event(struct hda_codec *codec,
12066 unsigned int res)
12067{
12068 if ((res >> 26) != ALC880_HP_EVENT)
12069 return;
12070 alc262_ultra_automute(codec);
12071}
12072
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012073static struct hda_input_mux alc262_ultra_capture_source = {
12074 .num_items = 2,
12075 .items = {
12076 { "Mic", 0x1 },
12077 { "Headphone", 0x7 },
12078 },
12079};
12080
12081static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
12082 struct snd_ctl_elem_value *ucontrol)
12083{
12084 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12085 struct alc_spec *spec = codec->spec;
12086 int ret;
12087
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012088 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012089 if (!ret)
12090 return 0;
12091 /* reprogram the HP pin as mic or HP according to the input source */
12092 snd_hda_codec_write_cache(codec, 0x15, 0,
12093 AC_VERB_SET_PIN_WIDGET_CONTROL,
12094 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
12095 alc262_ultra_automute(codec); /* mute/unmute HP */
12096 return ret;
12097}
12098
12099static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
12100 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
12101 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
12102 {
12103 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12104 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012105 .info = alc_mux_enum_info,
12106 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012107 .put = alc262_ultra_mux_enum_put,
12108 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010012109 {
12110 .iface = NID_MAPPING,
12111 .name = "Capture Source",
12112 .private_value = 0x15,
12113 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012114 { } /* end */
12115};
12116
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012117/* We use two mixers depending on the output pin; 0x16 is a mono output
12118 * and thus it's bound with a different mixer.
12119 * This function returns which mixer amp should be used.
12120 */
12121static int alc262_check_volbit(hda_nid_t nid)
12122{
12123 if (!nid)
12124 return 0;
12125 else if (nid == 0x16)
12126 return 2;
12127 else
12128 return 1;
12129}
12130
12131static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012132 const char *pfx, int *vbits, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012133{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012134 unsigned long val;
12135 int vbit;
12136
12137 vbit = alc262_check_volbit(nid);
12138 if (!vbit)
12139 return 0;
12140 if (*vbits & vbit) /* a volume control for this mixer already there */
12141 return 0;
12142 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012143 if (vbit == 2)
12144 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
12145 else
12146 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012147 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012148}
12149
12150static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012151 const char *pfx, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012152{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012153 unsigned long val;
12154
12155 if (!nid)
12156 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012157 if (nid == 0x16)
12158 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
12159 else
12160 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012161 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012162}
12163
Kailang Yangdf694da2005-12-05 19:42:22 +010012164/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012165static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
12166 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012167{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012168 const char *pfx;
12169 int vbits;
Takashi Iwai033688a2010-09-08 15:47:09 +020012170 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +010012171
12172 spec->multiout.num_dacs = 1; /* only use one dac */
12173 spec->multiout.dac_nids = spec->private_dac_nids;
12174 spec->multiout.dac_nids[0] = 2;
12175
Takashi Iwaice764ab2011-04-27 16:35:23 +020012176 pfx = alc_get_line_out_pfx(spec, true);
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010012177 if (!pfx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012178 pfx = "Front";
Takashi Iwai033688a2010-09-08 15:47:09 +020012179 for (i = 0; i < 2; i++) {
12180 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, i);
12181 if (err < 0)
12182 return err;
12183 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12184 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i],
12185 "Speaker", i);
12186 if (err < 0)
12187 return err;
12188 }
12189 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12190 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i],
12191 "Headphone", i);
12192 if (err < 0)
12193 return err;
12194 }
12195 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012196
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012197 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
12198 alc262_check_volbit(cfg->speaker_pins[0]) |
12199 alc262_check_volbit(cfg->hp_pins[0]);
12200 if (vbits == 1 || vbits == 2)
12201 pfx = "Master"; /* only one mixer is used */
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012202 vbits = 0;
Takashi Iwai033688a2010-09-08 15:47:09 +020012203 for (i = 0; i < 2; i++) {
12204 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx,
12205 &vbits, i);
12206 if (err < 0)
12207 return err;
12208 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12209 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i],
12210 "Speaker", &vbits, i);
12211 if (err < 0)
12212 return err;
12213 }
12214 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12215 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i],
12216 "Headphone", &vbits, i);
12217 if (err < 0)
12218 return err;
12219 }
12220 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012221 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010012222}
12223
Takashi Iwai05f5f472009-08-25 13:10:18 +020012224#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010012225 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010012226
12227/*
12228 * generic initialization of ADC, input mixers and output mixers
12229 */
12230static struct hda_verb alc262_volume_init_verbs[] = {
12231 /*
12232 * Unmute ADC0-2 and set the default input to mic-in
12233 */
12234 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12235 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12236 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12237 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12238 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12239 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12240
Takashi Iwaicb53c622007-08-10 17:21:45 +020012241 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010012242 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012243 * Note: PASD motherboards uses the Line In 2 as the input for
12244 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010012245 */
12246 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012247 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12248 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12249 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12250 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12251 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012252
12253 /*
12254 * Set up output mixers (0x0c - 0x0f)
12255 */
12256 /* set vol=0 to output mixers */
12257 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12258 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12259 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020012260
Kailang Yangdf694da2005-12-05 19:42:22 +010012261 /* set up input amps for analog loopback */
12262 /* Amp Indices: DAC = 0, mixer = 1 */
12263 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12264 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12265 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12266 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12267 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12268 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12269
12270 /* FIXME: use matrix-type input source selection */
12271 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12272 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12273 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12274 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12275 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12276 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12277 /* Input mixer2 */
12278 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12279 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12280 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12281 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12282 /* Input mixer3 */
12283 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12284 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12285 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12286 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12287
12288 { }
12289};
12290
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012291static struct hda_verb alc262_HP_BPC_init_verbs[] = {
12292 /*
12293 * Unmute ADC0-2 and set the default input to mic-in
12294 */
12295 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12296 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12297 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12298 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12299 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12300 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12301
Takashi Iwaicb53c622007-08-10 17:21:45 +020012302 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012303 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012304 * Note: PASD motherboards uses the Line In 2 as the input for
12305 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012306 */
12307 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012308 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12309 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12310 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12311 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12312 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12313 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12314 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012315
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012316 /*
12317 * Set up output mixers (0x0c - 0x0e)
12318 */
12319 /* set vol=0 to output mixers */
12320 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12321 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12322 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12323
12324 /* set up input amps for analog loopback */
12325 /* Amp Indices: DAC = 0, mixer = 1 */
12326 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12327 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12328 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12329 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12330 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12331 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12332
Takashi Iwaice875f02008-01-28 18:17:43 +010012333 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012334 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12335 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12336
12337 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12338 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12339
12340 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12341 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12342
12343 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12344 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12345 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12346 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12347 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12348
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012349 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012350 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12351 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012352 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012353 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12354 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12355
12356
12357 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012358 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
12359 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012360 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012361 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12362 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12363 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12364 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12365 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12366 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12367 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12368 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012369 /* Input mixer2 */
12370 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012371 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12372 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12373 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12374 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12375 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12376 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12377 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12378 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012379 /* Input mixer3 */
12380 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012381 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12382 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12383 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12384 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12385 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12386 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12387 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12388 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012389
Takashi Iwaice875f02008-01-28 18:17:43 +010012390 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12391
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012392 { }
12393};
12394
Kailang Yangcd7509a2007-01-26 18:33:17 +010012395static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
12396 /*
12397 * Unmute ADC0-2 and set the default input to mic-in
12398 */
12399 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12400 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12401 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12402 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12403 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12404 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12405
Takashi Iwaicb53c622007-08-10 17:21:45 +020012406 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010012407 * mixer widget
12408 * Note: PASD motherboards uses the Line In 2 as the input for front
12409 * panel mic (mic 2)
12410 */
12411 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012412 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12413 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12414 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12415 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12416 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12417 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12418 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12419 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010012420 /*
12421 * Set up output mixers (0x0c - 0x0e)
12422 */
12423 /* set vol=0 to output mixers */
12424 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12425 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12426 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12427
12428 /* set up input amps for analog loopback */
12429 /* Amp Indices: DAC = 0, mixer = 1 */
12430 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12431 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12432 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12433 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12434 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12435 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12436
12437
12438 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
12439 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
12440 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
12441 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
12442 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12443 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
12444 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
12445
12446 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12447 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12448
12449 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12450 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12451
12452 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
12453 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12454 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12455 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
12456 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12457 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12458
12459 /* FIXME: use matrix-type input source selection */
12460 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12461 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12462 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
12463 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
12464 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
12465 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
12466 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
12467 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12468 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
12469 /* Input mixer2 */
12470 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12471 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12472 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12473 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12474 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12475 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12476 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12477 /* Input mixer3 */
12478 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12479 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12480 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12481 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12482 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12483 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12484 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12485
Takashi Iwaice875f02008-01-28 18:17:43 +010012486 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12487
Kailang Yangcd7509a2007-01-26 18:33:17 +010012488 { }
12489};
12490
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012491static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
12492
12493 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12494 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12495 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12496
12497 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12498 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12499 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12500 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12501
12502 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12503 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12504 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12505 {}
12506};
12507
Takashi Iwai18675e42010-09-08 15:55:44 +020012508/*
12509 * Pin config fixes
12510 */
12511enum {
12512 PINFIX_FSC_H270,
12513};
12514
12515static const struct alc_fixup alc262_fixups[] = {
12516 [PINFIX_FSC_H270] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010012517 .type = ALC_FIXUP_PINS,
12518 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai18675e42010-09-08 15:55:44 +020012519 { 0x14, 0x99130110 }, /* speaker */
12520 { 0x15, 0x0221142f }, /* front HP */
12521 { 0x1b, 0x0121141f }, /* rear HP */
12522 { }
12523 }
12524 },
Takashi Iwai18675e42010-09-08 15:55:44 +020012525};
12526
12527static struct snd_pci_quirk alc262_fixup_tbl[] = {
12528 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270),
12529 {}
12530};
12531
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012532
Takashi Iwaicb53c622007-08-10 17:21:45 +020012533#ifdef CONFIG_SND_HDA_POWER_SAVE
12534#define alc262_loopbacks alc880_loopbacks
12535#endif
12536
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012537/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012538#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12539#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12540#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12541#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12542
12543/*
12544 * BIOS auto configuration
12545 */
12546static int alc262_parse_auto_config(struct hda_codec *codec)
12547{
12548 struct alc_spec *spec = codec->spec;
12549 int err;
12550 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12551
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012552 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12553 alc262_ignore);
12554 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012555 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012556 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012557 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012558 spec->multiout.max_channels = 2;
12559 spec->no_analog = 1;
12560 goto dig_only;
12561 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012562 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012563 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012564 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12565 if (err < 0)
12566 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012567 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012568 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012569 return err;
12570
12571 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12572
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012573 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012574 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012575
Takashi Iwai603c4012008-07-30 15:01:44 +020012576 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012577 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012578
Takashi Iwaid88897e2008-10-31 15:01:37 +010012579 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012580 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012581 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012582
Takashi Iwai776e1842007-08-29 15:07:11 +020012583 err = alc_auto_add_mic_boost(codec);
12584 if (err < 0)
12585 return err;
12586
Kailang Yang6227cdc2010-02-25 08:36:52 +010012587 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012588
Kailang Yangdf694da2005-12-05 19:42:22 +010012589 return 1;
12590}
12591
12592#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12593#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12594#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012595#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012596
12597
12598/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012599static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012600{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012601 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012602 alc262_auto_init_multi_out(codec);
12603 alc262_auto_init_hp_out(codec);
12604 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012605 alc262_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012606 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012607 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012608 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012609}
12610
12611/*
12612 * configuration and preset
12613 */
Takashi Iwaiea734962011-01-17 11:29:34 +010012614static const char * const alc262_models[ALC262_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012615 [ALC262_BASIC] = "basic",
12616 [ALC262_HIPPO] = "hippo",
12617 [ALC262_HIPPO_1] = "hippo_1",
12618 [ALC262_FUJITSU] = "fujitsu",
12619 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012620 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012621 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012622 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012623 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012624 [ALC262_BENQ_T31] = "benq-t31",
12625 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012626 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012627 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012628 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012629 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012630 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012631 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012632 [ALC262_AUTO] = "auto",
12633};
12634
12635static struct snd_pci_quirk alc262_cfg_tbl[] = {
12636 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012637 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012638 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12639 ALC262_HP_BPC),
12640 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12641 ALC262_HP_BPC),
Takashi Iwai5734a072011-01-19 17:07:12 +010012642 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1500, "HP z series",
12643 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012644 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12645 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012646 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012647 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012648 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012649 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012650 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012651 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012652 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012653 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012654 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12655 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12656 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012657 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12658 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012659 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012660 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012661 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012662 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012663 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012664 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012665 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012666 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012667#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012668 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12669 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012670#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012671 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012672 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012673 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012674 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012675 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012676 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012677 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12678 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012679 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012680 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012681 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012682 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012683 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012684 {}
12685};
12686
12687static struct alc_config_preset alc262_presets[] = {
12688 [ALC262_BASIC] = {
12689 .mixers = { alc262_base_mixer },
12690 .init_verbs = { alc262_init_verbs },
12691 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12692 .dac_nids = alc262_dac_nids,
12693 .hp_nid = 0x03,
12694 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12695 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012696 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012697 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012698 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012699 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012700 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012701 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12702 .dac_nids = alc262_dac_nids,
12703 .hp_nid = 0x03,
12704 .dig_out_nid = ALC262_DIGOUT_NID,
12705 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12706 .channel_mode = alc262_modes,
12707 .input_mux = &alc262_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012708 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012709 .setup = alc262_hippo_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020012710 .init_hook = alc_inithook,
Kailang Yangccc656c2006-10-17 12:32:26 +020012711 },
12712 [ALC262_HIPPO_1] = {
12713 .mixers = { alc262_hippo1_mixer },
12714 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12715 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12716 .dac_nids = alc262_dac_nids,
12717 .hp_nid = 0x02,
12718 .dig_out_nid = ALC262_DIGOUT_NID,
12719 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12720 .channel_mode = alc262_modes,
12721 .input_mux = &alc262_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012722 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012723 .setup = alc262_hippo1_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020012724 .init_hook = alc_inithook,
Kailang Yangccc656c2006-10-17 12:32:26 +020012725 },
Takashi Iwai834be882006-03-01 14:16:17 +010012726 [ALC262_FUJITSU] = {
12727 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012728 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12729 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012730 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12731 .dac_nids = alc262_dac_nids,
12732 .hp_nid = 0x03,
12733 .dig_out_nid = ALC262_DIGOUT_NID,
12734 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12735 .channel_mode = alc262_modes,
12736 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012737 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012738 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012739 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012740 [ALC262_HP_BPC] = {
12741 .mixers = { alc262_HP_BPC_mixer },
12742 .init_verbs = { alc262_HP_BPC_init_verbs },
12743 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12744 .dac_nids = alc262_dac_nids,
12745 .hp_nid = 0x03,
12746 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12747 .channel_mode = alc262_modes,
12748 .input_mux = &alc262_HP_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012749 .unsol_event = alc_sku_unsol_event,
12750 .setup = alc262_hp_bpc_setup,
12751 .init_hook = alc_inithook,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012752 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012753 [ALC262_HP_BPC_D7000_WF] = {
12754 .mixers = { alc262_HP_BPC_WildWest_mixer },
12755 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12756 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12757 .dac_nids = alc262_dac_nids,
12758 .hp_nid = 0x03,
12759 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12760 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012761 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012762 .unsol_event = alc_sku_unsol_event,
12763 .setup = alc262_hp_wildwest_setup,
12764 .init_hook = alc_inithook,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012765 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012766 [ALC262_HP_BPC_D7000_WL] = {
12767 .mixers = { alc262_HP_BPC_WildWest_mixer,
12768 alc262_HP_BPC_WildWest_option_mixer },
12769 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12770 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12771 .dac_nids = alc262_dac_nids,
12772 .hp_nid = 0x03,
12773 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12774 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012775 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012776 .unsol_event = alc_sku_unsol_event,
12777 .setup = alc262_hp_wildwest_setup,
12778 .init_hook = alc_inithook,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012779 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012780 [ALC262_HP_TC_T5735] = {
12781 .mixers = { alc262_hp_t5735_mixer },
12782 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12783 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12784 .dac_nids = alc262_dac_nids,
12785 .hp_nid = 0x03,
12786 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12787 .channel_mode = alc262_modes,
12788 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012789 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012790 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012791 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012792 },
12793 [ALC262_HP_RP5700] = {
12794 .mixers = { alc262_hp_rp5700_mixer },
12795 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12796 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12797 .dac_nids = alc262_dac_nids,
12798 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12799 .channel_mode = alc262_modes,
12800 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012801 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012802 [ALC262_BENQ_ED8] = {
12803 .mixers = { alc262_base_mixer },
12804 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12805 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12806 .dac_nids = alc262_dac_nids,
12807 .hp_nid = 0x03,
12808 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12809 .channel_mode = alc262_modes,
12810 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012811 },
Kailang Yang272a5272007-05-14 11:00:38 +020012812 [ALC262_SONY_ASSAMD] = {
12813 .mixers = { alc262_sony_mixer },
12814 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12815 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12816 .dac_nids = alc262_dac_nids,
12817 .hp_nid = 0x02,
12818 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12819 .channel_mode = alc262_modes,
12820 .input_mux = &alc262_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012821 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012822 .setup = alc262_hippo_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020012823 .init_hook = alc_inithook,
Kailang Yang83c34212007-07-05 11:43:05 +020012824 },
12825 [ALC262_BENQ_T31] = {
12826 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012827 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12828 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012829 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12830 .dac_nids = alc262_dac_nids,
12831 .hp_nid = 0x03,
12832 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12833 .channel_mode = alc262_modes,
12834 .input_mux = &alc262_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012835 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012836 .setup = alc262_hippo_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020012837 .init_hook = alc_inithook,
Kailang Yangea1fb292008-08-26 12:58:38 +020012838 },
Tobin Davisf651b502007-10-26 12:40:47 +020012839 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012840 .mixers = { alc262_ultra_mixer },
12841 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012842 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012843 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12844 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012845 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12846 .channel_mode = alc262_modes,
12847 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012848 .adc_nids = alc262_adc_nids, /* ADC0 */
12849 .capsrc_nids = alc262_capsrc_nids,
12850 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012851 .unsol_event = alc262_ultra_unsol_event,
12852 .init_hook = alc262_ultra_automute,
12853 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012854 [ALC262_LENOVO_3000] = {
12855 .mixers = { alc262_lenovo_3000_mixer },
12856 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012857 alc262_lenovo_3000_unsol_verbs,
12858 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012859 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12860 .dac_nids = alc262_dac_nids,
12861 .hp_nid = 0x03,
12862 .dig_out_nid = ALC262_DIGOUT_NID,
12863 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12864 .channel_mode = alc262_modes,
12865 .input_mux = &alc262_fujitsu_capture_source,
12866 .unsol_event = alc262_lenovo_3000_unsol_event,
12867 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012868 [ALC262_NEC] = {
12869 .mixers = { alc262_nec_mixer },
12870 .init_verbs = { alc262_nec_verbs },
12871 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12872 .dac_nids = alc262_dac_nids,
12873 .hp_nid = 0x03,
12874 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12875 .channel_mode = alc262_modes,
12876 .input_mux = &alc262_capture_source,
12877 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012878 [ALC262_TOSHIBA_S06] = {
12879 .mixers = { alc262_toshiba_s06_mixer },
12880 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12881 alc262_eapd_verbs },
12882 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12883 .capsrc_nids = alc262_dmic_capsrc_nids,
12884 .dac_nids = alc262_dac_nids,
12885 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012886 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012887 .dig_out_nid = ALC262_DIGOUT_NID,
12888 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12889 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012890 .unsol_event = alc_sku_unsol_event,
12891 .setup = alc262_toshiba_s06_setup,
12892 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012893 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012894 [ALC262_TOSHIBA_RX1] = {
12895 .mixers = { alc262_toshiba_rx1_mixer },
12896 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12897 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12898 .dac_nids = alc262_dac_nids,
12899 .hp_nid = 0x03,
12900 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12901 .channel_mode = alc262_modes,
12902 .input_mux = &alc262_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012903 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012904 .setup = alc262_hippo_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020012905 .init_hook = alc_inithook,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012906 },
Tony Vroonba340e82009-02-02 19:01:30 +000012907 [ALC262_TYAN] = {
12908 .mixers = { alc262_tyan_mixer },
12909 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12910 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12911 .dac_nids = alc262_dac_nids,
12912 .hp_nid = 0x02,
12913 .dig_out_nid = ALC262_DIGOUT_NID,
12914 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12915 .channel_mode = alc262_modes,
12916 .input_mux = &alc262_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020012917 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012918 .setup = alc262_tyan_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020012919 .init_hook = alc_hp_automute,
Tony Vroonba340e82009-02-02 19:01:30 +000012920 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012921};
12922
12923static int patch_alc262(struct hda_codec *codec)
12924{
12925 struct alc_spec *spec;
12926 int board_config;
12927 int err;
12928
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012929 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012930 if (spec == NULL)
12931 return -ENOMEM;
12932
12933 codec->spec = spec;
12934#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012935 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12936 * under-run
12937 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012938 {
12939 int tmp;
12940 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12941 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12942 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12943 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12944 }
12945#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012946 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012947
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012948 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12949
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012950 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12951 alc262_models,
12952 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012953
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012954 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012955 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12956 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012957 board_config = ALC262_AUTO;
12958 }
12959
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010012960 if (board_config == ALC262_AUTO) {
12961 alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups);
12962 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
12963 }
Takashi Iwai18675e42010-09-08 15:55:44 +020012964
Kailang Yangdf694da2005-12-05 19:42:22 +010012965 if (board_config == ALC262_AUTO) {
12966 /* automatic parse from the BIOS config */
12967 err = alc262_parse_auto_config(codec);
12968 if (err < 0) {
12969 alc_free(codec);
12970 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012971 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012972 printk(KERN_INFO
12973 "hda_codec: Cannot set up configuration "
12974 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012975 board_config = ALC262_BASIC;
12976 }
12977 }
12978
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012979 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010012980 err = snd_hda_attach_beep_device(codec, 0x1);
12981 if (err < 0) {
12982 alc_free(codec);
12983 return err;
12984 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012985 }
12986
Kailang Yangdf694da2005-12-05 19:42:22 +010012987 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012988 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012989
Kailang Yangdf694da2005-12-05 19:42:22 +010012990 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12991 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012992
Kailang Yangdf694da2005-12-05 19:42:22 +010012993 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12994 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12995
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012996 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012997 int i;
12998 /* check whether the digital-mic has to be supported */
12999 for (i = 0; i < spec->input_mux->num_items; i++) {
13000 if (spec->input_mux->items[i].index >= 9)
13001 break;
13002 }
13003 if (i < spec->input_mux->num_items) {
13004 /* use only ADC0 */
13005 spec->adc_nids = alc262_dmic_adc_nids;
13006 spec->num_adc_nids = 1;
13007 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010013008 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020013009 /* all analog inputs */
13010 /* check whether NID 0x07 is valid */
13011 unsigned int wcap = get_wcaps(codec, 0x07);
13012
13013 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013014 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020013015 if (wcap != AC_WID_AUD_IN) {
13016 spec->adc_nids = alc262_adc_nids_alt;
13017 spec->num_adc_nids =
13018 ARRAY_SIZE(alc262_adc_nids_alt);
13019 spec->capsrc_nids = alc262_capsrc_nids_alt;
13020 } else {
13021 spec->adc_nids = alc262_adc_nids;
13022 spec->num_adc_nids =
13023 ARRAY_SIZE(alc262_adc_nids);
13024 spec->capsrc_nids = alc262_capsrc_nids;
13025 }
Kailang Yangdf694da2005-12-05 19:42:22 +010013026 }
13027 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010013028 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013029 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020013030 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010013031 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010013032
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010013033 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai18675e42010-09-08 15:55:44 +020013034
Takashi Iwai2134ea42008-01-10 16:53:55 +010013035 spec->vmaster_nid = 0x0c;
13036
Kailang Yangdf694da2005-12-05 19:42:22 +010013037 codec->patch_ops = alc_patch_ops;
13038 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013039 spec->init_hook = alc262_auto_init;
Takashi Iwai1c7161532011-04-07 10:37:16 +020013040 spec->shutup = alc_eapd_shutup;
Kailang Yangbf1b0222010-10-21 08:49:56 +020013041
13042 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020013043#ifdef CONFIG_SND_HDA_POWER_SAVE
13044 if (!spec->loopback.amplist)
13045 spec->loopback.amplist = alc262_loopbacks;
13046#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020013047
Kailang Yangdf694da2005-12-05 19:42:22 +010013048 return 0;
13049}
13050
Kailang Yangdf694da2005-12-05 19:42:22 +010013051/*
Kailang Yanga361d842007-06-05 12:30:55 +020013052 * ALC268 channel source setting (2 channel)
13053 */
13054#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
13055#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020013056
Kailang Yanga361d842007-06-05 12:30:55 +020013057static hda_nid_t alc268_dac_nids[2] = {
13058 /* front, hp */
13059 0x02, 0x03
13060};
13061
13062static hda_nid_t alc268_adc_nids[2] = {
13063 /* ADC0-1 */
13064 0x08, 0x07
13065};
13066
13067static hda_nid_t alc268_adc_nids_alt[1] = {
13068 /* ADC0 */
13069 0x08
13070};
13071
Takashi Iwaie1406342008-02-11 18:32:32 +010013072static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
13073
Kailang Yanga361d842007-06-05 12:30:55 +020013074static struct snd_kcontrol_new alc268_base_mixer[] = {
13075 /* output mixer control */
13076 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13077 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13078 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13079 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013080 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13081 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
13082 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020013083 { }
13084};
13085
Takashi Iwai42171c12009-05-08 14:11:43 +020013086static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
13087 /* output mixer control */
13088 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13089 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13090 ALC262_HIPPO_MASTER_SWITCH,
David Henningsson5f99f862011-01-04 15:24:24 +010013091 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13092 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
13093 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020013094 { }
13095};
13096
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013097/* bind Beep switches of both NID 0x0f and 0x10 */
13098static struct hda_bind_ctls alc268_bind_beep_sw = {
13099 .ops = &snd_hda_bind_sw,
13100 .values = {
13101 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
13102 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
13103 0
13104 },
13105};
13106
13107static struct snd_kcontrol_new alc268_beep_mixer[] = {
13108 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
13109 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
13110 { }
13111};
13112
Kailang Yangd1a991a2007-08-15 16:21:59 +020013113static struct hda_verb alc268_eapd_verbs[] = {
13114 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13115 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13116 { }
13117};
13118
Takashi Iwaid2738092007-08-16 14:59:45 +020013119/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020013120static struct hda_verb alc268_toshiba_verbs[] = {
13121 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13122 { } /* end */
13123};
13124
13125/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020013126/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020013127static struct hda_bind_ctls alc268_acer_bind_master_vol = {
13128 .ops = &snd_hda_bind_vol,
13129 .values = {
13130 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
13131 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
13132 0
13133 },
13134};
13135
Takashi Iwai889c4392007-08-23 18:56:52 +020013136/* mute/unmute internal speaker according to the hp jack and mute state */
13137static void alc268_acer_automute(struct hda_codec *codec, int force)
13138{
13139 struct alc_spec *spec = codec->spec;
13140 unsigned int mute;
13141
13142 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080013143 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020013144 spec->sense_updated = 1;
13145 }
13146 if (spec->jack_present)
13147 mute = HDA_AMP_MUTE; /* mute internal speaker */
13148 else /* unmute internal speaker if necessary */
13149 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13150 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13151 HDA_AMP_MUTE, mute);
13152}
13153
13154
13155/* bind hp and internal speaker mute (with plug check) */
13156static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
13157 struct snd_ctl_elem_value *ucontrol)
13158{
13159 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
13160 long *valp = ucontrol->value.integer.value;
13161 int change;
13162
Takashi Iwai8de56b72009-07-24 16:51:47 +020013163 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020013164 if (change)
13165 alc268_acer_automute(codec, 0);
13166 return change;
13167}
Takashi Iwaid2738092007-08-16 14:59:45 +020013168
Kailang Yang8ef355d2008-08-26 13:10:22 +020013169static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
13170 /* output mixer control */
13171 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13172 {
13173 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13174 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013175 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013176 .info = snd_hda_mixer_amp_switch_info,
13177 .get = snd_hda_mixer_amp_switch_get,
13178 .put = alc268_acer_master_sw_put,
13179 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13180 },
13181 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
13182 { }
13183};
13184
Takashi Iwaid2738092007-08-16 14:59:45 +020013185static struct snd_kcontrol_new alc268_acer_mixer[] = {
13186 /* output mixer control */
13187 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13188 {
13189 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13190 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013191 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020013192 .info = snd_hda_mixer_amp_switch_info,
13193 .get = snd_hda_mixer_amp_switch_get,
13194 .put = alc268_acer_master_sw_put,
13195 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13196 },
David Henningsson5f99f862011-01-04 15:24:24 +010013197 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13198 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
13199 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020013200 { }
13201};
13202
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013203static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
13204 /* output mixer control */
13205 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13206 {
13207 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13208 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013209 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013210 .info = snd_hda_mixer_amp_switch_info,
13211 .get = snd_hda_mixer_amp_switch_get,
13212 .put = alc268_acer_master_sw_put,
13213 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13214 },
David Henningsson5f99f862011-01-04 15:24:24 +010013215 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13216 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013217 { }
13218};
13219
Kailang Yang8ef355d2008-08-26 13:10:22 +020013220static struct hda_verb alc268_acer_aspire_one_verbs[] = {
13221 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13222 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13223 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13224 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13225 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
13226 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
13227 { }
13228};
13229
Takashi Iwaid2738092007-08-16 14:59:45 +020013230static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013231 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
13232 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020013233 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13234 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013235 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13236 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020013237 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13238 { }
13239};
13240
13241/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013242#define alc268_toshiba_setup alc262_hippo_setup
Takashi Iwaid2738092007-08-16 14:59:45 +020013243
13244static void alc268_acer_unsol_event(struct hda_codec *codec,
13245 unsigned int res)
13246{
Takashi Iwai889c4392007-08-23 18:56:52 +020013247 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020013248 return;
13249 alc268_acer_automute(codec, 1);
13250}
13251
Takashi Iwai889c4392007-08-23 18:56:52 +020013252static void alc268_acer_init_hook(struct hda_codec *codec)
13253{
13254 alc268_acer_automute(codec, 1);
13255}
13256
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013257static void alc268_acer_lc_setup(struct hda_codec *codec)
13258{
13259 struct alc_spec *spec = codec->spec;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020013260 spec->autocfg.hp_pins[0] = 0x15;
13261 spec->autocfg.speaker_pins[0] = 0x14;
13262 spec->automute_mixer_nid[0] = 0x0f;
13263 spec->automute = 1;
13264 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013265 spec->ext_mic.pin = 0x18;
13266 spec->ext_mic.mux_idx = 0;
13267 spec->int_mic.pin = 0x12;
13268 spec->int_mic.mux_idx = 6;
13269 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013270}
13271
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013272static struct snd_kcontrol_new alc268_dell_mixer[] = {
13273 /* output mixer control */
13274 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13275 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13276 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13277 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013278 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13279 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013280 { }
13281};
13282
13283static struct hda_verb alc268_dell_verbs[] = {
13284 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13285 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13286 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013287 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013288 { }
13289};
13290
13291/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013292static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013293{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013294 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013295
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013296 spec->autocfg.hp_pins[0] = 0x15;
13297 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013298 spec->ext_mic.pin = 0x18;
13299 spec->ext_mic.mux_idx = 0;
13300 spec->int_mic.pin = 0x19;
13301 spec->int_mic.mux_idx = 1;
13302 spec->auto_mic = 1;
Takashi Iwaid922b512011-04-28 12:18:53 +020013303 spec->automute = 1;
13304 spec->automute_mode = ALC_AUTOMUTE_PIN;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013305}
13306
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013307static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
13308 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13309 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13310 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13311 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13312 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13313 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013314 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13315 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013316 { }
13317};
13318
13319static struct hda_verb alc267_quanta_il1_verbs[] = {
13320 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13321 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
13322 { }
13323};
13324
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013325static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013326{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013327 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013328 spec->autocfg.hp_pins[0] = 0x15;
13329 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013330 spec->ext_mic.pin = 0x18;
13331 spec->ext_mic.mux_idx = 0;
13332 spec->int_mic.pin = 0x19;
13333 spec->int_mic.mux_idx = 1;
13334 spec->auto_mic = 1;
Takashi Iwaid922b512011-04-28 12:18:53 +020013335 spec->automute = 1;
13336 spec->automute_mode = ALC_AUTOMUTE_PIN;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013337}
13338
Kailang Yanga361d842007-06-05 12:30:55 +020013339/*
13340 * generic initialization of ADC, input mixers and output mixers
13341 */
13342static struct hda_verb alc268_base_init_verbs[] = {
13343 /* Unmute DAC0-1 and set vol = 0 */
13344 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013345 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013346
13347 /*
13348 * Set up output mixers (0x0c - 0x0e)
13349 */
13350 /* set vol=0 to output mixers */
13351 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013352 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
13353
13354 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13355 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13356
13357 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13358 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
13359 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13360 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13361 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13362 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13363 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13364 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13365
13366 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13367 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13368 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13369 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013370 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013371
13372 /* set PCBEEP vol = 0, mute connections */
13373 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13374 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13375 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013376
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013377 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013378
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013379 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13380 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13381 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13382 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013383
Kailang Yanga361d842007-06-05 12:30:55 +020013384 { }
13385};
13386
13387/*
13388 * generic initialization of ADC, input mixers and output mixers
13389 */
13390static struct hda_verb alc268_volume_init_verbs[] = {
13391 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013392 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13393 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013394
13395 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13396 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13397 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13398 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13399 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13400
Kailang Yanga361d842007-06-05 12:30:55 +020013401 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013402 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13403 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13404
13405 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013406 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013407
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013408 /* set PCBEEP vol = 0, mute connections */
13409 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13410 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13411 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013412
13413 { }
13414};
13415
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013416static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
13417 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13418 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13419 { } /* end */
13420};
13421
Kailang Yanga361d842007-06-05 12:30:55 +020013422static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
13423 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13424 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013425 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013426 { } /* end */
13427};
13428
13429static struct snd_kcontrol_new alc268_capture_mixer[] = {
13430 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13431 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13432 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13433 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013434 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013435 { } /* end */
13436};
13437
13438static struct hda_input_mux alc268_capture_source = {
13439 .num_items = 4,
13440 .items = {
13441 { "Mic", 0x0 },
13442 { "Front Mic", 0x1 },
13443 { "Line", 0x2 },
13444 { "CD", 0x3 },
13445 },
13446};
13447
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013448static struct hda_input_mux alc268_acer_capture_source = {
13449 .num_items = 3,
13450 .items = {
13451 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013452 { "Internal Mic", 0x1 },
13453 { "Line", 0x2 },
13454 },
13455};
13456
13457static struct hda_input_mux alc268_acer_dmic_capture_source = {
13458 .num_items = 3,
13459 .items = {
13460 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013461 { "Internal Mic", 0x6 },
13462 { "Line", 0x2 },
13463 },
13464};
13465
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013466#ifdef CONFIG_SND_DEBUG
13467static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013468 /* Volume widgets */
13469 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13470 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13471 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13472 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13473 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13474 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13475 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13476 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13477 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13478 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13479 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13480 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13481 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013482 /* The below appears problematic on some hardwares */
13483 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013484 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13485 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13486 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13487 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13488
13489 /* Modes for retasking pin widgets */
13490 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13491 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13492 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13493 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13494
13495 /* Controls for GPIO pins, assuming they are configured as outputs */
13496 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13497 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13498 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13499 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13500
13501 /* Switches to allow the digital SPDIF output pin to be enabled.
13502 * The ALC268 does not have an SPDIF input.
13503 */
13504 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13505
13506 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13507 * this output to turn on an external amplifier.
13508 */
13509 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13510 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13511
13512 { } /* end */
13513};
13514#endif
13515
Kailang Yanga361d842007-06-05 12:30:55 +020013516/* create input playback/capture controls for the given pin */
13517static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13518 const char *ctlname, int idx)
13519{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013520 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013521 int err;
13522
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013523 switch (nid) {
13524 case 0x14:
13525 case 0x16:
13526 dac = 0x02;
13527 break;
13528 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013529 case 0x1a: /* ALC259/269 only */
13530 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013531 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013532 dac = 0x03;
13533 break;
13534 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013535 snd_printd(KERN_WARNING "hda_codec: "
13536 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013537 return 0;
13538 }
13539 if (spec->multiout.dac_nids[0] != dac &&
13540 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013541 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013542 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013543 HDA_OUTPUT));
13544 if (err < 0)
13545 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013546 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13547 }
13548
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013549 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013550 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013551 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013552 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013553 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013554 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013555 if (err < 0)
13556 return err;
13557 return 0;
13558}
13559
13560/* add playback controls from the parsed DAC table */
13561static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13562 const struct auto_pin_cfg *cfg)
13563{
13564 hda_nid_t nid;
13565 int err;
13566
Kailang Yanga361d842007-06-05 12:30:55 +020013567 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013568
13569 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013570 if (nid) {
13571 const char *name;
13572 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13573 name = "Speaker";
13574 else
13575 name = "Front";
13576 err = alc268_new_analog_output(spec, nid, name, 0);
13577 if (err < 0)
13578 return err;
13579 }
Kailang Yanga361d842007-06-05 12:30:55 +020013580
13581 nid = cfg->speaker_pins[0];
13582 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013583 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013584 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13585 if (err < 0)
13586 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013587 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013588 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13589 if (err < 0)
13590 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013591 }
13592 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013593 if (nid) {
13594 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13595 if (err < 0)
13596 return err;
13597 }
Kailang Yanga361d842007-06-05 12:30:55 +020013598
13599 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13600 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013601 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013602 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013603 if (err < 0)
13604 return err;
13605 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013606 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013607}
13608
13609/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013610static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013611 const struct auto_pin_cfg *cfg)
13612{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013613 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013614}
13615
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013616static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13617 hda_nid_t nid, int pin_type)
13618{
13619 int idx;
13620
13621 alc_set_pin_output(codec, nid, pin_type);
13622 if (nid == 0x14 || nid == 0x16)
13623 idx = 0;
13624 else
13625 idx = 1;
13626 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13627}
13628
13629static void alc268_auto_init_multi_out(struct hda_codec *codec)
13630{
13631 struct alc_spec *spec = codec->spec;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013632 int i;
13633
13634 for (i = 0; i < spec->autocfg.line_outs; i++) {
13635 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013636 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13637 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13638 }
13639}
13640
13641static void alc268_auto_init_hp_out(struct hda_codec *codec)
13642{
13643 struct alc_spec *spec = codec->spec;
13644 hda_nid_t pin;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013645 int i;
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013646
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013647 for (i = 0; i < spec->autocfg.hp_outs; i++) {
13648 pin = spec->autocfg.hp_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013649 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013650 }
13651 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
13652 pin = spec->autocfg.speaker_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013653 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013654 }
13655 if (spec->autocfg.mono_out_pin)
13656 snd_hda_codec_write(codec, spec->autocfg.mono_out_pin, 0,
13657 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013658}
13659
Kailang Yanga361d842007-06-05 12:30:55 +020013660static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13661{
13662 struct alc_spec *spec = codec->spec;
13663 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13664 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13665 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13666 unsigned int dac_vol1, dac_vol2;
13667
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013668 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013669 snd_hda_codec_write(codec, speaker_nid, 0,
13670 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013671 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013672 snd_hda_codec_write(codec, 0x0f, 0,
13673 AC_VERB_SET_AMP_GAIN_MUTE,
13674 AMP_IN_UNMUTE(1));
13675 snd_hda_codec_write(codec, 0x10, 0,
13676 AC_VERB_SET_AMP_GAIN_MUTE,
13677 AMP_IN_UNMUTE(1));
13678 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013679 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013680 snd_hda_codec_write(codec, 0x0f, 0,
13681 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13682 snd_hda_codec_write(codec, 0x10, 0,
13683 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13684 }
13685
13686 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013687 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013688 dac_vol2 = AMP_OUT_ZERO;
13689 else if (line_nid == 0x15)
13690 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013691 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013692 dac_vol2 = AMP_OUT_ZERO;
13693 else if (hp_nid == 0x15)
13694 dac_vol1 = AMP_OUT_ZERO;
13695 if (line_nid != 0x16 || hp_nid != 0x16 ||
13696 spec->autocfg.line_out_pins[1] != 0x16 ||
13697 spec->autocfg.line_out_pins[2] != 0x16)
13698 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13699
13700 snd_hda_codec_write(codec, 0x02, 0,
13701 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13702 snd_hda_codec_write(codec, 0x03, 0,
13703 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13704}
13705
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013706/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013707#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13708#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013709#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013710#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13711
13712/*
13713 * BIOS auto configuration
13714 */
13715static int alc268_parse_auto_config(struct hda_codec *codec)
13716{
13717 struct alc_spec *spec = codec->spec;
13718 int err;
13719 static hda_nid_t alc268_ignore[] = { 0 };
13720
13721 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13722 alc268_ignore);
13723 if (err < 0)
13724 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013725 if (!spec->autocfg.line_outs) {
13726 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13727 spec->multiout.max_channels = 2;
13728 spec->no_analog = 1;
13729 goto dig_only;
13730 }
Kailang Yanga361d842007-06-05 12:30:55 +020013731 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013732 }
Kailang Yanga361d842007-06-05 12:30:55 +020013733 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13734 if (err < 0)
13735 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013736 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013737 if (err < 0)
13738 return err;
13739
13740 spec->multiout.max_channels = 2;
13741
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013742 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013743 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013744 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013745 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013746 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013747
Takashi Iwai892981f2009-03-02 08:04:35 +010013748 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013749 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013750
Takashi Iwaid88897e2008-10-31 15:01:37 +010013751 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013752 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013753 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013754
Takashi Iwai776e1842007-08-29 15:07:11 +020013755 err = alc_auto_add_mic_boost(codec);
13756 if (err < 0)
13757 return err;
13758
Kailang Yang6227cdc2010-02-25 08:36:52 +010013759 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013760
Kailang Yanga361d842007-06-05 12:30:55 +020013761 return 1;
13762}
13763
Kailang Yanga361d842007-06-05 12:30:55 +020013764#define alc268_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaiae0ebbf2011-03-10 14:11:59 +010013765#define alc268_auto_init_input_src alc882_auto_init_input_src
Kailang Yanga361d842007-06-05 12:30:55 +020013766
13767/* init callback for auto-configuration model -- overriding the default init */
13768static void alc268_auto_init(struct hda_codec *codec)
13769{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013770 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013771 alc268_auto_init_multi_out(codec);
13772 alc268_auto_init_hp_out(codec);
13773 alc268_auto_init_mono_speaker_out(codec);
13774 alc268_auto_init_analog_input(codec);
Takashi Iwaiae0ebbf2011-03-10 14:11:59 +010013775 alc268_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013776 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013777 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013778 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013779}
13780
13781/*
13782 * configuration and preset
13783 */
Takashi Iwaiea734962011-01-17 11:29:34 +010013784static const char * const alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013785 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013786 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013787 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013788 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013789 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013790 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013791 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013792 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013793#ifdef CONFIG_SND_DEBUG
13794 [ALC268_TEST] = "test",
13795#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013796 [ALC268_AUTO] = "auto",
13797};
13798
13799static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013800 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013801 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013802 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013803 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013804 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013805 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13806 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013807 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013808 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13809 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013810 /* almost compatible with toshiba but with optional digital outs;
13811 * auto-probing seems working fine
13812 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013813 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013814 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013815 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013816 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013817 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013818 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013819 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013820 {}
13821};
13822
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013823/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13824static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13825 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13826 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13827 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13828 ALC268_TOSHIBA),
13829 {}
13830};
13831
Kailang Yanga361d842007-06-05 12:30:55 +020013832static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013833 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013834 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13835 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013836 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13837 alc267_quanta_il1_verbs },
13838 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13839 .dac_nids = alc268_dac_nids,
13840 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13841 .adc_nids = alc268_adc_nids_alt,
13842 .hp_nid = 0x03,
13843 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13844 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013845 .unsol_event = alc_sku_unsol_event,
13846 .setup = alc267_quanta_il1_setup,
13847 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013848 },
Kailang Yanga361d842007-06-05 12:30:55 +020013849 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013850 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13851 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013852 .init_verbs = { alc268_base_init_verbs },
13853 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13854 .dac_nids = alc268_dac_nids,
13855 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13856 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013857 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013858 .hp_nid = 0x03,
13859 .dig_out_nid = ALC268_DIGOUT_NID,
13860 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13861 .channel_mode = alc268_modes,
13862 .input_mux = &alc268_capture_source,
13863 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013864 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013865 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013866 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013867 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13868 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013869 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13870 .dac_nids = alc268_dac_nids,
13871 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13872 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013873 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013874 .hp_nid = 0x03,
13875 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13876 .channel_mode = alc268_modes,
13877 .input_mux = &alc268_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020013878 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013879 .setup = alc268_toshiba_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020013880 .init_hook = alc_inithook,
Takashi Iwaid2738092007-08-16 14:59:45 +020013881 },
13882 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013883 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013884 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013885 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13886 alc268_acer_verbs },
13887 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13888 .dac_nids = alc268_dac_nids,
13889 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13890 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013891 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013892 .hp_nid = 0x02,
13893 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13894 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013895 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013896 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013897 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013898 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013899 [ALC268_ACER_DMIC] = {
13900 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13901 alc268_beep_mixer },
13902 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13903 alc268_acer_verbs },
13904 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13905 .dac_nids = alc268_dac_nids,
13906 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13907 .adc_nids = alc268_adc_nids_alt,
13908 .capsrc_nids = alc268_capsrc_nids,
13909 .hp_nid = 0x02,
13910 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13911 .channel_mode = alc268_modes,
13912 .input_mux = &alc268_acer_dmic_capture_source,
13913 .unsol_event = alc268_acer_unsol_event,
13914 .init_hook = alc268_acer_init_hook,
13915 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013916 [ALC268_ACER_ASPIRE_ONE] = {
13917 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013918 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013919 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013920 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13921 alc268_acer_aspire_one_verbs },
13922 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13923 .dac_nids = alc268_dac_nids,
13924 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13925 .adc_nids = alc268_adc_nids_alt,
13926 .capsrc_nids = alc268_capsrc_nids,
13927 .hp_nid = 0x03,
13928 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13929 .channel_mode = alc268_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020013930 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013931 .setup = alc268_acer_lc_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020013932 .init_hook = alc_inithook,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013933 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013934 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013935 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13936 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013937 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13938 alc268_dell_verbs },
13939 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13940 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013941 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13942 .adc_nids = alc268_adc_nids_alt,
13943 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013944 .hp_nid = 0x02,
13945 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13946 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013947 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013948 .setup = alc268_dell_setup,
13949 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013950 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013951 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013952 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13953 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013954 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13955 alc268_toshiba_verbs },
13956 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13957 .dac_nids = alc268_dac_nids,
13958 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13959 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013960 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013961 .hp_nid = 0x03,
13962 .dig_out_nid = ALC268_DIGOUT_NID,
13963 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13964 .channel_mode = alc268_modes,
13965 .input_mux = &alc268_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020013966 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013967 .setup = alc268_toshiba_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020013968 .init_hook = alc_inithook,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013969 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013970#ifdef CONFIG_SND_DEBUG
13971 [ALC268_TEST] = {
13972 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13973 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13974 alc268_volume_init_verbs },
13975 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13976 .dac_nids = alc268_dac_nids,
13977 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13978 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013979 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013980 .hp_nid = 0x03,
13981 .dig_out_nid = ALC268_DIGOUT_NID,
13982 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13983 .channel_mode = alc268_modes,
13984 .input_mux = &alc268_capture_source,
13985 },
13986#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013987};
13988
13989static int patch_alc268(struct hda_codec *codec)
13990{
13991 struct alc_spec *spec;
13992 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013993 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013994
Julia Lawallef86f582009-12-19 08:18:03 +010013995 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013996 if (spec == NULL)
13997 return -ENOMEM;
13998
13999 codec->spec = spec;
14000
14001 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
14002 alc268_models,
14003 alc268_cfg_tbl);
14004
Takashi Iwai3abf2f32009-08-19 20:05:02 +020014005 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
14006 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010014007 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020014008
Kailang Yanga361d842007-06-05 12:30:55 +020014009 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014010 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14011 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020014012 board_config = ALC268_AUTO;
14013 }
14014
14015 if (board_config == ALC268_AUTO) {
14016 /* automatic parse from the BIOS config */
14017 err = alc268_parse_auto_config(codec);
14018 if (err < 0) {
14019 alc_free(codec);
14020 return err;
14021 } else if (!err) {
14022 printk(KERN_INFO
14023 "hda_codec: Cannot set up configuration "
14024 "from BIOS. Using base mode...\n");
14025 board_config = ALC268_3ST;
14026 }
14027 }
14028
14029 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014030 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020014031
Kailang Yanga361d842007-06-05 12:30:55 +020014032 spec->stream_analog_playback = &alc268_pcm_analog_playback;
14033 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010014034 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020014035
Kailang Yanga361d842007-06-05 12:30:55 +020014036 spec->stream_digital_playback = &alc268_pcm_digital_playback;
14037
Takashi Iwai22971e32009-02-10 11:56:44 +010014038 has_beep = 0;
14039 for (i = 0; i < spec->num_mixers; i++) {
14040 if (spec->mixers[i] == alc268_beep_mixer) {
14041 has_beep = 1;
14042 break;
14043 }
14044 }
14045
14046 if (has_beep) {
14047 err = snd_hda_attach_beep_device(codec, 0x1);
14048 if (err < 0) {
14049 alc_free(codec);
14050 return err;
14051 }
14052 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
14053 /* override the amp caps for beep generator */
14054 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010014055 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
14056 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
14057 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
14058 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010014059 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010014060
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014061 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014062 /* check whether NID 0x07 is valid */
14063 unsigned int wcap = get_wcaps(codec, 0x07);
Kailang Yanga361d842007-06-05 12:30:55 +020014064
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014065 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014066 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020014067 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014068 if (spec->auto_mic ||
14069 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014070 spec->adc_nids = alc268_adc_nids_alt;
14071 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014072 if (spec->auto_mic)
14073 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014074 if (spec->auto_mic || spec->input_mux->num_items == 1)
14075 add_mixer(spec, alc268_capture_nosrc_mixer);
14076 else
14077 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014078 } else {
14079 spec->adc_nids = alc268_adc_nids;
14080 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010014081 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020014082 }
14083 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010014084
14085 spec->vmaster_nid = 0x02;
14086
Kailang Yanga361d842007-06-05 12:30:55 +020014087 codec->patch_ops = alc_patch_ops;
14088 if (board_config == ALC268_AUTO)
14089 spec->init_hook = alc268_auto_init;
Takashi Iwai1c7161532011-04-07 10:37:16 +020014090 spec->shutup = alc_eapd_shutup;
Kailang Yangea1fb292008-08-26 12:58:38 +020014091
Kailang Yangbf1b0222010-10-21 08:49:56 +020014092 alc_init_jacks(codec);
14093
Kailang Yanga361d842007-06-05 12:30:55 +020014094 return 0;
14095}
14096
14097/*
Kailang Yangf6a92242007-12-13 16:52:54 +010014098 * ALC269 channel source setting (2 channel)
14099 */
14100#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
14101
14102#define alc269_dac_nids alc260_dac_nids
14103
14104static hda_nid_t alc269_adc_nids[1] = {
14105 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020014106 0x08,
14107};
14108
Takashi Iwaie01bf502008-08-21 16:25:07 +020014109static hda_nid_t alc269_capsrc_nids[1] = {
14110 0x23,
14111};
14112
Kailang Yang84898e82010-02-04 14:16:14 +010014113static hda_nid_t alc269vb_adc_nids[1] = {
14114 /* ADC1 */
14115 0x09,
14116};
14117
14118static hda_nid_t alc269vb_capsrc_nids[1] = {
14119 0x22,
14120};
14121
Takashi Iwai66946352010-03-29 17:21:45 +020014122static hda_nid_t alc269_adc_candidates[] = {
David Henningsson262ac222011-04-07 11:43:00 +020014123 0x08, 0x09, 0x07, 0x11,
Takashi Iwai66946352010-03-29 17:21:45 +020014124};
Takashi Iwaie01bf502008-08-21 16:25:07 +020014125
Kailang Yangf6a92242007-12-13 16:52:54 +010014126#define alc269_modes alc260_modes
14127#define alc269_capture_source alc880_lg_lw_capture_source
14128
14129static struct snd_kcontrol_new alc269_base_mixer[] = {
14130 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14131 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14132 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14133 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14134 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14135 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014136 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010014137 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14138 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014139 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010014140 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14141 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
14142 { } /* end */
14143};
14144
Kailang Yang60db6b52008-08-26 13:13:00 +020014145static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
14146 /* output mixer control */
14147 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14148 {
14149 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14150 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014151 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020014152 .info = snd_hda_mixer_amp_switch_info,
14153 .get = snd_hda_mixer_amp_switch_get,
14154 .put = alc268_acer_master_sw_put,
14155 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14156 },
14157 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14158 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014159 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014160 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14161 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014162 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014163 { }
14164};
14165
Tony Vroon64154832008-11-06 15:08:49 +000014166static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
14167 /* output mixer control */
14168 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14169 {
14170 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14171 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014172 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000014173 .info = snd_hda_mixer_amp_switch_info,
14174 .get = snd_hda_mixer_amp_switch_get,
14175 .put = alc268_acer_master_sw_put,
14176 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14177 },
14178 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14179 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014180 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014181 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14182 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014183 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014184 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
14185 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014186 HDA_CODEC_VOLUME("Dock Mic Boost Volume", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014187 { }
14188};
14189
Kailang Yang84898e82010-02-04 14:16:14 +010014190static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020014191 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014192 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020014193 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014194 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020014195 { } /* end */
14196};
14197
Kailang Yang84898e82010-02-04 14:16:14 +010014198static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
14199 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14200 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14201 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14202 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14203 { } /* end */
14204};
14205
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014206static struct snd_kcontrol_new alc269_asus_mixer[] = {
14207 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14208 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
14209 { } /* end */
14210};
14211
Kailang Yangf6a92242007-12-13 16:52:54 +010014212/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010014213static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
14214 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14215 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014216 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
14217 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014218 { } /* end */
14219};
14220
14221static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020014222 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14223 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014224 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010014225 { } /* end */
14226};
14227
Kailang Yang84898e82010-02-04 14:16:14 +010014228static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
14229 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14230 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014231 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
14232 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014233 { } /* end */
14234};
14235
14236static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
14237 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14238 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014239 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014240 { } /* end */
14241};
14242
Takashi Iwai26f5df22008-11-03 17:39:46 +010014243/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010014244#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020014245
Kailang Yang60db6b52008-08-26 13:13:00 +020014246static struct hda_verb alc269_quanta_fl1_verbs[] = {
14247 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14248 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14249 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14250 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14251 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14252 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14253 { }
14254};
14255
Tony Vroon64154832008-11-06 15:08:49 +000014256static struct hda_verb alc269_lifebook_verbs[] = {
14257 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14258 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
14259 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14260 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14261 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14262 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14263 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14264 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14265 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14266 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14267 { }
14268};
14269
Kailang Yang60db6b52008-08-26 13:13:00 +020014270/* toggle speaker-output according to the hp-jack state */
14271static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
14272{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014273 alc_hp_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014274
14275 snd_hda_codec_write(codec, 0x20, 0,
14276 AC_VERB_SET_COEF_INDEX, 0x0c);
14277 snd_hda_codec_write(codec, 0x20, 0,
14278 AC_VERB_SET_PROC_COEF, 0x680);
14279
14280 snd_hda_codec_write(codec, 0x20, 0,
14281 AC_VERB_SET_COEF_INDEX, 0x0c);
14282 snd_hda_codec_write(codec, 0x20, 0,
14283 AC_VERB_SET_PROC_COEF, 0x480);
14284}
14285
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014286#define alc269_lifebook_speaker_automute \
14287 alc269_quanta_fl1_speaker_automute
Tony Vroon64154832008-11-06 15:08:49 +000014288
Tony Vroon64154832008-11-06 15:08:49 +000014289static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
14290{
14291 unsigned int present_laptop;
14292 unsigned int present_dock;
14293
Wu Fengguang864f92b2009-11-18 12:38:02 +080014294 present_laptop = snd_hda_jack_detect(codec, 0x18);
14295 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000014296
14297 /* Laptop mic port overrides dock mic port, design decision */
14298 if (present_dock)
14299 snd_hda_codec_write(codec, 0x23, 0,
14300 AC_VERB_SET_CONNECT_SEL, 0x3);
14301 if (present_laptop)
14302 snd_hda_codec_write(codec, 0x23, 0,
14303 AC_VERB_SET_CONNECT_SEL, 0x0);
14304 if (!present_dock && !present_laptop)
14305 snd_hda_codec_write(codec, 0x23, 0,
14306 AC_VERB_SET_CONNECT_SEL, 0x1);
14307}
14308
Kailang Yang60db6b52008-08-26 13:13:00 +020014309static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
14310 unsigned int res)
14311{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014312 switch (res >> 26) {
14313 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014314 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014315 break;
14316 case ALC880_MIC_EVENT:
14317 alc_mic_automute(codec);
14318 break;
14319 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014320}
14321
Tony Vroon64154832008-11-06 15:08:49 +000014322static void alc269_lifebook_unsol_event(struct hda_codec *codec,
14323 unsigned int res)
14324{
14325 if ((res >> 26) == ALC880_HP_EVENT)
14326 alc269_lifebook_speaker_automute(codec);
14327 if ((res >> 26) == ALC880_MIC_EVENT)
14328 alc269_lifebook_mic_autoswitch(codec);
14329}
14330
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014331static void alc269_quanta_fl1_setup(struct hda_codec *codec)
14332{
14333 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014334 spec->autocfg.hp_pins[0] = 0x15;
14335 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014336 spec->automute_mixer_nid[0] = 0x0c;
14337 spec->automute = 1;
14338 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014339 spec->ext_mic.pin = 0x18;
14340 spec->ext_mic.mux_idx = 0;
14341 spec->int_mic.pin = 0x19;
14342 spec->int_mic.mux_idx = 1;
14343 spec->auto_mic = 1;
14344}
14345
Kailang Yang60db6b52008-08-26 13:13:00 +020014346static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
14347{
14348 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014349 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014350}
14351
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014352static void alc269_lifebook_setup(struct hda_codec *codec)
14353{
14354 struct alc_spec *spec = codec->spec;
14355 spec->autocfg.hp_pins[0] = 0x15;
14356 spec->autocfg.hp_pins[1] = 0x1a;
14357 spec->autocfg.speaker_pins[0] = 0x14;
14358 spec->automute_mixer_nid[0] = 0x0c;
14359 spec->automute = 1;
14360 spec->automute_mode = ALC_AUTOMUTE_MIXER;
14361}
14362
Tony Vroon64154832008-11-06 15:08:49 +000014363static void alc269_lifebook_init_hook(struct hda_codec *codec)
14364{
14365 alc269_lifebook_speaker_automute(codec);
14366 alc269_lifebook_mic_autoswitch(codec);
14367}
14368
Kailang Yang84898e82010-02-04 14:16:14 +010014369static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014370 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14371 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14372 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14373 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14374 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14375 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14376 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14377 {}
14378};
14379
Kailang Yang84898e82010-02-04 14:16:14 +010014380static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014381 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14382 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14383 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14384 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
14385 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14386 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14387 {}
14388};
14389
Kailang Yang84898e82010-02-04 14:16:14 +010014390static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
14391 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14392 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14393 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14394 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14395 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14396 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14397 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14398 {}
14399};
14400
14401static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
14402 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14403 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14404 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14405 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14406 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14407 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14408 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14409 {}
14410};
14411
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014412static struct hda_verb alc271_acer_dmic_verbs[] = {
14413 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14414 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14415 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14416 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14417 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14418 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14419 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14420 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14421 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14422 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14423 { }
14424};
14425
Kailang Yang226b1ec2010-04-09 11:01:20 +020014426static void alc269_laptop_amic_setup(struct hda_codec *codec)
14427{
14428 struct alc_spec *spec = codec->spec;
14429 spec->autocfg.hp_pins[0] = 0x15;
14430 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014431 spec->automute_mixer_nid[0] = 0x0c;
14432 spec->automute = 1;
14433 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014434 spec->ext_mic.pin = 0x18;
14435 spec->ext_mic.mux_idx = 0;
14436 spec->int_mic.pin = 0x19;
14437 spec->int_mic.mux_idx = 1;
14438 spec->auto_mic = 1;
14439}
14440
Kailang Yang84898e82010-02-04 14:16:14 +010014441static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014442{
14443 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014444 spec->autocfg.hp_pins[0] = 0x15;
14445 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014446 spec->automute_mixer_nid[0] = 0x0c;
14447 spec->automute = 1;
14448 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014449 spec->ext_mic.pin = 0x18;
14450 spec->ext_mic.mux_idx = 0;
14451 spec->int_mic.pin = 0x12;
14452 spec->int_mic.mux_idx = 5;
14453 spec->auto_mic = 1;
14454}
14455
Kailang Yang226b1ec2010-04-09 11:01:20 +020014456static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014457{
14458 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014459 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014460 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014461 spec->automute_mixer_nid[0] = 0x0c;
14462 spec->automute = 1;
14463 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014464 spec->ext_mic.pin = 0x18;
14465 spec->ext_mic.mux_idx = 0;
14466 spec->int_mic.pin = 0x19;
14467 spec->int_mic.mux_idx = 1;
14468 spec->auto_mic = 1;
14469}
14470
Kailang Yang226b1ec2010-04-09 11:01:20 +020014471static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14472{
14473 struct alc_spec *spec = codec->spec;
14474 spec->autocfg.hp_pins[0] = 0x21;
14475 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014476 spec->automute_mixer_nid[0] = 0x0c;
14477 spec->automute = 1;
14478 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014479 spec->ext_mic.pin = 0x18;
14480 spec->ext_mic.mux_idx = 0;
14481 spec->int_mic.pin = 0x12;
14482 spec->int_mic.mux_idx = 6;
14483 spec->auto_mic = 1;
14484}
14485
Kailang Yangf6a92242007-12-13 16:52:54 +010014486/*
14487 * generic initialization of ADC, input mixers and output mixers
14488 */
14489static struct hda_verb alc269_init_verbs[] = {
14490 /*
14491 * Unmute ADC0 and set the default input to mic-in
14492 */
Kailang Yang84898e82010-02-04 14:16:14 +010014493 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014494
14495 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014496 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014497 */
14498 /* set vol=0 to output mixers */
14499 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14500 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14501
14502 /* set up input amps for analog loopback */
14503 /* Amp Indices: DAC = 0, mixer = 1 */
14504 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14505 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14506 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14507 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14508 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14509 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14510
14511 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14512 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14513 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14514 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14515 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14516 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14517 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14518
14519 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14520 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014521
Kailang Yang84898e82010-02-04 14:16:14 +010014522 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014523 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14524 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014525 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014526
14527 /* set EAPD */
14528 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014529 { }
14530};
14531
14532static struct hda_verb alc269vb_init_verbs[] = {
14533 /*
14534 * Unmute ADC0 and set the default input to mic-in
14535 */
14536 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14537
14538 /*
14539 * Set up output mixers (0x02 - 0x03)
14540 */
14541 /* set vol=0 to output mixers */
14542 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14543 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14544
14545 /* set up input amps for analog loopback */
14546 /* Amp Indices: DAC = 0, mixer = 1 */
14547 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14548 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14549 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14550 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14551 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14552 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14553
14554 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14555 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14556 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14557 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14558 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14559 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14560 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14561
14562 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14563 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14564
14565 /* FIXME: use Mux-type input source selection */
14566 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14567 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14568 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14569
14570 /* set EAPD */
14571 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014572 { }
14573};
14574
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014575#define alc269_auto_create_multi_out_ctls \
14576 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014577#define alc269_auto_create_input_ctls \
14578 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014579
14580#ifdef CONFIG_SND_HDA_POWER_SAVE
14581#define alc269_loopbacks alc880_loopbacks
14582#endif
14583
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014584/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014585#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14586#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14587#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14588#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14589
Takashi Iwaif03d3112009-03-05 14:18:16 +010014590static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14591 .substreams = 1,
14592 .channels_min = 2,
14593 .channels_max = 8,
14594 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14595 /* NID is set in alc_build_pcms */
14596 .ops = {
14597 .open = alc880_playback_pcm_open,
14598 .prepare = alc880_playback_pcm_prepare,
14599 .cleanup = alc880_playback_pcm_cleanup
14600 },
14601};
14602
14603static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14604 .substreams = 1,
14605 .channels_min = 2,
14606 .channels_max = 2,
14607 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14608 /* NID is set in alc_build_pcms */
14609};
14610
Takashi Iwaiad358792010-03-30 18:00:59 +020014611#ifdef CONFIG_SND_HDA_POWER_SAVE
14612static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14613{
14614 switch (codec->subsystem_id) {
14615 case 0x103c1586:
14616 return 1;
14617 }
14618 return 0;
14619}
14620
14621static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14622{
14623 /* update mute-LED according to the speaker mute state */
14624 if (nid == 0x01 || nid == 0x14) {
14625 int pinval;
14626 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14627 HDA_AMP_MUTE)
14628 pinval = 0x24;
14629 else
14630 pinval = 0x20;
14631 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a542010-03-30 18:03:44 +020014632 snd_hda_codec_update_cache(codec, 0x19, 0,
14633 AC_VERB_SET_PIN_WIDGET_CONTROL,
14634 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014635 }
14636 return alc_check_power_status(codec, nid);
14637}
14638#endif /* CONFIG_SND_HDA_POWER_SAVE */
14639
Takashi Iwai840b64c2010-07-13 22:49:01 +020014640static int alc275_setup_dual_adc(struct hda_codec *codec)
14641{
14642 struct alc_spec *spec = codec->spec;
14643
14644 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14645 return 0;
14646 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14647 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14648 if (spec->ext_mic.pin <= 0x12) {
14649 spec->private_adc_nids[0] = 0x08;
14650 spec->private_adc_nids[1] = 0x11;
14651 spec->private_capsrc_nids[0] = 0x23;
14652 spec->private_capsrc_nids[1] = 0x22;
14653 } else {
14654 spec->private_adc_nids[0] = 0x11;
14655 spec->private_adc_nids[1] = 0x08;
14656 spec->private_capsrc_nids[0] = 0x22;
14657 spec->private_capsrc_nids[1] = 0x23;
14658 }
14659 spec->adc_nids = spec->private_adc_nids;
14660 spec->capsrc_nids = spec->private_capsrc_nids;
14661 spec->num_adc_nids = 2;
14662 spec->dual_adc_switch = 1;
14663 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14664 spec->adc_nids[0], spec->adc_nids[1]);
14665 return 1;
14666 }
14667 return 0;
14668}
14669
Takashi Iwaid433a672010-09-20 15:11:54 +020014670/* different alc269-variants */
14671enum {
14672 ALC269_TYPE_NORMAL,
Kailang Yang48c88e82010-11-23 08:56:16 +010014673 ALC269_TYPE_ALC258,
Takashi Iwaid433a672010-09-20 15:11:54 +020014674 ALC269_TYPE_ALC259,
Kailang Yang48c88e82010-11-23 08:56:16 +010014675 ALC269_TYPE_ALC269VB,
14676 ALC269_TYPE_ALC270,
Takashi Iwaid433a672010-09-20 15:11:54 +020014677 ALC269_TYPE_ALC271X,
14678};
14679
Kailang Yangf6a92242007-12-13 16:52:54 +010014680/*
14681 * BIOS auto configuration
14682 */
14683static int alc269_parse_auto_config(struct hda_codec *codec)
14684{
14685 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014686 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014687 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14688
14689 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14690 alc269_ignore);
14691 if (err < 0)
14692 return err;
14693
14694 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14695 if (err < 0)
14696 return err;
Takashi Iwaif3550d12010-09-20 15:09:03 +020014697 if (spec->codec_variant == ALC269_TYPE_NORMAL)
14698 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
14699 else
14700 err = alc_auto_create_input_ctls(codec, &spec->autocfg, 0,
14701 0x22, 0);
Kailang Yangf6a92242007-12-13 16:52:54 +010014702 if (err < 0)
14703 return err;
14704
14705 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14706
Takashi Iwai757899a2010-07-30 10:48:14 +020014707 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014708
Takashi Iwai603c4012008-07-30 15:01:44 +020014709 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014710 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014711
Takashi Iwaid433a672010-09-20 15:11:54 +020014712 if (spec->codec_variant != ALC269_TYPE_NORMAL) {
Kailang Yang84898e82010-02-04 14:16:14 +010014713 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014714 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014715 } else {
14716 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014717 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014718 }
14719
Kailang Yangf6a92242007-12-13 16:52:54 +010014720 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014721 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014722
14723 if (!alc275_setup_dual_adc(codec))
14724 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14725 sizeof(alc269_adc_candidates));
Takashi Iwai66946352010-03-29 17:21:45 +020014726
Kailang Yangf6a92242007-12-13 16:52:54 +010014727 err = alc_auto_add_mic_boost(codec);
14728 if (err < 0)
14729 return err;
14730
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014731 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014732 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014733
Kailang Yangf6a92242007-12-13 16:52:54 +010014734 return 1;
14735}
14736
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014737#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14738#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014739#define alc269_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaiae0ebbf2011-03-10 14:11:59 +010014740#define alc269_auto_init_input_src alc882_auto_init_input_src
Kailang Yangf6a92242007-12-13 16:52:54 +010014741
14742
14743/* init callback for auto-configuration model -- overriding the default init */
14744static void alc269_auto_init(struct hda_codec *codec)
14745{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014746 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014747 alc269_auto_init_multi_out(codec);
14748 alc269_auto_init_hp_out(codec);
14749 alc269_auto_init_analog_input(codec);
Takashi Iwaiae0ebbf2011-03-10 14:11:59 +010014750 if (!spec->dual_adc_switch)
14751 alc269_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014752 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014753 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014754 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014755}
14756
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014757static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
14758{
14759 int val = alc_read_coef_idx(codec, 0x04);
14760 if (power_up)
14761 val |= 1 << 11;
14762 else
14763 val &= ~(1 << 11);
14764 alc_write_coef_idx(codec, 0x04, val);
14765}
14766
Takashi Iwai5402e4c2011-04-07 10:39:25 +020014767static void alc269_shutup(struct hda_codec *codec)
Kailang Yang977ddd62010-09-15 10:02:29 +020014768{
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014769 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017)
14770 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014771 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014772 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014773 msleep(150);
14774 }
Kailang Yang977ddd62010-09-15 10:02:29 +020014775}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014776
Takashi Iwai5402e4c2011-04-07 10:39:25 +020014777#ifdef SND_HDA_NEEDS_RESUME
Kailang Yang977ddd62010-09-15 10:02:29 +020014778static int alc269_resume(struct hda_codec *codec)
14779{
Kailang Yang977ddd62010-09-15 10:02:29 +020014780 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014781 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014782 msleep(150);
14783 }
14784
14785 codec->patch_ops.init(codec);
14786
14787 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014788 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014789 msleep(200);
14790 }
14791
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014792 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018)
14793 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014794
14795 snd_hda_codec_resume_amp(codec);
14796 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +020014797 hda_call_check_power_status(codec, 0x01);
Kailang Yang977ddd62010-09-15 10:02:29 +020014798 return 0;
14799}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014800#endif /* SND_HDA_NEEDS_RESUME */
Kailang Yang977ddd62010-09-15 10:02:29 +020014801
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014802static void alc269_fixup_hweq(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014803 const struct alc_fixup *fix, int action)
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014804{
14805 int coef;
14806
Takashi Iwai58701122011-01-13 15:41:45 +010014807 if (action != ALC_FIXUP_ACT_INIT)
Takashi Iwai9fb1ef22011-01-13 14:40:43 +010014808 return;
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014809 coef = alc_read_coef_idx(codec, 0x1e);
14810 alc_write_coef_idx(codec, 0x1e, coef | 0x80);
14811}
14812
Takashi Iwai6981d182011-04-15 10:11:12 +020014813static void alc271_fixup_dmic(struct hda_codec *codec,
14814 const struct alc_fixup *fix, int action)
14815{
14816 static struct hda_verb verbs[] = {
14817 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14818 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14819 {}
14820 };
14821 unsigned int cfg;
14822
14823 if (strcmp(codec->chip_name, "ALC271X"))
14824 return;
14825 cfg = snd_hda_codec_get_pincfg(codec, 0x12);
14826 if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
14827 snd_hda_sequence_write(codec, verbs);
14828}
14829
Takashi Iwaiff818c22010-04-12 08:59:25 +020014830enum {
14831 ALC269_FIXUP_SONY_VAIO,
Takashi Iwai74dc8902011-01-13 14:14:41 +010014832 ALC275_FIXUP_SONY_VAIO_GPIO2,
David Henningsson145a9022010-09-16 10:07:53 +020014833 ALC269_FIXUP_DELL_M101Z,
David Henningsson022c92b2010-12-17 20:43:04 +010014834 ALC269_FIXUP_SKU_IGNORE,
David Henningssonac612402010-12-15 09:18:18 +010014835 ALC269_FIXUP_ASUS_G73JW,
Kailang Yang357f9152011-01-12 08:12:52 +010014836 ALC269_FIXUP_LENOVO_EAPD,
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014837 ALC275_FIXUP_SONY_HWEQ,
Takashi Iwai6981d182011-04-15 10:11:12 +020014838 ALC271_FIXUP_DMIC,
Takashi Iwaiff818c22010-04-12 08:59:25 +020014839};
14840
Takashi Iwaiff818c22010-04-12 08:59:25 +020014841static const struct alc_fixup alc269_fixups[] = {
14842 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014843 .type = ALC_FIXUP_VERBS,
14844 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020014845 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14846 {}
14847 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014848 },
Takashi Iwai74dc8902011-01-13 14:14:41 +010014849 [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014850 .type = ALC_FIXUP_VERBS,
14851 .v.verbs = (const struct hda_verb[]) {
Kailang Yang27855912010-12-21 09:09:53 +010014852 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
14853 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
14854 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
14855 { }
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014856 },
14857 .chained = true,
14858 .chain_id = ALC269_FIXUP_SONY_VAIO
Kailang Yang27855912010-12-21 09:09:53 +010014859 },
David Henningsson145a9022010-09-16 10:07:53 +020014860 [ALC269_FIXUP_DELL_M101Z] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014861 .type = ALC_FIXUP_VERBS,
14862 .v.verbs = (const struct hda_verb[]) {
David Henningsson145a9022010-09-16 10:07:53 +020014863 /* Enables internal speaker */
14864 {0x20, AC_VERB_SET_COEF_INDEX, 13},
14865 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
14866 {}
14867 }
14868 },
David Henningsson022c92b2010-12-17 20:43:04 +010014869 [ALC269_FIXUP_SKU_IGNORE] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014870 .type = ALC_FIXUP_SKU,
14871 .v.sku = ALC_FIXUP_SKU_IGNORE,
David Henningssonfe67b242010-12-15 08:01:46 +010014872 },
David Henningssonac612402010-12-15 09:18:18 +010014873 [ALC269_FIXUP_ASUS_G73JW] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014874 .type = ALC_FIXUP_PINS,
14875 .v.pins = (const struct alc_pincfg[]) {
David Henningssonac612402010-12-15 09:18:18 +010014876 { 0x17, 0x99130111 }, /* subwoofer */
14877 { }
14878 }
14879 },
Kailang Yang357f9152011-01-12 08:12:52 +010014880 [ALC269_FIXUP_LENOVO_EAPD] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014881 .type = ALC_FIXUP_VERBS,
14882 .v.verbs = (const struct hda_verb[]) {
Kailang Yang357f9152011-01-12 08:12:52 +010014883 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
14884 {}
14885 }
14886 },
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014887 [ALC275_FIXUP_SONY_HWEQ] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014888 .type = ALC_FIXUP_FUNC,
14889 .v.func = alc269_fixup_hweq,
14890 .chained = true,
14891 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
Takashi Iwai6981d182011-04-15 10:11:12 +020014892 },
14893 [ALC271_FIXUP_DMIC] = {
14894 .type = ALC_FIXUP_FUNC,
14895 .v.func = alc271_fixup_dmic,
14896 },
Takashi Iwaiff818c22010-04-12 08:59:25 +020014897};
14898
14899static struct snd_pci_quirk alc269_fixup_tbl[] = {
Takashi Iwai74dc8902011-01-13 14:14:41 +010014900 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014901 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
14902 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
Takashi Iwai7039c742010-12-23 16:35:34 +010014903 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningsson145a9022010-09-16 10:07:53 +020014904 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
Takashi Iwai6981d182011-04-15 10:11:12 +020014905 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
David Henningsson022c92b2010-12-17 20:43:04 +010014906 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
David Henningssonded9f522011-01-26 11:46:12 +010014907 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
14908 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
14909 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
14910 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
David Henningssonac612402010-12-15 09:18:18 +010014911 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
Kailang Yang357f9152011-01-12 08:12:52 +010014912 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014913 {}
14914};
14915
14916
Kailang Yangf6a92242007-12-13 16:52:54 +010014917/*
14918 * configuration and preset
14919 */
Takashi Iwaiea734962011-01-17 11:29:34 +010014920static const char * const alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014921 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014922 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014923 [ALC269_AMIC] = "laptop-amic",
14924 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014925 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014926 [ALC269_LIFEBOOK] = "lifebook",
14927 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014928};
14929
14930static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014931 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014932 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020014933 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014934 ALC269_AMIC),
14935 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14936 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14937 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14938 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14939 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14940 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14941 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14942 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14943 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
Chih-Wei Huangc790ad32011-02-25 11:14:31 +080014944 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269VB_AMIC),
Kailang Yang84898e82010-02-04 14:16:14 +010014945 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14946 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14947 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14948 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14949 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14950 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14951 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14952 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14953 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14954 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14955 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14956 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14957 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14958 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14959 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14960 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14961 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14962 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14963 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14964 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14965 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14966 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14967 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14968 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14969 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14970 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014971 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014972 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014973 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014974 ALC269_DMIC),
14975 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14976 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014977 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000014978 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014979 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14980 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14981 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14982 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14983 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14984 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014985 {}
14986};
14987
14988static struct alc_config_preset alc269_presets[] = {
14989 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014990 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010014991 .init_verbs = { alc269_init_verbs },
14992 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14993 .dac_nids = alc269_dac_nids,
14994 .hp_nid = 0x03,
14995 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14996 .channel_mode = alc269_modes,
14997 .input_mux = &alc269_capture_source,
14998 },
Kailang Yang60db6b52008-08-26 13:13:00 +020014999 [ALC269_QUANTA_FL1] = {
15000 .mixers = { alc269_quanta_fl1_mixer },
15001 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
15002 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15003 .dac_nids = alc269_dac_nids,
15004 .hp_nid = 0x03,
15005 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15006 .channel_mode = alc269_modes,
15007 .input_mux = &alc269_capture_source,
15008 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015009 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020015010 .init_hook = alc269_quanta_fl1_init_hook,
15011 },
Kailang Yang84898e82010-02-04 14:16:14 +010015012 [ALC269_AMIC] = {
15013 .mixers = { alc269_laptop_mixer },
15014 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020015015 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015016 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020015017 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15018 .dac_nids = alc269_dac_nids,
15019 .hp_nid = 0x03,
15020 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15021 .channel_mode = alc269_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015022 .unsol_event = alc_sku_unsol_event,
Kailang Yang84898e82010-02-04 14:16:14 +010015023 .setup = alc269_laptop_amic_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015024 .init_hook = alc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020015025 },
Kailang Yang84898e82010-02-04 14:16:14 +010015026 [ALC269_DMIC] = {
15027 .mixers = { alc269_laptop_mixer },
15028 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020015029 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015030 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020015031 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15032 .dac_nids = alc269_dac_nids,
15033 .hp_nid = 0x03,
15034 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15035 .channel_mode = alc269_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015036 .unsol_event = alc_sku_unsol_event,
Kailang Yang84898e82010-02-04 14:16:14 +010015037 .setup = alc269_laptop_dmic_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015038 .init_hook = alc_inithook,
Kailang Yang84898e82010-02-04 14:16:14 +010015039 },
15040 [ALC269VB_AMIC] = {
15041 .mixers = { alc269vb_laptop_mixer },
15042 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
15043 .init_verbs = { alc269vb_init_verbs,
15044 alc269vb_laptop_amic_init_verbs },
15045 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15046 .dac_nids = alc269_dac_nids,
15047 .hp_nid = 0x03,
15048 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15049 .channel_mode = alc269_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015050 .unsol_event = alc_sku_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020015051 .setup = alc269vb_laptop_amic_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015052 .init_hook = alc_inithook,
Kailang Yang84898e82010-02-04 14:16:14 +010015053 },
15054 [ALC269VB_DMIC] = {
15055 .mixers = { alc269vb_laptop_mixer },
15056 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
15057 .init_verbs = { alc269vb_init_verbs,
15058 alc269vb_laptop_dmic_init_verbs },
15059 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15060 .dac_nids = alc269_dac_nids,
15061 .hp_nid = 0x03,
15062 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15063 .channel_mode = alc269_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015064 .unsol_event = alc_sku_unsol_event,
Kailang Yang84898e82010-02-04 14:16:14 +010015065 .setup = alc269vb_laptop_dmic_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015066 .init_hook = alc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020015067 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010015068 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015069 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010015070 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010015071 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015072 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010015073 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15074 .dac_nids = alc269_dac_nids,
15075 .hp_nid = 0x03,
15076 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15077 .channel_mode = alc269_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015078 .unsol_event = alc_sku_unsol_event,
Kailang Yang84898e82010-02-04 14:16:14 +010015079 .setup = alc269_laptop_dmic_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015080 .init_hook = alc_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010015081 },
Tony Vroon64154832008-11-06 15:08:49 +000015082 [ALC269_LIFEBOOK] = {
15083 .mixers = { alc269_lifebook_mixer },
15084 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
15085 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15086 .dac_nids = alc269_dac_nids,
15087 .hp_nid = 0x03,
15088 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15089 .channel_mode = alc269_modes,
15090 .input_mux = &alc269_capture_source,
15091 .unsol_event = alc269_lifebook_unsol_event,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015092 .setup = alc269_lifebook_setup,
Tony Vroon64154832008-11-06 15:08:49 +000015093 .init_hook = alc269_lifebook_init_hook,
15094 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020015095 [ALC271_ACER] = {
15096 .mixers = { alc269_asus_mixer },
15097 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
15098 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
15099 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15100 .dac_nids = alc269_dac_nids,
15101 .adc_nids = alc262_dmic_adc_nids,
15102 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
15103 .capsrc_nids = alc262_dmic_capsrc_nids,
15104 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15105 .channel_mode = alc269_modes,
15106 .input_mux = &alc269_capture_source,
15107 .dig_out_nid = ALC880_DIGOUT_NID,
15108 .unsol_event = alc_sku_unsol_event,
15109 .setup = alc269vb_laptop_dmic_setup,
15110 .init_hook = alc_inithook,
15111 },
Kailang Yangf6a92242007-12-13 16:52:54 +010015112};
15113
Kailang Yang977ddd62010-09-15 10:02:29 +020015114static int alc269_fill_coef(struct hda_codec *codec)
15115{
15116 int val;
15117
15118 if ((alc_read_coef_idx(codec, 0) & 0x00ff) < 0x015) {
15119 alc_write_coef_idx(codec, 0xf, 0x960b);
15120 alc_write_coef_idx(codec, 0xe, 0x8817);
15121 }
15122
15123 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x016) {
15124 alc_write_coef_idx(codec, 0xf, 0x960b);
15125 alc_write_coef_idx(codec, 0xe, 0x8814);
15126 }
15127
15128 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
15129 val = alc_read_coef_idx(codec, 0x04);
15130 /* Power up output pin */
15131 alc_write_coef_idx(codec, 0x04, val | (1<<11));
15132 }
15133
15134 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
15135 val = alc_read_coef_idx(codec, 0xd);
15136 if ((val & 0x0c00) >> 10 != 0x1) {
15137 /* Capless ramp up clock control */
15138 alc_write_coef_idx(codec, 0xd, val | 1<<10);
15139 }
15140 val = alc_read_coef_idx(codec, 0x17);
15141 if ((val & 0x01c0) >> 6 != 0x4) {
15142 /* Class D power on reset */
15143 alc_write_coef_idx(codec, 0x17, val | 1<<7);
15144 }
15145 }
15146 return 0;
15147}
15148
Kailang Yangf6a92242007-12-13 16:52:54 +010015149static int patch_alc269(struct hda_codec *codec)
15150{
15151 struct alc_spec *spec;
Kailang Yang48c88e82010-11-23 08:56:16 +010015152 int board_config, coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010015153 int err;
15154
15155 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15156 if (spec == NULL)
15157 return -ENOMEM;
15158
15159 codec->spec = spec;
15160
Kailang Yangda00c242010-03-19 11:23:45 +010015161 alc_auto_parse_customize_define(codec);
15162
Kailang Yangc793bec2010-12-21 09:14:13 +010015163 if (codec->vendor_id == 0x10ec0269) {
15164 coef = alc_read_coef_idx(codec, 0);
15165 if ((coef & 0x00f0) == 0x0010) {
15166 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
15167 spec->cdefine.platform_type == 1) {
15168 alc_codec_rename(codec, "ALC271X");
15169 spec->codec_variant = ALC269_TYPE_ALC271X;
15170 } else if ((coef & 0xf000) == 0x1000) {
15171 spec->codec_variant = ALC269_TYPE_ALC270;
15172 } else if ((coef & 0xf000) == 0x2000) {
15173 alc_codec_rename(codec, "ALC259");
15174 spec->codec_variant = ALC269_TYPE_ALC259;
15175 } else if ((coef & 0xf000) == 0x3000) {
15176 alc_codec_rename(codec, "ALC258");
15177 spec->codec_variant = ALC269_TYPE_ALC258;
15178 } else {
15179 alc_codec_rename(codec, "ALC269VB");
15180 spec->codec_variant = ALC269_TYPE_ALC269VB;
15181 }
15182 } else
15183 alc_fix_pll_init(codec, 0x20, 0x04, 15);
15184 alc269_fill_coef(codec);
15185 }
Kailang Yang977ddd62010-09-15 10:02:29 +020015186
Kailang Yangf6a92242007-12-13 16:52:54 +010015187 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
15188 alc269_models,
15189 alc269_cfg_tbl);
15190
15191 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015192 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15193 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010015194 board_config = ALC269_AUTO;
15195 }
15196
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010015197 if (board_config == ALC269_AUTO) {
15198 alc_pick_fixup(codec, NULL, alc269_fixup_tbl, alc269_fixups);
15199 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
15200 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020015201
Kailang Yangf6a92242007-12-13 16:52:54 +010015202 if (board_config == ALC269_AUTO) {
15203 /* automatic parse from the BIOS config */
15204 err = alc269_parse_auto_config(codec);
15205 if (err < 0) {
15206 alc_free(codec);
15207 return err;
15208 } else if (!err) {
15209 printk(KERN_INFO
15210 "hda_codec: Cannot set up configuration "
15211 "from BIOS. Using base mode...\n");
15212 board_config = ALC269_BASIC;
15213 }
15214 }
15215
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015216 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020015217 err = snd_hda_attach_beep_device(codec, 0x1);
15218 if (err < 0) {
15219 alc_free(codec);
15220 return err;
15221 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015222 }
15223
Kailang Yangf6a92242007-12-13 16:52:54 +010015224 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015225 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010015226
Kailang Yang84898e82010-02-04 14:16:14 +010015227 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010015228 /* Due to a hardware problem on Lenovo Ideadpad, we need to
15229 * fix the sample rate of analog I/O to 44.1kHz
15230 */
15231 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
15232 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020015233 } else if (spec->dual_adc_switch) {
15234 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15235 /* switch ADC dynamically */
15236 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010015237 } else {
15238 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15239 spec->stream_analog_capture = &alc269_pcm_analog_capture;
15240 }
Kailang Yangf6a92242007-12-13 16:52:54 +010015241 spec->stream_digital_playback = &alc269_pcm_digital_playback;
15242 spec->stream_digital_capture = &alc269_pcm_digital_capture;
15243
Takashi Iwai66946352010-03-29 17:21:45 +020015244 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
Kailang Yang1657cbd2010-11-23 08:53:32 +010015245 if (spec->codec_variant == ALC269_TYPE_NORMAL) {
Takashi Iwai66946352010-03-29 17:21:45 +020015246 spec->adc_nids = alc269_adc_nids;
15247 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
15248 spec->capsrc_nids = alc269_capsrc_nids;
15249 } else {
15250 spec->adc_nids = alc269vb_adc_nids;
15251 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
15252 spec->capsrc_nids = alc269vb_capsrc_nids;
15253 }
Kailang Yang84898e82010-02-04 14:16:14 +010015254 }
15255
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015256 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015257 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015258 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010015259 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010015260
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010015261 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwaiff818c22010-04-12 08:59:25 +020015262
Takashi Iwai100d5eb2009-08-10 11:55:51 +020015263 spec->vmaster_nid = 0x02;
15264
Kailang Yangf6a92242007-12-13 16:52:54 +010015265 codec->patch_ops = alc_patch_ops;
Kailang Yang977ddd62010-09-15 10:02:29 +020015266#ifdef SND_HDA_NEEDS_RESUME
15267 codec->patch_ops.resume = alc269_resume;
15268#endif
Kailang Yangf6a92242007-12-13 16:52:54 +010015269 if (board_config == ALC269_AUTO)
15270 spec->init_hook = alc269_auto_init;
Takashi Iwai5402e4c2011-04-07 10:39:25 +020015271 spec->shutup = alc269_shutup;
Kailang Yangbf1b0222010-10-21 08:49:56 +020015272
15273 alc_init_jacks(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010015274#ifdef CONFIG_SND_HDA_POWER_SAVE
15275 if (!spec->loopback.amplist)
15276 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020015277 if (alc269_mic2_for_mute_led(codec))
15278 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010015279#endif
15280
15281 return 0;
15282}
15283
15284/*
Kailang Yangdf694da2005-12-05 19:42:22 +010015285 * ALC861 channel source setting (2/6 channel selection for 3-stack)
15286 */
15287
15288/*
15289 * set the path ways for 2 channel output
15290 * need to set the codec line out and mic 1 pin widgets to inputs
15291 */
15292static struct hda_verb alc861_threestack_ch2_init[] = {
15293 /* set pin widget 1Ah (line in) for input */
15294 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015295 /* set pin widget 18h (mic1/2) for input, for mic also enable
15296 * the vref
15297 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015298 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15299
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015300 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15301#if 0
15302 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15303 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15304#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015305 { } /* end */
15306};
15307/*
15308 * 6ch mode
15309 * need to set the codec line out and mic 1 pin widgets to outputs
15310 */
15311static struct hda_verb alc861_threestack_ch6_init[] = {
15312 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15313 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15314 /* set pin widget 18h (mic1) for output (CLFE)*/
15315 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15316
15317 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015318 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015319
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015320 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15321#if 0
15322 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15323 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15324#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015325 { } /* end */
15326};
15327
15328static struct hda_channel_mode alc861_threestack_modes[2] = {
15329 { 2, alc861_threestack_ch2_init },
15330 { 6, alc861_threestack_ch6_init },
15331};
Takashi Iwai22309c32006-08-09 16:57:28 +020015332/* Set mic1 as input and unmute the mixer */
15333static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
15334 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15335 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15336 { } /* end */
15337};
15338/* Set mic1 as output and mute mixer */
15339static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
15340 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15341 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15342 { } /* end */
15343};
15344
15345static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
15346 { 2, alc861_uniwill_m31_ch2_init },
15347 { 4, alc861_uniwill_m31_ch4_init },
15348};
Kailang Yangdf694da2005-12-05 19:42:22 +010015349
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015350/* Set mic1 and line-in as input and unmute the mixer */
15351static struct hda_verb alc861_asus_ch2_init[] = {
15352 /* set pin widget 1Ah (line in) for input */
15353 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015354 /* set pin widget 18h (mic1/2) for input, for mic also enable
15355 * the vref
15356 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015357 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15358
15359 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15360#if 0
15361 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15362 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15363#endif
15364 { } /* end */
15365};
15366/* Set mic1 nad line-in as output and mute mixer */
15367static struct hda_verb alc861_asus_ch6_init[] = {
15368 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15369 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15370 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15371 /* set pin widget 18h (mic1) for output (CLFE)*/
15372 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15373 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15374 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
15375 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
15376
15377 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15378#if 0
15379 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15380 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15381#endif
15382 { } /* end */
15383};
15384
15385static struct hda_channel_mode alc861_asus_modes[2] = {
15386 { 2, alc861_asus_ch2_init },
15387 { 6, alc861_asus_ch6_init },
15388};
15389
Kailang Yangdf694da2005-12-05 19:42:22 +010015390/* patch-ALC861 */
15391
15392static struct snd_kcontrol_new alc861_base_mixer[] = {
15393 /* output mixer control */
15394 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15395 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15396 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15397 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15398 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15399
15400 /*Input mixer control */
15401 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15402 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15403 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15404 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15405 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15406 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15407 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15408 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15409 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15410 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015411
Kailang Yangdf694da2005-12-05 19:42:22 +010015412 { } /* end */
15413};
15414
15415static struct snd_kcontrol_new alc861_3ST_mixer[] = {
15416 /* output mixer control */
15417 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15418 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15419 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15420 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15421 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15422
15423 /* Input mixer control */
15424 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15425 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15426 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15427 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15428 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15429 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15430 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15431 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15432 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15433 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015434
Kailang Yangdf694da2005-12-05 19:42:22 +010015435 {
15436 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15437 .name = "Channel Mode",
15438 .info = alc_ch_mode_info,
15439 .get = alc_ch_mode_get,
15440 .put = alc_ch_mode_put,
15441 .private_value = ARRAY_SIZE(alc861_threestack_modes),
15442 },
15443 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015444};
15445
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015446static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015447 /* output mixer control */
15448 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15449 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15450 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015451
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015452 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015453};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015454
Takashi Iwai22309c32006-08-09 16:57:28 +020015455static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
15456 /* output mixer control */
15457 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15458 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15459 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15460 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15461 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15462
15463 /* Input mixer control */
15464 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15465 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15466 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15467 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15468 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15469 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15470 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15471 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15472 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15473 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015474
Takashi Iwai22309c32006-08-09 16:57:28 +020015475 {
15476 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15477 .name = "Channel Mode",
15478 .info = alc_ch_mode_info,
15479 .get = alc_ch_mode_get,
15480 .put = alc_ch_mode_put,
15481 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
15482 },
15483 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015484};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015485
15486static struct snd_kcontrol_new alc861_asus_mixer[] = {
15487 /* output mixer control */
15488 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15489 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15490 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15491 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15492 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15493
15494 /* Input mixer control */
15495 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15496 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15497 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15498 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15499 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15500 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15501 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15502 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15503 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015504 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
15505
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015506 {
15507 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15508 .name = "Channel Mode",
15509 .info = alc_ch_mode_info,
15510 .get = alc_ch_mode_get,
15511 .put = alc_ch_mode_put,
15512 .private_value = ARRAY_SIZE(alc861_asus_modes),
15513 },
15514 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015515};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015516
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015517/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015518static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015519 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15520 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015521 { }
15522};
15523
Kailang Yangdf694da2005-12-05 19:42:22 +010015524/*
15525 * generic initialization of ADC, input mixers and output mixers
15526 */
15527static struct hda_verb alc861_base_init_verbs[] = {
15528 /*
15529 * Unmute ADC0 and set the default input to mic-in
15530 */
15531 /* port-A for surround (rear panel) */
15532 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15533 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
15534 /* port-B for mic-in (rear panel) with vref */
15535 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15536 /* port-C for line-in (rear panel) */
15537 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15538 /* port-D for Front */
15539 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15540 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15541 /* port-E for HP out (front panel) */
15542 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15543 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015544 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015545 /* port-F for mic-in (front panel) with vref */
15546 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15547 /* port-G for CLFE (rear panel) */
15548 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15549 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15550 /* port-H for side (rear panel) */
15551 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15552 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15553 /* CD-in */
15554 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15555 /* route front mic to ADC1*/
15556 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15557 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015558
Kailang Yangdf694da2005-12-05 19:42:22 +010015559 /* Unmute DAC0~3 & spdif out*/
15560 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15561 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15562 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15563 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15564 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015565
Kailang Yangdf694da2005-12-05 19:42:22 +010015566 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15567 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15568 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15569 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15570 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015571
Kailang Yangdf694da2005-12-05 19:42:22 +010015572 /* Unmute Stereo Mixer 15 */
15573 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15574 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15575 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015576 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015577
15578 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15579 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15580 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15581 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15582 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15583 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15584 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15585 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015586 /* hp used DAC 3 (Front) */
15587 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015588 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15589
15590 { }
15591};
15592
15593static struct hda_verb alc861_threestack_init_verbs[] = {
15594 /*
15595 * Unmute ADC0 and set the default input to mic-in
15596 */
15597 /* port-A for surround (rear panel) */
15598 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15599 /* port-B for mic-in (rear panel) with vref */
15600 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15601 /* port-C for line-in (rear panel) */
15602 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15603 /* port-D for Front */
15604 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15605 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15606 /* port-E for HP out (front panel) */
15607 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15608 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015609 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015610 /* port-F for mic-in (front panel) with vref */
15611 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15612 /* port-G for CLFE (rear panel) */
15613 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15614 /* port-H for side (rear panel) */
15615 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15616 /* CD-in */
15617 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15618 /* route front mic to ADC1*/
15619 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15620 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15621 /* Unmute DAC0~3 & spdif out*/
15622 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15623 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15624 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15625 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15626 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015627
Kailang Yangdf694da2005-12-05 19:42:22 +010015628 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15629 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15630 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15631 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15632 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015633
Kailang Yangdf694da2005-12-05 19:42:22 +010015634 /* Unmute Stereo Mixer 15 */
15635 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15636 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15637 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015638 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015639
15640 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15641 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15642 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15643 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15644 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15645 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15646 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15647 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015648 /* hp used DAC 3 (Front) */
15649 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015650 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15651 { }
15652};
Takashi Iwai22309c32006-08-09 16:57:28 +020015653
15654static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
15655 /*
15656 * Unmute ADC0 and set the default input to mic-in
15657 */
15658 /* port-A for surround (rear panel) */
15659 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15660 /* port-B for mic-in (rear panel) with vref */
15661 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15662 /* port-C for line-in (rear panel) */
15663 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15664 /* port-D for Front */
15665 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15666 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15667 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015668 /* this has to be set to VREF80 */
15669 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015670 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015671 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015672 /* port-F for mic-in (front panel) with vref */
15673 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15674 /* port-G for CLFE (rear panel) */
15675 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15676 /* port-H for side (rear panel) */
15677 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15678 /* CD-in */
15679 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15680 /* route front mic to ADC1*/
15681 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15682 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15683 /* Unmute DAC0~3 & spdif out*/
15684 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15685 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15686 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15687 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15688 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015689
Takashi Iwai22309c32006-08-09 16:57:28 +020015690 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15691 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15692 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15693 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15694 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015695
Takashi Iwai22309c32006-08-09 16:57:28 +020015696 /* Unmute Stereo Mixer 15 */
15697 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15698 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15699 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015700 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015701
15702 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15703 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15704 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15705 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15706 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15707 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15708 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15709 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015710 /* hp used DAC 3 (Front) */
15711 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015712 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15713 { }
15714};
15715
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015716static struct hda_verb alc861_asus_init_verbs[] = {
15717 /*
15718 * Unmute ADC0 and set the default input to mic-in
15719 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015720 /* port-A for surround (rear panel)
15721 * according to codec#0 this is the HP jack
15722 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015723 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15724 /* route front PCM to HP */
15725 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15726 /* port-B for mic-in (rear panel) with vref */
15727 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15728 /* port-C for line-in (rear panel) */
15729 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15730 /* port-D for Front */
15731 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15732 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15733 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015734 /* this has to be set to VREF80 */
15735 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015736 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015737 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015738 /* port-F for mic-in (front panel) with vref */
15739 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15740 /* port-G for CLFE (rear panel) */
15741 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15742 /* port-H for side (rear panel) */
15743 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15744 /* CD-in */
15745 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15746 /* route front mic to ADC1*/
15747 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15748 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15749 /* Unmute DAC0~3 & spdif out*/
15750 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15751 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15752 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15753 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15754 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15755 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15756 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15757 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15758 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15759 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015760
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015761 /* Unmute Stereo Mixer 15 */
15762 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15763 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15764 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015765 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015766
15767 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15768 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15769 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15770 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15771 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15772 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15773 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15774 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015775 /* hp used DAC 3 (Front) */
15776 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015777 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15778 { }
15779};
15780
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015781/* additional init verbs for ASUS laptops */
15782static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15783 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15784 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15785 { }
15786};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015787
Kailang Yangdf694da2005-12-05 19:42:22 +010015788/*
15789 * generic initialization of ADC, input mixers and output mixers
15790 */
15791static struct hda_verb alc861_auto_init_verbs[] = {
15792 /*
15793 * Unmute ADC0 and set the default input to mic-in
15794 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015795 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015796 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015797
Kailang Yangdf694da2005-12-05 19:42:22 +010015798 /* Unmute DAC0~3 & spdif out*/
15799 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15800 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15801 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15802 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15803 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015804
Kailang Yangdf694da2005-12-05 19:42:22 +010015805 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15806 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15807 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15808 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15809 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015810
Kailang Yangdf694da2005-12-05 19:42:22 +010015811 /* Unmute Stereo Mixer 15 */
15812 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15813 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15814 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15815 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15816
Takashi Iwai1c209302009-07-22 15:17:45 +020015817 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15818 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15819 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15820 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15821 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15822 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15823 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15824 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015825
15826 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15827 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015828 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15829 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015830 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15831 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015832 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15833 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015834
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015835 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015836
15837 { }
15838};
15839
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015840static struct hda_verb alc861_toshiba_init_verbs[] = {
15841 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015842
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015843 { }
15844};
15845
15846/* toggle speaker-output according to the hp-jack state */
15847static void alc861_toshiba_automute(struct hda_codec *codec)
15848{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015849 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015850
Takashi Iwai47fd8302007-08-10 17:11:07 +020015851 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15852 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15853 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15854 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015855}
15856
15857static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15858 unsigned int res)
15859{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015860 if ((res >> 26) == ALC880_HP_EVENT)
15861 alc861_toshiba_automute(codec);
15862}
15863
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015864/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015865#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15866#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15867#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15868#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15869
15870
15871#define ALC861_DIGOUT_NID 0x07
15872
15873static struct hda_channel_mode alc861_8ch_modes[1] = {
15874 { 8, NULL }
15875};
15876
15877static hda_nid_t alc861_dac_nids[4] = {
15878 /* front, surround, clfe, side */
15879 0x03, 0x06, 0x05, 0x04
15880};
15881
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015882static hda_nid_t alc660_dac_nids[3] = {
15883 /* front, clfe, surround */
15884 0x03, 0x05, 0x06
15885};
15886
Kailang Yangdf694da2005-12-05 19:42:22 +010015887static hda_nid_t alc861_adc_nids[1] = {
15888 /* ADC0-2 */
15889 0x08,
15890};
15891
15892static struct hda_input_mux alc861_capture_source = {
15893 .num_items = 5,
15894 .items = {
15895 { "Mic", 0x0 },
15896 { "Front Mic", 0x3 },
15897 { "Line", 0x1 },
15898 { "CD", 0x4 },
15899 { "Mixer", 0x5 },
15900 },
15901};
15902
Takashi Iwai1c209302009-07-22 15:17:45 +020015903static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15904{
15905 struct alc_spec *spec = codec->spec;
15906 hda_nid_t mix, srcs[5];
15907 int i, j, num;
15908
15909 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15910 return 0;
15911 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15912 if (num < 0)
15913 return 0;
15914 for (i = 0; i < num; i++) {
15915 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015916 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015917 if (type != AC_WID_AUD_OUT)
15918 continue;
15919 for (j = 0; j < spec->multiout.num_dacs; j++)
15920 if (spec->multiout.dac_nids[j] == srcs[i])
15921 break;
15922 if (j >= spec->multiout.num_dacs)
15923 return srcs[i];
15924 }
15925 return 0;
15926}
15927
Kailang Yangdf694da2005-12-05 19:42:22 +010015928/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015929static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015930 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015931{
Takashi Iwai1c209302009-07-22 15:17:45 +020015932 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015933 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015934 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015935
15936 spec->multiout.dac_nids = spec->private_dac_nids;
15937 for (i = 0; i < cfg->line_outs; i++) {
15938 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015939 dac = alc861_look_for_dac(codec, nid);
15940 if (!dac)
15941 continue;
15942 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015943 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015944 return 0;
15945}
15946
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015947static int __alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15948 hda_nid_t nid, int idx, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015949{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015950 return __add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx, idx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015951 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15952}
15953
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015954#define alc861_create_out_sw(codec, pfx, nid, chs) \
15955 __alc861_create_out_sw(codec, pfx, nid, 0, chs)
15956
Takashi Iwai1c209302009-07-22 15:17:45 +020015957/* add playback controls from the parsed DAC table */
15958static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15959 const struct auto_pin_cfg *cfg)
15960{
15961 struct alc_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +010015962 static const char * const chname[4] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015963 "Front", "Surround", NULL /*CLFE*/, "Side"
15964 };
Takashi Iwaice764ab2011-04-27 16:35:23 +020015965 const char *pfx = alc_get_line_out_pfx(spec, true);
Kailang Yangdf694da2005-12-05 19:42:22 +010015966 hda_nid_t nid;
Takashi Iwaice764ab2011-04-27 16:35:23 +020015967 int i, err, noutputs;
Takashi Iwai1c209302009-07-22 15:17:45 +020015968
Takashi Iwaice764ab2011-04-27 16:35:23 +020015969 noutputs = cfg->line_outs;
15970 if (spec->multi_ios > 0)
15971 noutputs += spec->multi_ios;
15972
15973 for (i = 0; i < noutputs; i++) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015974 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015975 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015976 continue;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015977 if (!pfx && i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015978 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015979 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015980 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015981 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015982 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015983 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015984 return err;
15985 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015986 const char *name = pfx;
David Henningsson5a882642011-03-23 08:35:07 +010015987 int index = i;
15988 if (!name) {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015989 name = chname[i];
David Henningsson5a882642011-03-23 08:35:07 +010015990 index = 0;
15991 }
15992 err = __alc861_create_out_sw(codec, name, nid, index, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015993 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015994 return err;
15995 }
15996 }
15997 return 0;
15998}
15999
Takashi Iwai1c209302009-07-22 15:17:45 +020016000static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010016001{
Takashi Iwai1c209302009-07-22 15:17:45 +020016002 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016003 int err;
16004 hda_nid_t nid;
16005
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016006 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010016007 return 0;
16008
16009 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020016010 nid = alc861_look_for_dac(codec, pin);
16011 if (nid) {
16012 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
16013 if (err < 0)
16014 return err;
16015 spec->multiout.hp_nid = nid;
16016 }
Kailang Yangdf694da2005-12-05 19:42:22 +010016017 }
16018 return 0;
16019}
16020
16021/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016022static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016023 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010016024{
Takashi Iwai05f5f472009-08-25 13:10:18 +020016025 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010016026}
16027
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016028static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
16029 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020016030 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010016031{
Takashi Iwai1c209302009-07-22 15:17:45 +020016032 hda_nid_t mix, srcs[5];
16033 int i, num;
16034
Jacek Luczak564c5be2008-05-03 18:41:23 +020016035 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
16036 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020016037 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020016038 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020016039 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
16040 return;
16041 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
16042 if (num < 0)
16043 return;
16044 for (i = 0; i < num; i++) {
16045 unsigned int mute;
16046 if (srcs[i] == dac || srcs[i] == 0x15)
16047 mute = AMP_IN_UNMUTE(i);
16048 else
16049 mute = AMP_IN_MUTE(i);
16050 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16051 mute);
16052 }
Kailang Yangdf694da2005-12-05 19:42:22 +010016053}
16054
16055static void alc861_auto_init_multi_out(struct hda_codec *codec)
16056{
16057 struct alc_spec *spec = codec->spec;
16058 int i;
16059
16060 for (i = 0; i < spec->autocfg.line_outs; i++) {
16061 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016062 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010016063 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016064 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016065 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016066 }
16067}
16068
16069static void alc861_auto_init_hp_out(struct hda_codec *codec)
16070{
16071 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016072
Takashi Iwai15870f02009-10-05 08:25:13 +020016073 if (spec->autocfg.hp_outs)
16074 alc861_auto_set_output_and_unmute(codec,
16075 spec->autocfg.hp_pins[0],
16076 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020016077 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020016078 if (spec->autocfg.speaker_outs)
16079 alc861_auto_set_output_and_unmute(codec,
16080 spec->autocfg.speaker_pins[0],
16081 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020016082 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016083}
16084
16085static void alc861_auto_init_analog_input(struct hda_codec *codec)
16086{
16087 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016088 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +010016089 int i;
16090
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016091 for (i = 0; i < cfg->num_inputs; i++) {
16092 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai23f0c042009-02-26 13:03:58 +010016093 if (nid >= 0x0c && nid <= 0x11)
Takashi Iwai30ea0982010-09-16 18:47:56 +020016094 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Kailang Yangdf694da2005-12-05 19:42:22 +010016095 }
16096}
16097
16098/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016099/* return 1 if successful, 0 if the proper config is not found,
16100 * or a negative error code
16101 */
Kailang Yangdf694da2005-12-05 19:42:22 +010016102static int alc861_parse_auto_config(struct hda_codec *codec)
16103{
16104 struct alc_spec *spec = codec->spec;
16105 int err;
16106 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
16107
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016108 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16109 alc861_ignore);
16110 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016111 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016112 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010016113 return 0; /* can't find valid BIOS pin config */
16114
Takashi Iwai1c209302009-07-22 15:17:45 +020016115 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016116 if (err < 0)
16117 return err;
Takashi Iwaice764ab2011-04-27 16:35:23 +020016118 err = alc_auto_add_multi_channel_mode(codec);
16119 if (err < 0)
16120 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016121 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016122 if (err < 0)
16123 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016124 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016125 if (err < 0)
16126 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016127 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016128 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016129 return err;
16130
16131 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16132
Takashi Iwai757899a2010-07-30 10:48:14 +020016133 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016134
Takashi Iwai603c4012008-07-30 15:01:44 +020016135 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016136 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010016137
Takashi Iwaid88897e2008-10-31 15:01:37 +010016138 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010016139
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020016140 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016141 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010016142
16143 spec->adc_nids = alc861_adc_nids;
16144 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016145 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016146
Kailang Yang6227cdc2010-02-25 08:36:52 +010016147 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016148
Kailang Yangdf694da2005-12-05 19:42:22 +010016149 return 1;
16150}
16151
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016152/* additional initialization for auto-configuration model */
16153static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010016154{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016155 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016156 alc861_auto_init_multi_out(codec);
16157 alc861_auto_init_hp_out(codec);
16158 alc861_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020016159 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016160 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016161 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016162}
16163
Takashi Iwaicb53c622007-08-10 17:21:45 +020016164#ifdef CONFIG_SND_HDA_POWER_SAVE
16165static struct hda_amp_list alc861_loopbacks[] = {
16166 { 0x15, HDA_INPUT, 0 },
16167 { 0x15, HDA_INPUT, 1 },
16168 { 0x15, HDA_INPUT, 2 },
16169 { 0x15, HDA_INPUT, 3 },
16170 { } /* end */
16171};
16172#endif
16173
Kailang Yangdf694da2005-12-05 19:42:22 +010016174
16175/*
16176 * configuration and preset
16177 */
Takashi Iwaiea734962011-01-17 11:29:34 +010016178static const char * const alc861_models[ALC861_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016179 [ALC861_3ST] = "3stack",
16180 [ALC660_3ST] = "3stack-660",
16181 [ALC861_3ST_DIG] = "3stack-dig",
16182 [ALC861_6ST_DIG] = "6stack-dig",
16183 [ALC861_UNIWILL_M31] = "uniwill-m31",
16184 [ALC861_TOSHIBA] = "toshiba",
16185 [ALC861_ASUS] = "asus",
16186 [ALC861_ASUS_LAPTOP] = "asus-laptop",
16187 [ALC861_AUTO] = "auto",
16188};
16189
16190static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010016191 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016192 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16193 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16194 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016195 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020016196 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010016197 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020016198 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
16199 * Any other models that need this preset?
16200 */
16201 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020016202 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
16203 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016204 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
16205 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
16206 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
16207 /* FIXME: the below seems conflict */
16208 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
16209 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
16210 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010016211 {}
16212};
16213
16214static struct alc_config_preset alc861_presets[] = {
16215 [ALC861_3ST] = {
16216 .mixers = { alc861_3ST_mixer },
16217 .init_verbs = { alc861_threestack_init_verbs },
16218 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16219 .dac_nids = alc861_dac_nids,
16220 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16221 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016222 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016223 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16224 .adc_nids = alc861_adc_nids,
16225 .input_mux = &alc861_capture_source,
16226 },
16227 [ALC861_3ST_DIG] = {
16228 .mixers = { alc861_base_mixer },
16229 .init_verbs = { alc861_threestack_init_verbs },
16230 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16231 .dac_nids = alc861_dac_nids,
16232 .dig_out_nid = ALC861_DIGOUT_NID,
16233 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16234 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016235 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016236 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16237 .adc_nids = alc861_adc_nids,
16238 .input_mux = &alc861_capture_source,
16239 },
16240 [ALC861_6ST_DIG] = {
16241 .mixers = { alc861_base_mixer },
16242 .init_verbs = { alc861_base_init_verbs },
16243 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16244 .dac_nids = alc861_dac_nids,
16245 .dig_out_nid = ALC861_DIGOUT_NID,
16246 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
16247 .channel_mode = alc861_8ch_modes,
16248 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16249 .adc_nids = alc861_adc_nids,
16250 .input_mux = &alc861_capture_source,
16251 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016252 [ALC660_3ST] = {
16253 .mixers = { alc861_3ST_mixer },
16254 .init_verbs = { alc861_threestack_init_verbs },
16255 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
16256 .dac_nids = alc660_dac_nids,
16257 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16258 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016259 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016260 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16261 .adc_nids = alc861_adc_nids,
16262 .input_mux = &alc861_capture_source,
16263 },
Takashi Iwai22309c32006-08-09 16:57:28 +020016264 [ALC861_UNIWILL_M31] = {
16265 .mixers = { alc861_uniwill_m31_mixer },
16266 .init_verbs = { alc861_uniwill_m31_init_verbs },
16267 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16268 .dac_nids = alc861_dac_nids,
16269 .dig_out_nid = ALC861_DIGOUT_NID,
16270 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
16271 .channel_mode = alc861_uniwill_m31_modes,
16272 .need_dac_fix = 1,
16273 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16274 .adc_nids = alc861_adc_nids,
16275 .input_mux = &alc861_capture_source,
16276 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016277 [ALC861_TOSHIBA] = {
16278 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016279 .init_verbs = { alc861_base_init_verbs,
16280 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016281 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16282 .dac_nids = alc861_dac_nids,
16283 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16284 .channel_mode = alc883_3ST_2ch_modes,
16285 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16286 .adc_nids = alc861_adc_nids,
16287 .input_mux = &alc861_capture_source,
16288 .unsol_event = alc861_toshiba_unsol_event,
16289 .init_hook = alc861_toshiba_automute,
16290 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020016291 [ALC861_ASUS] = {
16292 .mixers = { alc861_asus_mixer },
16293 .init_verbs = { alc861_asus_init_verbs },
16294 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16295 .dac_nids = alc861_dac_nids,
16296 .dig_out_nid = ALC861_DIGOUT_NID,
16297 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
16298 .channel_mode = alc861_asus_modes,
16299 .need_dac_fix = 1,
16300 .hp_nid = 0x06,
16301 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16302 .adc_nids = alc861_adc_nids,
16303 .input_mux = &alc861_capture_source,
16304 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010016305 [ALC861_ASUS_LAPTOP] = {
16306 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
16307 .init_verbs = { alc861_asus_init_verbs,
16308 alc861_asus_laptop_init_verbs },
16309 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16310 .dac_nids = alc861_dac_nids,
16311 .dig_out_nid = ALC861_DIGOUT_NID,
16312 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16313 .channel_mode = alc883_3ST_2ch_modes,
16314 .need_dac_fix = 1,
16315 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16316 .adc_nids = alc861_adc_nids,
16317 .input_mux = &alc861_capture_source,
16318 },
16319};
Kailang Yangdf694da2005-12-05 19:42:22 +010016320
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016321/* Pin config fixes */
16322enum {
16323 PINFIX_FSC_AMILO_PI1505,
16324};
16325
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016326static const struct alc_fixup alc861_fixups[] = {
16327 [PINFIX_FSC_AMILO_PI1505] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016328 .type = ALC_FIXUP_PINS,
16329 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020016330 { 0x0b, 0x0221101f }, /* HP */
16331 { 0x0f, 0x90170310 }, /* speaker */
16332 { }
16333 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016334 },
16335};
16336
16337static struct snd_pci_quirk alc861_fixup_tbl[] = {
16338 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
16339 {}
16340};
Kailang Yangdf694da2005-12-05 19:42:22 +010016341
16342static int patch_alc861(struct hda_codec *codec)
16343{
16344 struct alc_spec *spec;
16345 int board_config;
16346 int err;
16347
Robert P. J. Daydc041e02006-12-19 14:44:15 +010016348 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010016349 if (spec == NULL)
16350 return -ENOMEM;
16351
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016352 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016353
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016354 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
16355 alc861_models,
16356 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016357
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016358 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016359 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16360 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010016361 board_config = ALC861_AUTO;
16362 }
16363
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016364 if (board_config == ALC861_AUTO) {
16365 alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
16366 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
16367 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016368
Kailang Yangdf694da2005-12-05 19:42:22 +010016369 if (board_config == ALC861_AUTO) {
16370 /* automatic parse from the BIOS config */
16371 err = alc861_parse_auto_config(codec);
16372 if (err < 0) {
16373 alc_free(codec);
16374 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016375 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016376 printk(KERN_INFO
16377 "hda_codec: Cannot set up configuration "
16378 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010016379 board_config = ALC861_3ST_DIG;
16380 }
16381 }
16382
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016383 err = snd_hda_attach_beep_device(codec, 0x23);
16384 if (err < 0) {
16385 alc_free(codec);
16386 return err;
16387 }
16388
Kailang Yangdf694da2005-12-05 19:42:22 +010016389 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016390 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016391
Kailang Yangdf694da2005-12-05 19:42:22 +010016392 spec->stream_analog_playback = &alc861_pcm_analog_playback;
16393 spec->stream_analog_capture = &alc861_pcm_analog_capture;
16394
Kailang Yangdf694da2005-12-05 19:42:22 +010016395 spec->stream_digital_playback = &alc861_pcm_digital_playback;
16396 spec->stream_digital_capture = &alc861_pcm_digital_capture;
16397
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010016398 if (!spec->cap_mixer)
16399 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016400 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
16401
Takashi Iwai2134ea42008-01-10 16:53:55 +010016402 spec->vmaster_nid = 0x03;
16403
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016404 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016405
Kailang Yangdf694da2005-12-05 19:42:22 +010016406 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050016407 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016408 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016409#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050016410 spec->power_hook = alc_power_eapd;
16411#endif
16412 }
16413#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020016414 if (!spec->loopback.amplist)
16415 spec->loopback.amplist = alc861_loopbacks;
16416#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020016417
Kailang Yangdf694da2005-12-05 19:42:22 +010016418 return 0;
16419}
16420
16421/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016422 * ALC861-VD support
16423 *
16424 * Based on ALC882
16425 *
16426 * In addition, an independent DAC
16427 */
16428#define ALC861VD_DIGOUT_NID 0x06
16429
16430static hda_nid_t alc861vd_dac_nids[4] = {
16431 /* front, surr, clfe, side surr */
16432 0x02, 0x03, 0x04, 0x05
16433};
16434
16435/* dac_nids for ALC660vd are in a different order - according to
16436 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016437 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016438 * of ALC660vd codecs, but for now there is only 3stack mixer
16439 * - and it is the same as in 861vd.
16440 * adc_nids in ALC660vd are (is) the same as in 861vd
16441 */
16442static hda_nid_t alc660vd_dac_nids[3] = {
16443 /* front, rear, clfe, rear_surr */
16444 0x02, 0x04, 0x03
16445};
16446
16447static hda_nid_t alc861vd_adc_nids[1] = {
16448 /* ADC0 */
16449 0x09,
16450};
16451
Takashi Iwaie1406342008-02-11 18:32:32 +010016452static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
16453
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016454/* input MUX */
16455/* FIXME: should be a matrix-type input source selection */
16456static struct hda_input_mux alc861vd_capture_source = {
16457 .num_items = 4,
16458 .items = {
16459 { "Mic", 0x0 },
16460 { "Front Mic", 0x1 },
16461 { "Line", 0x2 },
16462 { "CD", 0x4 },
16463 },
16464};
16465
Kailang Yang272a5272007-05-14 11:00:38 +020016466static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010016467 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020016468 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +010016469 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +010016470 { "Internal Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020016471 },
16472};
16473
Kailang Yangd1a991a2007-08-15 16:21:59 +020016474static struct hda_input_mux alc861vd_hp_capture_source = {
16475 .num_items = 2,
16476 .items = {
16477 { "Front Mic", 0x0 },
16478 { "ATAPI Mic", 0x1 },
16479 },
16480};
16481
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016482/*
16483 * 2ch mode
16484 */
16485static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
16486 { 2, NULL }
16487};
16488
16489/*
16490 * 6ch mode
16491 */
16492static struct hda_verb alc861vd_6stack_ch6_init[] = {
16493 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16494 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16495 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16496 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16497 { } /* end */
16498};
16499
16500/*
16501 * 8ch mode
16502 */
16503static struct hda_verb alc861vd_6stack_ch8_init[] = {
16504 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16505 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16506 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16507 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16508 { } /* end */
16509};
16510
16511static struct hda_channel_mode alc861vd_6stack_modes[2] = {
16512 { 6, alc861vd_6stack_ch6_init },
16513 { 8, alc861vd_6stack_ch8_init },
16514};
16515
16516static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
16517 {
16518 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16519 .name = "Channel Mode",
16520 .info = alc_ch_mode_info,
16521 .get = alc_ch_mode_get,
16522 .put = alc_ch_mode_put,
16523 },
16524 { } /* end */
16525};
16526
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016527/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16528 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16529 */
16530static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
16531 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16532 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16533
16534 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16535 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16536
16537 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16538 HDA_OUTPUT),
16539 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16540 HDA_OUTPUT),
16541 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16542 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16543
16544 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16545 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16546
16547 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16548
David Henningsson5f99f862011-01-04 15:24:24 +010016549 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016550 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16551 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16552
David Henningsson5f99f862011-01-04 15:24:24 +010016553 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016554 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16555 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16556
16557 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16558 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16559
16560 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16561 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16562
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016563 { } /* end */
16564};
16565
16566static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
16567 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16568 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16569
16570 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16571
David Henningsson5f99f862011-01-04 15:24:24 +010016572 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016573 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16574 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16575
David Henningsson5f99f862011-01-04 15:24:24 +010016576 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016577 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16578 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16579
16580 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16581 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16582
16583 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16584 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16585
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016586 { } /* end */
16587};
16588
Kailang Yangbdd148a2007-05-08 15:19:08 +020016589static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
16590 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16591 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16592 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16593
16594 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16595
David Henningsson5f99f862011-01-04 15:24:24 +010016596 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +020016597 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16598 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16599
David Henningsson5f99f862011-01-04 15:24:24 +010016600 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +020016601 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16602 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16603
16604 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16605 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16606
16607 { } /* end */
16608};
16609
Tobin Davisb419f342008-03-07 11:57:51 +010016610/* Pin assignment: Speaker=0x14, HP = 0x15,
David Henningsson8607f7c2010-12-20 14:43:54 +010016611 * Mic=0x18, Internal Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016612 */
16613static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016614 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16615 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016616 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16617 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010016618 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson8607f7c2010-12-20 14:43:54 +010016619 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16620 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010016621 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010016622 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16623 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016624 { } /* end */
16625};
16626
Kailang Yangd1a991a2007-08-15 16:21:59 +020016627/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16628 * Front Mic=0x18, ATAPI Mic = 0x19,
16629 */
16630static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
16631 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16632 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16633 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16634 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16635 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16636 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16637 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16638 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016639
Kailang Yangd1a991a2007-08-15 16:21:59 +020016640 { } /* end */
16641};
16642
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016643/*
16644 * generic initialization of ADC, input mixers and output mixers
16645 */
16646static struct hda_verb alc861vd_volume_init_verbs[] = {
16647 /*
16648 * Unmute ADC0 and set the default input to mic-in
16649 */
16650 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16651 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16652
16653 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16654 * the analog-loopback mixer widget
16655 */
16656 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016657 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16658 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16659 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16660 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16661 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016662
16663 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016664 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16665 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16666 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016667 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016668
16669 /*
16670 * Set up output mixers (0x02 - 0x05)
16671 */
16672 /* set vol=0 to output mixers */
16673 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16674 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16675 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16676 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16677
16678 /* set up input amps for analog loopback */
16679 /* Amp Indices: DAC = 0, mixer = 1 */
16680 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16681 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16682 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16683 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16684 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16685 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16686 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16687 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16688
16689 { }
16690};
16691
16692/*
16693 * 3-stack pin configuration:
16694 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16695 */
16696static struct hda_verb alc861vd_3stack_init_verbs[] = {
16697 /*
16698 * Set pin mode and muting
16699 */
16700 /* set front pin widgets 0x14 for output */
16701 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16702 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16703 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16704
16705 /* Mic (rear) pin: input vref at 80% */
16706 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16707 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16708 /* Front Mic pin: input vref at 80% */
16709 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16710 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16711 /* Line In pin: input */
16712 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16713 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16714 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16715 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16716 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16717 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16718 /* CD pin widget for input */
16719 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16720
16721 { }
16722};
16723
16724/*
16725 * 6-stack pin configuration:
16726 */
16727static struct hda_verb alc861vd_6stack_init_verbs[] = {
16728 /*
16729 * Set pin mode and muting
16730 */
16731 /* set front pin widgets 0x14 for output */
16732 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16733 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16734 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16735
16736 /* Rear Pin: output 1 (0x0d) */
16737 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16738 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16739 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16740 /* CLFE Pin: output 2 (0x0e) */
16741 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16742 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16743 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16744 /* Side Pin: output 3 (0x0f) */
16745 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16746 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16747 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16748
16749 /* Mic (rear) pin: input vref at 80% */
16750 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16751 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16752 /* Front Mic pin: input vref at 80% */
16753 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16754 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16755 /* Line In pin: input */
16756 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16757 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16758 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16759 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16760 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16761 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16762 /* CD pin widget for input */
16763 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16764
16765 { }
16766};
16767
Kailang Yangbdd148a2007-05-08 15:19:08 +020016768static struct hda_verb alc861vd_eapd_verbs[] = {
16769 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16770 { }
16771};
16772
Kailang Yangf9423e72008-05-27 12:32:25 +020016773static struct hda_verb alc660vd_eapd_verbs[] = {
16774 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16775 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16776 { }
16777};
16778
Kailang Yangbdd148a2007-05-08 15:19:08 +020016779static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16780 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16781 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16782 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16783 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016784 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016785 {}
16786};
16787
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016788static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016789{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016790 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016791 spec->autocfg.hp_pins[0] = 0x1b;
16792 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +020016793 spec->automute = 1;
16794 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016795}
16796
16797static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16798{
Takashi Iwaid922b512011-04-28 12:18:53 +020016799 alc_hp_automute(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +010016800 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016801}
16802
16803static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16804 unsigned int res)
16805{
16806 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016807 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +010016808 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016809 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016810 default:
Takashi Iwaid922b512011-04-28 12:18:53 +020016811 alc_sku_unsol_event(codec, res);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016812 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016813 }
16814}
16815
Kailang Yang272a5272007-05-14 11:00:38 +020016816static struct hda_verb alc861vd_dallas_verbs[] = {
16817 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16818 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16819 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16820 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16821
16822 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16823 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16824 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16825 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16826 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16827 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16828 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16829 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016830
Kailang Yang272a5272007-05-14 11:00:38 +020016831 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16832 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16833 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16834 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16835 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16836 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16837 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16838 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16839
16840 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16841 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16842 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16843 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16844 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16845 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16846 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16847 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16848
16849 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16850 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16851 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16852 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16853
16854 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016855 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016856 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16857
16858 { } /* end */
16859};
16860
16861/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016862static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016863{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016864 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016865
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016866 spec->autocfg.hp_pins[0] = 0x15;
16867 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +020016868 spec->automute = 1;
16869 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yang272a5272007-05-14 11:00:38 +020016870}
16871
Takashi Iwaicb53c622007-08-10 17:21:45 +020016872#ifdef CONFIG_SND_HDA_POWER_SAVE
16873#define alc861vd_loopbacks alc880_loopbacks
16874#endif
16875
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016876/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016877#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16878#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16879#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16880#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16881
16882/*
16883 * configuration and preset
16884 */
Takashi Iwaiea734962011-01-17 11:29:34 +010016885static const char * const alc861vd_models[ALC861VD_MODEL_LAST] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016886 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016887 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016888 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016889 [ALC861VD_3ST] = "3stack",
16890 [ALC861VD_3ST_DIG] = "3stack-digout",
16891 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016892 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016893 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016894 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016895 [ALC861VD_AUTO] = "auto",
16896};
16897
16898static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016899 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16900 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016901 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016902 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016903 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016904 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016905 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016906 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016907 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016908 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016909 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016910 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016911 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016912 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016913 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016914 {}
16915};
16916
16917static struct alc_config_preset alc861vd_presets[] = {
16918 [ALC660VD_3ST] = {
16919 .mixers = { alc861vd_3st_mixer },
16920 .init_verbs = { alc861vd_volume_init_verbs,
16921 alc861vd_3stack_init_verbs },
16922 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16923 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016924 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16925 .channel_mode = alc861vd_3stack_2ch_modes,
16926 .input_mux = &alc861vd_capture_source,
16927 },
Mike Crash6963f842007-06-25 12:12:51 +020016928 [ALC660VD_3ST_DIG] = {
16929 .mixers = { alc861vd_3st_mixer },
16930 .init_verbs = { alc861vd_volume_init_verbs,
16931 alc861vd_3stack_init_verbs },
16932 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16933 .dac_nids = alc660vd_dac_nids,
16934 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016935 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16936 .channel_mode = alc861vd_3stack_2ch_modes,
16937 .input_mux = &alc861vd_capture_source,
16938 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016939 [ALC861VD_3ST] = {
16940 .mixers = { alc861vd_3st_mixer },
16941 .init_verbs = { alc861vd_volume_init_verbs,
16942 alc861vd_3stack_init_verbs },
16943 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16944 .dac_nids = alc861vd_dac_nids,
16945 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16946 .channel_mode = alc861vd_3stack_2ch_modes,
16947 .input_mux = &alc861vd_capture_source,
16948 },
16949 [ALC861VD_3ST_DIG] = {
16950 .mixers = { alc861vd_3st_mixer },
16951 .init_verbs = { alc861vd_volume_init_verbs,
16952 alc861vd_3stack_init_verbs },
16953 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16954 .dac_nids = alc861vd_dac_nids,
16955 .dig_out_nid = ALC861VD_DIGOUT_NID,
16956 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16957 .channel_mode = alc861vd_3stack_2ch_modes,
16958 .input_mux = &alc861vd_capture_source,
16959 },
16960 [ALC861VD_6ST_DIG] = {
16961 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16962 .init_verbs = { alc861vd_volume_init_verbs,
16963 alc861vd_6stack_init_verbs },
16964 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16965 .dac_nids = alc861vd_dac_nids,
16966 .dig_out_nid = ALC861VD_DIGOUT_NID,
16967 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16968 .channel_mode = alc861vd_6stack_modes,
16969 .input_mux = &alc861vd_capture_source,
16970 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016971 [ALC861VD_LENOVO] = {
16972 .mixers = { alc861vd_lenovo_mixer },
16973 .init_verbs = { alc861vd_volume_init_verbs,
16974 alc861vd_3stack_init_verbs,
16975 alc861vd_eapd_verbs,
16976 alc861vd_lenovo_unsol_verbs },
16977 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16978 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016979 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16980 .channel_mode = alc861vd_3stack_2ch_modes,
16981 .input_mux = &alc861vd_capture_source,
16982 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016983 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016984 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016985 },
Kailang Yang272a5272007-05-14 11:00:38 +020016986 [ALC861VD_DALLAS] = {
16987 .mixers = { alc861vd_dallas_mixer },
16988 .init_verbs = { alc861vd_dallas_verbs },
16989 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16990 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016991 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16992 .channel_mode = alc861vd_3stack_2ch_modes,
16993 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020016994 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016995 .setup = alc861vd_dallas_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020016996 .init_hook = alc_hp_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016997 },
16998 [ALC861VD_HP] = {
16999 .mixers = { alc861vd_hp_mixer },
17000 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
17001 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
17002 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020017003 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020017004 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17005 .channel_mode = alc861vd_3stack_2ch_modes,
17006 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020017007 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017008 .setup = alc861vd_dallas_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020017009 .init_hook = alc_hp_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020017010 },
Takashi Iwai13c94742008-11-05 08:06:08 +010017011 [ALC660VD_ASUS_V1S] = {
17012 .mixers = { alc861vd_lenovo_mixer },
17013 .init_verbs = { alc861vd_volume_init_verbs,
17014 alc861vd_3stack_init_verbs,
17015 alc861vd_eapd_verbs,
17016 alc861vd_lenovo_unsol_verbs },
17017 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
17018 .dac_nids = alc660vd_dac_nids,
17019 .dig_out_nid = ALC861VD_DIGOUT_NID,
17020 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17021 .channel_mode = alc861vd_3stack_2ch_modes,
17022 .input_mux = &alc861vd_capture_source,
17023 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017024 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020017025 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010017026 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017027};
17028
17029/*
17030 * BIOS auto configuration
17031 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020017032static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
17033 const struct auto_pin_cfg *cfg)
17034{
Herton Ronaldo Krzesinski71675942010-11-25 00:08:01 -020017035 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x22, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020017036}
17037
17038
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017039static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
17040 hda_nid_t nid, int pin_type, int dac_idx)
17041{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017042 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017043}
17044
17045static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
17046{
17047 struct alc_spec *spec = codec->spec;
17048 int i;
17049
17050 for (i = 0; i <= HDA_SIDE; i++) {
17051 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017052 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017053 if (nid)
17054 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017055 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017056 }
17057}
17058
17059
17060static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
17061{
17062 struct alc_spec *spec = codec->spec;
17063 hda_nid_t pin;
17064
17065 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017066 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017067 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017068 pin = spec->autocfg.speaker_pins[0];
17069 if (pin)
17070 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017071}
17072
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017073#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
17074
17075static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
17076{
17077 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020017078 struct auto_pin_cfg *cfg = &spec->autocfg;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017079 int i;
17080
Takashi Iwai66ceeb62010-08-30 13:05:52 +020017081 for (i = 0; i < cfg->num_inputs; i++) {
17082 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017083 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020017084 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +010017085 if (nid != ALC861VD_PIN_CD_NID &&
17086 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017087 snd_hda_codec_write(codec, nid, 0,
17088 AC_VERB_SET_AMP_GAIN_MUTE,
17089 AMP_OUT_MUTE);
17090 }
17091 }
17092}
17093
Takashi Iwaif511b012008-08-15 16:46:42 +020017094#define alc861vd_auto_init_input_src alc882_auto_init_input_src
17095
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017096#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
17097#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
17098
17099/* add playback controls from the parsed DAC table */
Takashi Iwai569ed342011-01-19 10:14:46 +010017100/* Based on ALC880 version. But ALC861VD has separate,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017101 * different NIDs for mute/unmute switch and volume control */
17102static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
17103 const struct auto_pin_cfg *cfg)
17104{
Takashi Iwaiea734962011-01-17 11:29:34 +010017105 static const char * const chname[4] = {
17106 "Front", "Surround", "CLFE", "Side"
17107 };
Takashi Iwaice764ab2011-04-27 16:35:23 +020017108 const char *pfx = alc_get_line_out_pfx(spec, true);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017109 hda_nid_t nid_v, nid_s;
Takashi Iwaice764ab2011-04-27 16:35:23 +020017110 int i, err, noutputs;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017111
Takashi Iwaice764ab2011-04-27 16:35:23 +020017112 noutputs = cfg->line_outs;
17113 if (spec->multi_ios > 0)
17114 noutputs += spec->multi_ios;
17115
17116 for (i = 0; i < noutputs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017117 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017118 continue;
17119 nid_v = alc861vd_idx_to_mixer_vol(
17120 alc880_dac_to_idx(
17121 spec->multiout.dac_nids[i]));
17122 nid_s = alc861vd_idx_to_mixer_switch(
17123 alc880_dac_to_idx(
17124 spec->multiout.dac_nids[i]));
17125
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017126 if (!pfx && i == 2) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017127 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017128 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17129 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017130 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
17131 HDA_OUTPUT));
17132 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017133 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017134 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17135 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017136 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
17137 HDA_OUTPUT));
17138 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017139 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017140 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17141 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017142 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
17143 HDA_INPUT));
17144 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017145 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017146 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17147 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017148 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
17149 HDA_INPUT));
17150 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017151 return err;
17152 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017153 const char *name = pfx;
David Henningsson5a882642011-03-23 08:35:07 +010017154 int index = i;
17155 if (!name) {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017156 name = chname[i];
David Henningsson5a882642011-03-23 08:35:07 +010017157 index = 0;
17158 }
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017159 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
David Henningsson5a882642011-03-23 08:35:07 +010017160 name, index,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017161 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
17162 HDA_OUTPUT));
17163 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017164 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017165 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
David Henningsson5a882642011-03-23 08:35:07 +010017166 name, index,
Kailang Yangbdd148a2007-05-08 15:19:08 +020017167 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017168 HDA_INPUT));
17169 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017170 return err;
17171 }
17172 }
17173 return 0;
17174}
17175
17176/* add playback controls for speaker and HP outputs */
17177/* Based on ALC880 version. But ALC861VD has separate,
17178 * different NIDs for mute/unmute switch and volume control */
17179static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
17180 hda_nid_t pin, const char *pfx)
17181{
17182 hda_nid_t nid_v, nid_s;
17183 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017184
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017185 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017186 return 0;
17187
17188 if (alc880_is_fixed_pin(pin)) {
17189 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17190 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017191 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017192 spec->multiout.hp_nid = nid_v;
17193 else
17194 spec->multiout.extra_out_nid[0] = nid_v;
17195 /* control HP volume/switch on the output mixer amp */
17196 nid_v = alc861vd_idx_to_mixer_vol(
17197 alc880_fixed_pin_idx(pin));
17198 nid_s = alc861vd_idx_to_mixer_switch(
17199 alc880_fixed_pin_idx(pin));
17200
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017201 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017202 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
17203 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017204 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017205 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017206 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
17207 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017208 return err;
17209 } else if (alc880_is_multi_pin(pin)) {
17210 /* set manual connection */
17211 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017212 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017213 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17214 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017215 return err;
17216 }
17217 return 0;
17218}
17219
17220/* parse the BIOS configuration and set up the alc_spec
17221 * return 1 if successful, 0 if the proper config is not found,
17222 * or a negative error code
17223 * Based on ALC880 version - had to change it to override
17224 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
17225static int alc861vd_parse_auto_config(struct hda_codec *codec)
17226{
17227 struct alc_spec *spec = codec->spec;
17228 int err;
17229 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
17230
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017231 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17232 alc861vd_ignore);
17233 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017234 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017235 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017236 return 0; /* can't find valid BIOS pin config */
17237
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017238 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17239 if (err < 0)
17240 return err;
Takashi Iwaice764ab2011-04-27 16:35:23 +020017241 err = alc_auto_add_multi_channel_mode(codec);
17242 if (err < 0)
17243 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017244 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
17245 if (err < 0)
17246 return err;
17247 err = alc861vd_auto_create_extra_out(spec,
17248 spec->autocfg.speaker_pins[0],
17249 "Speaker");
17250 if (err < 0)
17251 return err;
17252 err = alc861vd_auto_create_extra_out(spec,
17253 spec->autocfg.hp_pins[0],
17254 "Headphone");
17255 if (err < 0)
17256 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017257 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017258 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017259 return err;
17260
17261 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17262
Takashi Iwai757899a2010-07-30 10:48:14 +020017263 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017264
Takashi Iwai603c4012008-07-30 15:01:44 +020017265 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017266 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017267
Takashi Iwaid88897e2008-10-31 15:01:37 +010017268 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017269
17270 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017271 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017272
Takashi Iwai776e1842007-08-29 15:07:11 +020017273 err = alc_auto_add_mic_boost(codec);
17274 if (err < 0)
17275 return err;
17276
Kailang Yang6227cdc2010-02-25 08:36:52 +010017277 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017278
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017279 return 1;
17280}
17281
17282/* additional initialization for auto-configuration model */
17283static void alc861vd_auto_init(struct hda_codec *codec)
17284{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017285 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017286 alc861vd_auto_init_multi_out(codec);
17287 alc861vd_auto_init_hp_out(codec);
17288 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017289 alc861vd_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020017290 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017291 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017292 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017293}
17294
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017295enum {
17296 ALC660VD_FIX_ASUS_GPIO1
17297};
17298
17299/* reset GPIO1 */
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017300static const struct alc_fixup alc861vd_fixups[] = {
17301 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017302 .type = ALC_FIXUP_VERBS,
17303 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020017304 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
17305 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
17306 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
17307 { }
17308 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017309 },
17310};
17311
17312static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
17313 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
17314 {}
17315};
17316
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017317static int patch_alc861vd(struct hda_codec *codec)
17318{
17319 struct alc_spec *spec;
17320 int err, board_config;
17321
17322 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17323 if (spec == NULL)
17324 return -ENOMEM;
17325
17326 codec->spec = spec;
17327
17328 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
17329 alc861vd_models,
17330 alc861vd_cfg_tbl);
17331
17332 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017333 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17334 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017335 board_config = ALC861VD_AUTO;
17336 }
17337
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017338 if (board_config == ALC861VD_AUTO) {
17339 alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
17340 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
17341 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017342
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017343 if (board_config == ALC861VD_AUTO) {
17344 /* automatic parse from the BIOS config */
17345 err = alc861vd_parse_auto_config(codec);
17346 if (err < 0) {
17347 alc_free(codec);
17348 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017349 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017350 printk(KERN_INFO
17351 "hda_codec: Cannot set up configuration "
17352 "from BIOS. Using base mode...\n");
17353 board_config = ALC861VD_3ST;
17354 }
17355 }
17356
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017357 err = snd_hda_attach_beep_device(codec, 0x23);
17358 if (err < 0) {
17359 alc_free(codec);
17360 return err;
17361 }
17362
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017363 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017364 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017365
Kailang Yang2f893282008-05-27 12:14:47 +020017366 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020017367 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010017368 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020017369 }
17370
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017371 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
17372 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
17373
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017374 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
17375 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
17376
Takashi Iwaidd704692009-08-11 08:45:11 +020017377 if (!spec->adc_nids) {
17378 spec->adc_nids = alc861vd_adc_nids;
17379 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
17380 }
17381 if (!spec->capsrc_nids)
17382 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017383
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017384 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010017385 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017386
Takashi Iwai2134ea42008-01-10 16:53:55 +010017387 spec->vmaster_nid = 0x02;
17388
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017389 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017390
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017391 codec->patch_ops = alc_patch_ops;
17392
17393 if (board_config == ALC861VD_AUTO)
17394 spec->init_hook = alc861vd_auto_init;
Takashi Iwai1c7161532011-04-07 10:37:16 +020017395 spec->shutup = alc_eapd_shutup;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017396#ifdef CONFIG_SND_HDA_POWER_SAVE
17397 if (!spec->loopback.amplist)
17398 spec->loopback.amplist = alc861vd_loopbacks;
17399#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017400
17401 return 0;
17402}
17403
17404/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017405 * ALC662 support
17406 *
17407 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
17408 * configuration. Each pin widget can choose any input DACs and a mixer.
17409 * Each ADC is connected from a mixer of all inputs. This makes possible
17410 * 6-channel independent captures.
17411 *
17412 * In addition, an independent DAC for the multi-playback (not used in this
17413 * driver yet).
17414 */
17415#define ALC662_DIGOUT_NID 0x06
17416#define ALC662_DIGIN_NID 0x0a
17417
Raymond Yau4bf4a6c2011-04-05 22:47:15 +080017418static hda_nid_t alc662_dac_nids[3] = {
17419 /* front, rear, clfe */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017420 0x02, 0x03, 0x04
17421};
17422
Kailang Yang622e84c2009-04-21 07:39:04 +020017423static hda_nid_t alc272_dac_nids[2] = {
17424 0x02, 0x03
17425};
17426
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017427static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017428 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017429 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017430};
Takashi Iwaie1406342008-02-11 18:32:32 +010017431
Kailang Yang622e84c2009-04-21 07:39:04 +020017432static hda_nid_t alc272_adc_nids[1] = {
17433 /* ADC1-2 */
17434 0x08,
17435};
17436
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017437static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020017438static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
17439
Takashi Iwaie1406342008-02-11 18:32:32 +010017440
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017441/* input MUX */
17442/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017443static struct hda_input_mux alc662_capture_source = {
17444 .num_items = 4,
17445 .items = {
17446 { "Mic", 0x0 },
17447 { "Front Mic", 0x1 },
17448 { "Line", 0x2 },
17449 { "CD", 0x4 },
17450 },
17451};
17452
17453static struct hda_input_mux alc662_lenovo_101e_capture_source = {
17454 .num_items = 2,
17455 .items = {
17456 { "Mic", 0x1 },
17457 { "Line", 0x2 },
17458 },
17459};
Kailang Yang291702f2007-10-16 14:28:03 +020017460
Kailang Yang6dda9f42008-05-27 12:05:31 +020017461static struct hda_input_mux alc663_capture_source = {
17462 .num_items = 3,
17463 .items = {
17464 { "Mic", 0x0 },
17465 { "Front Mic", 0x1 },
17466 { "Line", 0x2 },
17467 },
17468};
17469
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017470#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020017471static struct hda_input_mux alc272_nc10_capture_source = {
17472 .num_items = 16,
17473 .items = {
17474 { "Autoselect Mic", 0x0 },
17475 { "Internal Mic", 0x1 },
17476 { "In-0x02", 0x2 },
17477 { "In-0x03", 0x3 },
17478 { "In-0x04", 0x4 },
17479 { "In-0x05", 0x5 },
17480 { "In-0x06", 0x6 },
17481 { "In-0x07", 0x7 },
17482 { "In-0x08", 0x8 },
17483 { "In-0x09", 0x9 },
17484 { "In-0x0a", 0x0a },
17485 { "In-0x0b", 0x0b },
17486 { "In-0x0c", 0x0c },
17487 { "In-0x0d", 0x0d },
17488 { "In-0x0e", 0x0e },
17489 { "In-0x0f", 0x0f },
17490 },
17491};
17492#endif
17493
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017494/*
17495 * 2ch mode
17496 */
17497static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
17498 { 2, NULL }
17499};
17500
17501/*
17502 * 2ch mode
17503 */
17504static struct hda_verb alc662_3ST_ch2_init[] = {
17505 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
17506 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17507 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
17508 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17509 { } /* end */
17510};
17511
17512/*
17513 * 6ch mode
17514 */
17515static struct hda_verb alc662_3ST_ch6_init[] = {
17516 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17517 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17518 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17519 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17520 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17521 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17522 { } /* end */
17523};
17524
17525static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
17526 { 2, alc662_3ST_ch2_init },
17527 { 6, alc662_3ST_ch6_init },
17528};
17529
17530/*
17531 * 2ch mode
17532 */
17533static struct hda_verb alc662_sixstack_ch6_init[] = {
17534 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17535 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17536 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17537 { } /* end */
17538};
17539
17540/*
17541 * 6ch mode
17542 */
17543static struct hda_verb alc662_sixstack_ch8_init[] = {
17544 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17545 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17546 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17547 { } /* end */
17548};
17549
17550static struct hda_channel_mode alc662_5stack_modes[2] = {
17551 { 2, alc662_sixstack_ch6_init },
17552 { 6, alc662_sixstack_ch8_init },
17553};
17554
17555/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17556 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17557 */
17558
17559static struct snd_kcontrol_new alc662_base_mixer[] = {
17560 /* output mixer control */
17561 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017562 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017563 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017564 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017565 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17566 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017567 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17568 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017569 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17570
17571 /*Input mixer control */
17572 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17573 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17574 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17575 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17576 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17577 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17578 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17579 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017580 { } /* end */
17581};
17582
17583static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
17584 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017585 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017586 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17587 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17588 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17589 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17590 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17591 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17592 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17593 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17594 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017595 { } /* end */
17596};
17597
17598static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
17599 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017600 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017601 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017602 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017603 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17604 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017605 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17606 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017607 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17608 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17609 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17610 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17611 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17612 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17613 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17614 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17615 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017616 { } /* end */
17617};
17618
17619static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
17620 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17621 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017622 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17623 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017624 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17625 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17626 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17627 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17628 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017629 { } /* end */
17630};
17631
Kailang Yang291702f2007-10-16 14:28:03 +020017632static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017633 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17634 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017635
David Henningsson5f99f862011-01-04 15:24:24 +010017636 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017637 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17638 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020017639
David Henningsson5f99f862011-01-04 15:24:24 +010017640 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017641 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17642 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020017643 { } /* end */
17644};
17645
Kailang Yang8c427222008-01-10 13:03:59 +010017646static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017647 ALC262_HIPPO_MASTER_SWITCH,
17648 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017649 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017650 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17651 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017652 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17653 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17654 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17655 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17656 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17657 { } /* end */
17658};
17659
Kailang Yangf1d4e282008-08-26 14:03:29 +020017660static struct hda_bind_ctls alc663_asus_bind_master_vol = {
17661 .ops = &snd_hda_bind_vol,
17662 .values = {
17663 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17664 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17665 0
17666 },
17667};
17668
17669static struct hda_bind_ctls alc663_asus_one_bind_switch = {
17670 .ops = &snd_hda_bind_sw,
17671 .values = {
17672 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17673 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17674 0
17675 },
17676};
17677
Kailang Yang6dda9f42008-05-27 12:05:31 +020017678static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017679 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17680 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17681 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17682 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17683 { } /* end */
17684};
17685
17686static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
17687 .ops = &snd_hda_bind_sw,
17688 .values = {
17689 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17690 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17691 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17692 0
17693 },
17694};
17695
17696static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
17697 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17698 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17699 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17700 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17701 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17702 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17703
17704 { } /* end */
17705};
17706
17707static struct hda_bind_ctls alc663_asus_four_bind_switch = {
17708 .ops = &snd_hda_bind_sw,
17709 .values = {
17710 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17711 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17712 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17713 0
17714 },
17715};
17716
17717static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
17718 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17719 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17720 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17721 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17722 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17723 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17724 { } /* end */
17725};
17726
17727static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017728 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17729 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017730 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17731 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17732 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17733 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17734 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17735 { } /* end */
17736};
17737
17738static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
17739 .ops = &snd_hda_bind_vol,
17740 .values = {
17741 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17742 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17743 0
17744 },
17745};
17746
17747static struct hda_bind_ctls alc663_asus_two_bind_switch = {
17748 .ops = &snd_hda_bind_sw,
17749 .values = {
17750 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17751 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17752 0
17753 },
17754};
17755
17756static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17757 HDA_BIND_VOL("Master Playback Volume",
17758 &alc663_asus_two_bind_master_vol),
17759 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17760 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017761 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17762 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17763 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017764 { } /* end */
17765};
17766
17767static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17768 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17769 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17770 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17771 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17772 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17773 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017774 { } /* end */
17775};
17776
17777static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17778 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17779 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17780 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17781 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17782 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17783
17784 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17785 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017786 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17787 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017788 { } /* end */
17789};
17790
17791static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17792 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17793 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17794 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17795
17796 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17797 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017798 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17799 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017800 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17801 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17802 { } /* end */
17803};
17804
Kailang Yangebb83ee2009-12-17 12:23:00 +010017805static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17806 .ops = &snd_hda_bind_sw,
17807 .values = {
17808 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17809 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17810 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17811 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17812 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17813 0
17814 },
17815};
17816
17817static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17818 .ops = &snd_hda_bind_sw,
17819 .values = {
17820 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17821 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17822 0
17823 },
17824};
17825
17826static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17827 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17828 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17829 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17830 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17831 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17832 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17833 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17834 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17835 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17836 { } /* end */
17837};
17838
17839static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17840 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17841 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17842 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17843 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17844 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17845 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17846 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17847 { } /* end */
17848};
17849
17850
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017851static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17852 {
17853 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17854 .name = "Channel Mode",
17855 .info = alc_ch_mode_info,
17856 .get = alc_ch_mode_get,
17857 .put = alc_ch_mode_put,
17858 },
17859 { } /* end */
17860};
17861
17862static struct hda_verb alc662_init_verbs[] = {
17863 /* ADC: mute amp left and right */
17864 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17865 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017866
Kailang Yangb60dd392007-09-20 12:50:29 +020017867 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17868 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17869 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17870 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17871 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17872 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017873
17874 /* Front Pin: output 0 (0x0c) */
17875 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17876 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17877
17878 /* Rear Pin: output 1 (0x0d) */
17879 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17880 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17881
17882 /* CLFE Pin: output 2 (0x0e) */
17883 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17884 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17885
17886 /* Mic (rear) pin: input vref at 80% */
17887 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17888 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17889 /* Front Mic pin: input vref at 80% */
17890 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17891 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17892 /* Line In pin: input */
17893 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17894 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17895 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17896 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17897 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17898 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17899 /* CD pin widget for input */
17900 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17901
17902 /* FIXME: use matrix-type input source selection */
17903 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17904 /* Input mixer */
17905 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017906 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017907
Takashi Iwaia7f23712011-04-07 10:24:23 +020017908 { }
17909};
17910
17911static struct hda_verb alc662_eapd_init_verbs[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017912 /* always trun on EAPD */
17913 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17914 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017915 { }
17916};
17917
17918static struct hda_verb alc662_sue_init_verbs[] = {
17919 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17920 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017921 {}
17922};
17923
17924static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17925 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17926 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17927 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017928};
17929
Kailang Yang8c427222008-01-10 13:03:59 +010017930/* Set Unsolicited Event*/
17931static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17932 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17933 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17934 {}
17935};
17936
Kailang Yang6dda9f42008-05-27 12:05:31 +020017937static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017938 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17939 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017940 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17941 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017942 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17943 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17944 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017945 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17946 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17947 {}
17948};
17949
Kailang Yangf1d4e282008-08-26 14:03:29 +020017950static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17951 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17952 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17953 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17954 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17955 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17956 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17957 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17958 {}
17959};
17960
17961static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17962 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17963 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17964 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17965 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17966 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17967 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17968 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17969 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17970 {}
17971};
17972
17973static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17974 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17975 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17976 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17977 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17978 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17979 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17980 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17981 {}
17982};
17983
17984static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
17985 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17986 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17987 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17988 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17989 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17990 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17991 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17992 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17993 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17994 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17995 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17996 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17997 {}
17998};
17999
18000static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
18001 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18002 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18003 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18004 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18005 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18006 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18007 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18008 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18009 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18010 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18011 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18012 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18013 {}
18014};
18015
Kailang Yang6dda9f42008-05-27 12:05:31 +020018016static struct hda_verb alc663_g71v_init_verbs[] = {
18017 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18018 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
18019 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
18020
18021 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18022 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18023 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
18024
18025 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
18026 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
18027 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
18028 {}
18029};
18030
18031static struct hda_verb alc663_g50v_init_verbs[] = {
18032 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18033 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18034 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
18035
18036 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18037 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18038 {}
18039};
18040
Kailang Yangf1d4e282008-08-26 14:03:29 +020018041static struct hda_verb alc662_ecs_init_verbs[] = {
18042 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
18043 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18044 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18045 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18046 {}
18047};
18048
Kailang Yang622e84c2009-04-21 07:39:04 +020018049static struct hda_verb alc272_dell_zm1_init_verbs[] = {
18050 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18051 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18052 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18053 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18054 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18055 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18056 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18057 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18058 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18059 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18060 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18061 {}
18062};
18063
18064static struct hda_verb alc272_dell_init_verbs[] = {
18065 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18066 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18067 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18068 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18069 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18070 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18071 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18072 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18073 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18074 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18075 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18076 {}
18077};
18078
Kailang Yangebb83ee2009-12-17 12:23:00 +010018079static struct hda_verb alc663_mode7_init_verbs[] = {
18080 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18081 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18082 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18083 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18084 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18085 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18086 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
18087 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18088 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18089 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18090 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18091 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18092 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18093 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18094 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18095 {}
18096};
18097
18098static struct hda_verb alc663_mode8_init_verbs[] = {
18099 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18100 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18101 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18102 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
18103 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18104 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18105 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18106 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18107 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18108 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18109 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18110 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18111 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18112 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18113 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18114 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18115 {}
18116};
18117
Kailang Yangf1d4e282008-08-26 14:03:29 +020018118static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
18119 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
18120 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
18121 { } /* end */
18122};
18123
Kailang Yang622e84c2009-04-21 07:39:04 +020018124static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
18125 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
18126 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
18127 { } /* end */
18128};
18129
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020018130static void alc662_lenovo_101e_setup(struct hda_codec *codec)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018131{
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020018132 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018133
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020018134 spec->autocfg.hp_pins[0] = 0x1b;
18135 spec->autocfg.line_out_pins[0] = 0x14;
18136 spec->autocfg.speaker_pins[0] = 0x15;
18137 spec->automute = 1;
18138 spec->detect_line = 1;
18139 spec->automute_lines = 1;
18140 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018141}
18142
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018143static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020018144{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018145 struct alc_spec *spec = codec->spec;
18146
18147 alc262_hippo1_setup(codec);
18148 spec->ext_mic.pin = 0x18;
18149 spec->ext_mic.mux_idx = 0;
18150 spec->int_mic.pin = 0x19;
18151 spec->int_mic.mux_idx = 1;
18152 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020018153}
18154
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018155static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010018156{
Takashi Iwai42171c12009-05-08 14:11:43 +020018157 struct alc_spec *spec = codec->spec;
18158
18159 spec->autocfg.hp_pins[0] = 0x14;
18160 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaie9427962011-04-28 15:46:07 +020018161 spec->automute = 1;
18162 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yang8c427222008-01-10 13:03:59 +010018163}
18164
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018165static void alc663_m51va_setup(struct hda_codec *codec)
18166{
18167 struct alc_spec *spec = codec->spec;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018168 spec->autocfg.hp_pins[0] = 0x21;
18169 spec->autocfg.speaker_pins[0] = 0x14;
18170 spec->automute_mixer_nid[0] = 0x0c;
18171 spec->automute = 1;
18172 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018173 spec->ext_mic.pin = 0x18;
18174 spec->ext_mic.mux_idx = 0;
18175 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018176 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018177 spec->auto_mic = 1;
18178}
18179
Kailang Yangf1d4e282008-08-26 14:03:29 +020018180/* ***************** Mode1 ******************************/
Kailang Yangebb83ee2009-12-17 12:23:00 +010018181static void alc663_mode1_setup(struct hda_codec *codec)
18182{
18183 struct alc_spec *spec = codec->spec;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018184 spec->autocfg.hp_pins[0] = 0x21;
18185 spec->autocfg.speaker_pins[0] = 0x14;
18186 spec->automute_mixer_nid[0] = 0x0c;
18187 spec->automute = 1;
18188 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018189 spec->ext_mic.pin = 0x18;
18190 spec->ext_mic.mux_idx = 0;
18191 spec->int_mic.pin = 0x19;
18192 spec->int_mic.mux_idx = 1;
18193 spec->auto_mic = 1;
18194}
18195
Kailang Yangf1d4e282008-08-26 14:03:29 +020018196/* ***************** Mode2 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018197static void alc662_mode2_setup(struct hda_codec *codec)
Kailang Yangf1d4e282008-08-26 14:03:29 +020018198{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018199 struct alc_spec *spec = codec->spec;
18200 spec->autocfg.hp_pins[0] = 0x1b;
18201 spec->autocfg.speaker_pins[0] = 0x14;
18202 spec->automute = 1;
18203 spec->automute_mode = ALC_AUTOMUTE_PIN;
18204 spec->ext_mic.pin = 0x18;
18205 spec->ext_mic.mux_idx = 0;
18206 spec->int_mic.pin = 0x19;
18207 spec->int_mic.mux_idx = 1;
18208 spec->auto_mic = 1;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018209}
18210
Kailang Yangf1d4e282008-08-26 14:03:29 +020018211/* ***************** Mode3 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018212static void alc663_mode3_setup(struct hda_codec *codec)
Kailang Yangf1d4e282008-08-26 14:03:29 +020018213{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018214 struct alc_spec *spec = codec->spec;
18215 spec->autocfg.hp_pins[0] = 0x21;
18216 spec->autocfg.hp_pins[0] = 0x15;
18217 spec->autocfg.speaker_pins[0] = 0x14;
18218 spec->automute = 1;
18219 spec->automute_mode = ALC_AUTOMUTE_PIN;
18220 spec->ext_mic.pin = 0x18;
18221 spec->ext_mic.mux_idx = 0;
18222 spec->int_mic.pin = 0x19;
18223 spec->int_mic.mux_idx = 1;
18224 spec->auto_mic = 1;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018225}
18226
Kailang Yangf1d4e282008-08-26 14:03:29 +020018227/* ***************** Mode4 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018228static void alc663_mode4_setup(struct hda_codec *codec)
Kailang Yangf1d4e282008-08-26 14:03:29 +020018229{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018230 struct alc_spec *spec = codec->spec;
18231 spec->autocfg.hp_pins[0] = 0x21;
18232 spec->autocfg.speaker_pins[0] = 0x14;
18233 spec->autocfg.speaker_pins[1] = 0x16;
18234 spec->automute_mixer_nid[0] = 0x0c;
18235 spec->automute_mixer_nid[1] = 0x0e;
18236 spec->automute = 1;
18237 spec->automute_mode = ALC_AUTOMUTE_MIXER;
18238 spec->ext_mic.pin = 0x18;
18239 spec->ext_mic.mux_idx = 0;
18240 spec->int_mic.pin = 0x19;
18241 spec->int_mic.mux_idx = 1;
18242 spec->auto_mic = 1;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018243}
18244
Kailang Yangf1d4e282008-08-26 14:03:29 +020018245/* ***************** Mode5 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018246static void alc663_mode5_setup(struct hda_codec *codec)
Kailang Yangf1d4e282008-08-26 14:03:29 +020018247{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018248 struct alc_spec *spec = codec->spec;
18249 spec->autocfg.hp_pins[0] = 0x15;
18250 spec->autocfg.speaker_pins[0] = 0x14;
18251 spec->autocfg.speaker_pins[1] = 0x16;
18252 spec->automute_mixer_nid[0] = 0x0c;
18253 spec->automute_mixer_nid[1] = 0x0e;
18254 spec->automute = 1;
18255 spec->automute_mode = ALC_AUTOMUTE_MIXER;
18256 spec->ext_mic.pin = 0x18;
18257 spec->ext_mic.mux_idx = 0;
18258 spec->int_mic.pin = 0x19;
18259 spec->int_mic.mux_idx = 1;
18260 spec->auto_mic = 1;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018261}
18262
Kailang Yangf1d4e282008-08-26 14:03:29 +020018263/* ***************** Mode6 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018264static void alc663_mode6_setup(struct hda_codec *codec)
Kailang Yangf1d4e282008-08-26 14:03:29 +020018265{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018266 struct alc_spec *spec = codec->spec;
18267 spec->autocfg.hp_pins[0] = 0x1b;
18268 spec->autocfg.hp_pins[0] = 0x15;
18269 spec->autocfg.speaker_pins[0] = 0x14;
18270 spec->automute_mixer_nid[0] = 0x0c;
18271 spec->automute = 1;
18272 spec->automute_mode = ALC_AUTOMUTE_MIXER;
18273 spec->ext_mic.pin = 0x18;
18274 spec->ext_mic.mux_idx = 0;
18275 spec->int_mic.pin = 0x19;
18276 spec->int_mic.mux_idx = 1;
18277 spec->auto_mic = 1;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018278}
18279
Kailang Yangebb83ee2009-12-17 12:23:00 +010018280/* ***************** Mode7 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018281static void alc663_mode7_setup(struct hda_codec *codec)
Kailang Yangebb83ee2009-12-17 12:23:00 +010018282{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018283 struct alc_spec *spec = codec->spec;
18284 spec->autocfg.hp_pins[0] = 0x1b;
18285 spec->autocfg.hp_pins[0] = 0x21;
18286 spec->autocfg.speaker_pins[0] = 0x14;
18287 spec->autocfg.speaker_pins[0] = 0x17;
18288 spec->automute = 1;
18289 spec->automute_mode = ALC_AUTOMUTE_PIN;
18290 spec->ext_mic.pin = 0x18;
18291 spec->ext_mic.mux_idx = 0;
18292 spec->int_mic.pin = 0x19;
18293 spec->int_mic.mux_idx = 1;
18294 spec->auto_mic = 1;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018295}
18296
18297/* ***************** Mode8 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018298static void alc663_mode8_setup(struct hda_codec *codec)
Kailang Yangebb83ee2009-12-17 12:23:00 +010018299{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018300 struct alc_spec *spec = codec->spec;
18301 spec->autocfg.hp_pins[0] = 0x21;
18302 spec->autocfg.hp_pins[1] = 0x15;
18303 spec->autocfg.speaker_pins[0] = 0x14;
18304 spec->autocfg.speaker_pins[0] = 0x17;
18305 spec->automute = 1;
18306 spec->automute_mode = ALC_AUTOMUTE_PIN;
18307 spec->ext_mic.pin = 0x18;
18308 spec->ext_mic.mux_idx = 0;
18309 spec->int_mic.pin = 0x12;
18310 spec->int_mic.mux_idx = 9;
18311 spec->auto_mic = 1;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018312}
18313
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020018314static void alc663_g71v_setup(struct hda_codec *codec)
Kailang Yang6dda9f42008-05-27 12:05:31 +020018315{
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020018316 struct alc_spec *spec = codec->spec;
18317 spec->autocfg.hp_pins[0] = 0x21;
18318 spec->autocfg.line_out_pins[0] = 0x15;
18319 spec->autocfg.speaker_pins[0] = 0x14;
18320 spec->automute = 1;
18321 spec->automute_mode = ALC_AUTOMUTE_AMP;
18322 spec->detect_line = 1;
18323 spec->automute_lines = 1;
18324 spec->ext_mic.pin = 0x18;
18325 spec->ext_mic.mux_idx = 0;
18326 spec->int_mic.pin = 0x12;
18327 spec->int_mic.mux_idx = 9;
18328 spec->auto_mic = 1;
Kailang Yang6dda9f42008-05-27 12:05:31 +020018329}
18330
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018331#define alc663_g50v_setup alc663_m51va_setup
18332
Kailang Yangf1d4e282008-08-26 14:03:29 +020018333static struct snd_kcontrol_new alc662_ecs_mixer[] = {
18334 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020018335 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018336
David Henningsson5f99f862011-01-04 15:24:24 +010018337 HDA_CODEC_VOLUME("Mic/LineIn Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010018338 HDA_CODEC_VOLUME("Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
18339 HDA_CODEC_MUTE("Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020018340
David Henningsson5f99f862011-01-04 15:24:24 +010018341 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010018342 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18343 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020018344 { } /* end */
18345};
18346
Chris Pockelé9541ba12009-05-12 08:08:53 +020018347static struct snd_kcontrol_new alc272_nc10_mixer[] = {
18348 /* Master Playback automatically created from Speaker and Headphone */
18349 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18350 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18351 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
18352 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
18353
David Henningsson8607f7c2010-12-20 14:43:54 +010018354 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
18355 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010018356 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018357
David Henningsson28c4edb2010-12-20 14:24:29 +010018358 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18359 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010018360 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018361 { } /* end */
18362};
18363
Takashi Iwaicb53c622007-08-10 17:21:45 +020018364#ifdef CONFIG_SND_HDA_POWER_SAVE
18365#define alc662_loopbacks alc880_loopbacks
18366#endif
18367
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018368
Sasha Alexandrdef319f2009-06-16 16:00:15 -040018369/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018370#define alc662_pcm_analog_playback alc880_pcm_analog_playback
18371#define alc662_pcm_analog_capture alc880_pcm_analog_capture
18372#define alc662_pcm_digital_playback alc880_pcm_digital_playback
18373#define alc662_pcm_digital_capture alc880_pcm_digital_capture
18374
18375/*
18376 * configuration and preset
18377 */
Takashi Iwaiea734962011-01-17 11:29:34 +010018378static const char * const alc662_models[ALC662_MODEL_LAST] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018379 [ALC662_3ST_2ch_DIG] = "3stack-dig",
18380 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
18381 [ALC662_3ST_6ch] = "3stack-6ch",
Raymond Yau4bf4a6c2011-04-05 22:47:15 +080018382 [ALC662_5ST_DIG] = "5stack-dig",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018383 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020018384 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010018385 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018386 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020018387 [ALC663_ASUS_M51VA] = "m51va",
18388 [ALC663_ASUS_G71V] = "g71v",
18389 [ALC663_ASUS_H13] = "h13",
18390 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018391 [ALC663_ASUS_MODE1] = "asus-mode1",
18392 [ALC662_ASUS_MODE2] = "asus-mode2",
18393 [ALC663_ASUS_MODE3] = "asus-mode3",
18394 [ALC663_ASUS_MODE4] = "asus-mode4",
18395 [ALC663_ASUS_MODE5] = "asus-mode5",
18396 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010018397 [ALC663_ASUS_MODE7] = "asus-mode7",
18398 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020018399 [ALC272_DELL] = "dell",
18400 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020018401 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018402 [ALC662_AUTO] = "auto",
18403};
18404
18405static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010018406 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020018407 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18408 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018409 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
18410 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010018411 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018412 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
18413 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
18414 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
18415 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018416 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
18417 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018418 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018419 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
18420 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
18421 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
18422 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
18423 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018424 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018425 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
18426 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018427 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
18428 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
18429 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
18430 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018431 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018432 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
18433 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
18434 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018435 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
18436 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
18437 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
18438 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018439 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018440 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
18441 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020018442 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018443 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
18444 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
18445 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018446 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010018447 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018448 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
18449 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018450 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
18451 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
18452 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018453 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018454 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
18455 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018456 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018457 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018458 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018459 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18460 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18461 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018462 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018463 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18464 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018465 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018466 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018467 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018468 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018469 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18470 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018471 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018472 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018473 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018474 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018475 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018476 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018477 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018478 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018479 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18480 ALC663_ASUS_H13),
Anisse Astier965b76d2011-02-10 13:14:44 +010018481 SND_PCI_QUIRK(0x1991, 0x5628, "Ordissimo EVE", ALC662_LENOVO_101E),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018482 {}
18483};
18484
18485static struct alc_config_preset alc662_presets[] = {
18486 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018487 .mixers = { alc662_3ST_2ch_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018488 .init_verbs = { alc662_init_verbs, alc662_eapd_init_verbs },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018489 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18490 .dac_nids = alc662_dac_nids,
18491 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018492 .dig_in_nid = ALC662_DIGIN_NID,
18493 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18494 .channel_mode = alc662_3ST_2ch_modes,
18495 .input_mux = &alc662_capture_source,
18496 },
18497 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018498 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018499 .init_verbs = { alc662_init_verbs, alc662_eapd_init_verbs },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018500 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18501 .dac_nids = alc662_dac_nids,
18502 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018503 .dig_in_nid = ALC662_DIGIN_NID,
18504 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18505 .channel_mode = alc662_3ST_6ch_modes,
18506 .need_dac_fix = 1,
18507 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018508 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018509 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018510 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018511 .init_verbs = { alc662_init_verbs, alc662_eapd_init_verbs },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018512 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18513 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018514 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18515 .channel_mode = alc662_3ST_6ch_modes,
18516 .need_dac_fix = 1,
18517 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018518 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018519 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018520 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018521 .init_verbs = { alc662_init_verbs, alc662_eapd_init_verbs },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018522 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18523 .dac_nids = alc662_dac_nids,
18524 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018525 .dig_in_nid = ALC662_DIGIN_NID,
18526 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18527 .channel_mode = alc662_5stack_modes,
18528 .input_mux = &alc662_capture_source,
18529 },
18530 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018531 .mixers = { alc662_lenovo_101e_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018532 .init_verbs = { alc662_init_verbs,
18533 alc662_eapd_init_verbs,
18534 alc662_sue_init_verbs },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018535 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18536 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018537 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18538 .channel_mode = alc662_3ST_2ch_modes,
18539 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020018540 .unsol_event = alc_sku_unsol_event,
18541 .setup = alc662_lenovo_101e_setup,
18542 .init_hook = alc_inithook,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018543 },
Kailang Yang291702f2007-10-16 14:28:03 +020018544 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018545 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018546 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018547 alc662_eapd_init_verbs,
Kailang Yang291702f2007-10-16 14:28:03 +020018548 alc662_eeepc_sue_init_verbs },
18549 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18550 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018551 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18552 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwaie9427962011-04-28 15:46:07 +020018553 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018554 .setup = alc662_eeepc_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020018555 .init_hook = alc_inithook,
Kailang Yang291702f2007-10-16 14:28:03 +020018556 },
Kailang Yang8c427222008-01-10 13:03:59 +010018557 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018558 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018559 alc662_chmode_mixer },
18560 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018561 alc662_eapd_init_verbs,
Kailang Yang8c427222008-01-10 13:03:59 +010018562 alc662_eeepc_ep20_sue_init_verbs },
18563 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18564 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018565 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18566 .channel_mode = alc662_3ST_6ch_modes,
18567 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020018568 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018569 .setup = alc662_eeepc_ep20_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020018570 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010018571 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018572 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018573 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018574 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018575 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018576 alc662_ecs_init_verbs },
18577 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18578 .dac_nids = alc662_dac_nids,
18579 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18580 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwaie9427962011-04-28 15:46:07 +020018581 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018582 .setup = alc662_eeepc_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020018583 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018584 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018585 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018586 .mixers = { alc663_m51va_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018587 .init_verbs = { alc662_init_verbs,
18588 alc662_eapd_init_verbs,
18589 alc663_m51va_init_verbs },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018590 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18591 .dac_nids = alc662_dac_nids,
18592 .dig_out_nid = ALC662_DIGOUT_NID,
18593 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18594 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018595 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018596 .setup = alc663_m51va_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018597 .init_hook = alc_inithook,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018598 },
18599 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018600 .mixers = { alc663_g71v_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018601 .init_verbs = { alc662_init_verbs,
18602 alc662_eapd_init_verbs,
18603 alc663_g71v_init_verbs },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018604 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18605 .dac_nids = alc662_dac_nids,
18606 .dig_out_nid = ALC662_DIGOUT_NID,
18607 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18608 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020018609 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018610 .setup = alc663_g71v_setup,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020018611 .init_hook = alc_inithook,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018612 },
18613 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018614 .mixers = { alc663_m51va_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018615 .init_verbs = { alc662_init_verbs,
18616 alc662_eapd_init_verbs,
18617 alc663_m51va_init_verbs },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018618 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18619 .dac_nids = alc662_dac_nids,
18620 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18621 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018622 .setup = alc663_m51va_setup,
18623 .unsol_event = alc_sku_unsol_event,
18624 .init_hook = alc_inithook,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018625 },
18626 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018627 .mixers = { alc663_g50v_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018628 .init_verbs = { alc662_init_verbs,
18629 alc662_eapd_init_verbs,
18630 alc663_g50v_init_verbs },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018631 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18632 .dac_nids = alc662_dac_nids,
18633 .dig_out_nid = ALC662_DIGOUT_NID,
18634 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18635 .channel_mode = alc662_3ST_6ch_modes,
18636 .input_mux = &alc663_capture_source,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018637 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018638 .setup = alc663_g50v_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018639 .init_hook = alc_inithook,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018640 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018641 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018642 .mixers = { alc663_m51va_mixer },
18643 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018644 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018645 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018646 alc663_21jd_amic_init_verbs },
18647 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18648 .hp_nid = 0x03,
18649 .dac_nids = alc662_dac_nids,
18650 .dig_out_nid = ALC662_DIGOUT_NID,
18651 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18652 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018653 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018654 .setup = alc663_mode1_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018655 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018656 },
18657 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018658 .mixers = { alc662_1bjd_mixer },
18659 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018660 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018661 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018662 alc662_1bjd_amic_init_verbs },
18663 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18664 .dac_nids = alc662_dac_nids,
18665 .dig_out_nid = ALC662_DIGOUT_NID,
18666 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18667 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018668 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018669 .setup = alc662_mode2_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018670 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018671 },
18672 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018673 .mixers = { alc663_two_hp_m1_mixer },
18674 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018675 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018676 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018677 alc663_two_hp_amic_m1_init_verbs },
18678 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18679 .hp_nid = 0x03,
18680 .dac_nids = alc662_dac_nids,
18681 .dig_out_nid = ALC662_DIGOUT_NID,
18682 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18683 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018684 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018685 .setup = alc663_mode3_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018686 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018687 },
18688 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018689 .mixers = { alc663_asus_21jd_clfe_mixer },
18690 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018691 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018692 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018693 alc663_21jd_amic_init_verbs},
18694 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18695 .hp_nid = 0x03,
18696 .dac_nids = alc662_dac_nids,
18697 .dig_out_nid = ALC662_DIGOUT_NID,
18698 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18699 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018700 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018701 .setup = alc663_mode4_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018702 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018703 },
18704 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018705 .mixers = { alc663_asus_15jd_clfe_mixer },
18706 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018707 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018708 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018709 alc663_15jd_amic_init_verbs },
18710 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18711 .hp_nid = 0x03,
18712 .dac_nids = alc662_dac_nids,
18713 .dig_out_nid = ALC662_DIGOUT_NID,
18714 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18715 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018716 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018717 .setup = alc663_mode5_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018718 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018719 },
18720 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018721 .mixers = { alc663_two_hp_m2_mixer },
18722 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018723 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018724 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018725 alc663_two_hp_amic_m2_init_verbs },
18726 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18727 .hp_nid = 0x03,
18728 .dac_nids = alc662_dac_nids,
18729 .dig_out_nid = ALC662_DIGOUT_NID,
18730 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18731 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018732 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018733 .setup = alc663_mode6_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018734 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018735 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018736 [ALC663_ASUS_MODE7] = {
18737 .mixers = { alc663_mode7_mixer },
18738 .cap_mixer = alc662_auto_capture_mixer,
18739 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018740 alc662_eapd_init_verbs,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018741 alc663_mode7_init_verbs },
18742 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18743 .hp_nid = 0x03,
18744 .dac_nids = alc662_dac_nids,
18745 .dig_out_nid = ALC662_DIGOUT_NID,
18746 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18747 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018748 .unsol_event = alc_sku_unsol_event,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018749 .setup = alc663_mode7_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018750 .init_hook = alc_inithook,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018751 },
18752 [ALC663_ASUS_MODE8] = {
18753 .mixers = { alc663_mode8_mixer },
18754 .cap_mixer = alc662_auto_capture_mixer,
18755 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018756 alc662_eapd_init_verbs,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018757 alc663_mode8_init_verbs },
18758 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18759 .hp_nid = 0x03,
18760 .dac_nids = alc662_dac_nids,
18761 .dig_out_nid = ALC662_DIGOUT_NID,
18762 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18763 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018764 .unsol_event = alc_sku_unsol_event,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018765 .setup = alc663_mode8_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018766 .init_hook = alc_inithook,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018767 },
Kailang Yang622e84c2009-04-21 07:39:04 +020018768 [ALC272_DELL] = {
18769 .mixers = { alc663_m51va_mixer },
18770 .cap_mixer = alc272_auto_capture_mixer,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018771 .init_verbs = { alc662_init_verbs,
18772 alc662_eapd_init_verbs,
18773 alc272_dell_init_verbs },
Kailang Yang622e84c2009-04-21 07:39:04 +020018774 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
Takashi Iwai1bc7cf92011-04-06 09:42:29 +020018775 .dac_nids = alc272_dac_nids,
Kailang Yang622e84c2009-04-21 07:39:04 +020018776 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18777 .adc_nids = alc272_adc_nids,
18778 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
18779 .capsrc_nids = alc272_capsrc_nids,
18780 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018781 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018782 .setup = alc663_m51va_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018783 .init_hook = alc_inithook,
Kailang Yang622e84c2009-04-21 07:39:04 +020018784 },
18785 [ALC272_DELL_ZM1] = {
18786 .mixers = { alc663_m51va_mixer },
18787 .cap_mixer = alc662_auto_capture_mixer,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018788 .init_verbs = { alc662_init_verbs,
18789 alc662_eapd_init_verbs,
18790 alc272_dell_zm1_init_verbs },
Kailang Yang622e84c2009-04-21 07:39:04 +020018791 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
Takashi Iwai1bc7cf92011-04-06 09:42:29 +020018792 .dac_nids = alc272_dac_nids,
Kailang Yang622e84c2009-04-21 07:39:04 +020018793 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18794 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018795 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020018796 .capsrc_nids = alc662_capsrc_nids,
18797 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018798 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018799 .setup = alc663_m51va_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018800 .init_hook = alc_inithook,
Kailang Yang622e84c2009-04-21 07:39:04 +020018801 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020018802 [ALC272_SAMSUNG_NC10] = {
18803 .mixers = { alc272_nc10_mixer },
18804 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018805 alc662_eapd_init_verbs,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018806 alc663_21jd_amic_init_verbs },
18807 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18808 .dac_nids = alc272_dac_nids,
18809 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18810 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018811 /*.input_mux = &alc272_nc10_capture_source,*/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018812 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018813 .setup = alc663_mode4_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018814 .init_hook = alc_inithook,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018815 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018816};
18817
18818
18819/*
18820 * BIOS auto configuration
18821 */
18822
Takashi Iwai7085ec12009-10-02 09:03:58 +020018823/* convert from MIX nid to DAC */
Takashi Iwai604401a2011-04-27 15:14:23 +020018824static hda_nid_t alc_auto_mix_to_dac(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018825{
Takashi Iwai604401a2011-04-27 15:14:23 +020018826 hda_nid_t list[5];
Takashi Iwai1304ac82011-04-06 15:16:21 +020018827 int i, num;
18828
18829 num = snd_hda_get_connections(codec, nid, list, ARRAY_SIZE(list));
18830 for (i = 0; i < num; i++) {
18831 if (get_wcaps_type(get_wcaps(codec, list[i])) == AC_WID_AUD_OUT)
18832 return list[i];
18833 }
18834 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018835}
18836
Takashi Iwai604401a2011-04-27 15:14:23 +020018837/* go down to the selector widget before the mixer */
18838static hda_nid_t alc_go_down_to_selector(struct hda_codec *codec, hda_nid_t pin)
18839{
18840 hda_nid_t srcs[5];
18841 int num = snd_hda_get_connections(codec, pin, srcs,
18842 ARRAY_SIZE(srcs));
18843 if (num != 1 ||
18844 get_wcaps_type(get_wcaps(codec, srcs[0])) != AC_WID_AUD_SEL)
18845 return pin;
18846 return srcs[0];
18847}
18848
Takashi Iwai7085ec12009-10-02 09:03:58 +020018849/* get MIX nid connected to the given pin targeted to DAC */
Takashi Iwai604401a2011-04-27 15:14:23 +020018850static hda_nid_t alc_auto_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018851 hda_nid_t dac)
18852{
David Henningssoncc1c4522010-11-24 14:17:47 +010018853 hda_nid_t mix[5];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018854 int i, num;
18855
Takashi Iwai604401a2011-04-27 15:14:23 +020018856 pin = alc_go_down_to_selector(codec, pin);
Takashi Iwai7085ec12009-10-02 09:03:58 +020018857 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
18858 for (i = 0; i < num; i++) {
Takashi Iwai604401a2011-04-27 15:14:23 +020018859 if (alc_auto_mix_to_dac(codec, mix[i]) == dac)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018860 return mix[i];
18861 }
18862 return 0;
18863}
18864
Takashi Iwaice764ab2011-04-27 16:35:23 +020018865/* select the connection from pin to DAC if needed */
18866static int alc_auto_select_dac(struct hda_codec *codec, hda_nid_t pin,
18867 hda_nid_t dac)
18868{
18869 hda_nid_t mix[5];
18870 int i, num;
18871
18872 pin = alc_go_down_to_selector(codec, pin);
18873 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
18874 if (num < 2)
18875 return 0;
18876 for (i = 0; i < num; i++) {
18877 if (alc_auto_mix_to_dac(codec, mix[i]) == dac) {
18878 snd_hda_codec_update_cache(codec, pin, 0,
18879 AC_VERB_SET_CONNECT_SEL, i);
18880 return 0;
18881 }
18882 }
18883 return 0;
18884}
18885
Takashi Iwai7085ec12009-10-02 09:03:58 +020018886/* look for an empty DAC slot */
Takashi Iwai604401a2011-04-27 15:14:23 +020018887static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018888{
18889 struct alc_spec *spec = codec->spec;
18890 hda_nid_t srcs[5];
18891 int i, j, num;
18892
Takashi Iwai604401a2011-04-27 15:14:23 +020018893 pin = alc_go_down_to_selector(codec, pin);
Takashi Iwai7085ec12009-10-02 09:03:58 +020018894 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
Takashi Iwai7085ec12009-10-02 09:03:58 +020018895 for (i = 0; i < num; i++) {
Takashi Iwai604401a2011-04-27 15:14:23 +020018896 hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]);
Takashi Iwai7085ec12009-10-02 09:03:58 +020018897 if (!nid)
18898 continue;
18899 for (j = 0; j < spec->multiout.num_dacs; j++)
18900 if (spec->multiout.dac_nids[j] == nid)
18901 break;
18902 if (j >= spec->multiout.num_dacs)
18903 return nid;
18904 }
18905 return 0;
18906}
18907
18908/* fill in the dac_nids table from the parsed pin configuration */
18909static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
18910 const struct auto_pin_cfg *cfg)
18911{
18912 struct alc_spec *spec = codec->spec;
18913 int i;
18914 hda_nid_t dac;
18915
18916 spec->multiout.dac_nids = spec->private_dac_nids;
18917 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai604401a2011-04-27 15:14:23 +020018918 dac = alc_auto_look_for_dac(codec, cfg->line_out_pins[i]);
Takashi Iwai7085ec12009-10-02 09:03:58 +020018919 if (!dac)
18920 continue;
18921 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
18922 }
18923 return 0;
18924}
18925
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010018926static inline int __alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
18927 hda_nid_t nid, int idx, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018928{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010018929 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018930 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
18931}
18932
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010018933static inline int __alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
18934 hda_nid_t nid, int idx, unsigned int chs)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018935{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010018936 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018937 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
18938}
18939
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010018940#define alc662_add_vol_ctl(spec, pfx, nid, chs) \
18941 __alc662_add_vol_ctl(spec, pfx, nid, 0, chs)
18942#define alc662_add_sw_ctl(spec, pfx, nid, chs) \
18943 __alc662_add_sw_ctl(spec, pfx, nid, 0, chs)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018944#define alc662_add_stereo_vol(spec, pfx, nid) \
18945 alc662_add_vol_ctl(spec, pfx, nid, 3)
18946#define alc662_add_stereo_sw(spec, pfx, nid) \
18947 alc662_add_sw_ctl(spec, pfx, nid, 3)
18948
18949/* add playback controls from the parsed DAC table */
18950static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
18951 const struct auto_pin_cfg *cfg)
18952{
18953 struct alc_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +010018954 static const char * const chname[4] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018955 "Front", "Surround", NULL /*CLFE*/, "Side"
18956 };
Takashi Iwaice764ab2011-04-27 16:35:23 +020018957 const char *pfx = alc_get_line_out_pfx(spec, true);
18958 hda_nid_t nid, mix, pin;
18959 int i, err, noutputs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018960
Takashi Iwaice764ab2011-04-27 16:35:23 +020018961 noutputs = cfg->line_outs;
18962 if (spec->multi_ios > 0)
18963 noutputs += spec->multi_ios;
18964
18965 for (i = 0; i < noutputs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018966 nid = spec->multiout.dac_nids[i];
18967 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018968 continue;
Takashi Iwaice764ab2011-04-27 16:35:23 +020018969 if (i >= cfg->line_outs)
18970 pin = spec->multi_io[i - 1].pin;
18971 else
18972 pin = cfg->line_out_pins[i];
18973 mix = alc_auto_dac_to_mix(codec, pin, nid);
Takashi Iwai7085ec12009-10-02 09:03:58 +020018974 if (!mix)
18975 continue;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010018976 if (!pfx && i == 2) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018977 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018978 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018979 if (err < 0)
18980 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018981 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018982 if (err < 0)
18983 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018984 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018985 if (err < 0)
18986 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018987 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018988 if (err < 0)
18989 return err;
18990 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010018991 const char *name = pfx;
David Henningsson5a882642011-03-23 08:35:07 +010018992 int index = i;
18993 if (!name) {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010018994 name = chname[i];
David Henningsson5a882642011-03-23 08:35:07 +010018995 index = 0;
18996 }
18997 err = __alc662_add_vol_ctl(spec, name, nid, index, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018998 if (err < 0)
18999 return err;
David Henningsson5a882642011-03-23 08:35:07 +010019000 err = __alc662_add_sw_ctl(spec, name, mix, index, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019001 if (err < 0)
19002 return err;
19003 }
19004 }
19005 return 0;
19006}
19007
19008/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019009/* return DAC nid if any new DAC is assigned */
19010static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019011 const char *pfx)
19012{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019013 struct alc_spec *spec = codec->spec;
19014 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019015 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019016
19017 if (!pin)
19018 return 0;
Takashi Iwai604401a2011-04-27 15:14:23 +020019019 nid = alc_auto_look_for_dac(codec, pin);
Takashi Iwai7085ec12009-10-02 09:03:58 +020019020 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019021 /* the corresponding DAC is already occupied */
19022 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
19023 return 0; /* no way */
19024 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019025 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019026 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
19027 }
19028
Takashi Iwai604401a2011-04-27 15:14:23 +020019029 mix = alc_auto_dac_to_mix(codec, pin, nid);
Takashi Iwai7085ec12009-10-02 09:03:58 +020019030 if (!mix)
19031 return 0;
19032 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
19033 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020019034 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019035 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
19036 if (err < 0)
19037 return err;
19038 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019039}
19040
19041/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020019042#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020019043 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019044
19045static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
19046 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019047 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019048{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019049 int i, num;
Takashi Iwaice503f32010-07-30 10:37:29 +020019050 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019051
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019052 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai7085ec12009-10-02 09:03:58 +020019053 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
Takashi Iwai7085ec12009-10-02 09:03:58 +020019054 for (i = 0; i < num; i++) {
Takashi Iwai604401a2011-04-27 15:14:23 +020019055 if (alc_auto_mix_to_dac(codec, srcs[i]) != dac)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019056 continue;
Takashi Iwai0e53f342011-04-07 12:27:32 +020019057 /* need the manual connection? */
19058 if (num > 1)
19059 snd_hda_codec_write(codec, nid, 0,
19060 AC_VERB_SET_CONNECT_SEL, i);
19061 /* unmute mixer widget inputs */
19062 snd_hda_codec_write(codec, srcs[i], 0,
19063 AC_VERB_SET_AMP_GAIN_MUTE,
19064 AMP_IN_UNMUTE(0));
19065 snd_hda_codec_write(codec, srcs[i], 0,
19066 AC_VERB_SET_AMP_GAIN_MUTE,
19067 AMP_IN_UNMUTE(1));
Takashi Iwai7085ec12009-10-02 09:03:58 +020019068 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019069 }
19070}
19071
19072static void alc662_auto_init_multi_out(struct hda_codec *codec)
19073{
19074 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019075 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019076 int i;
19077
19078 for (i = 0; i <= HDA_SIDE; i++) {
19079 hda_nid_t nid = spec->autocfg.line_out_pins[i];
19080 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020019081 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019082 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019083 }
19084}
19085
19086static void alc662_auto_init_hp_out(struct hda_codec *codec)
19087{
19088 struct alc_spec *spec = codec->spec;
19089 hda_nid_t pin;
19090
19091 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019092 if (pin)
19093 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
19094 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019095 pin = spec->autocfg.speaker_pins[0];
19096 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019097 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
19098 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019099}
19100
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019101#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
19102
19103static void alc662_auto_init_analog_input(struct hda_codec *codec)
19104{
19105 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019106 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019107 int i;
19108
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019109 for (i = 0; i < cfg->num_inputs; i++) {
19110 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019111 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020019112 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010019113 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010019114 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019115 snd_hda_codec_write(codec, nid, 0,
19116 AC_VERB_SET_AMP_GAIN_MUTE,
19117 AMP_OUT_MUTE);
19118 }
19119 }
19120}
19121
Takashi Iwaif511b012008-08-15 16:46:42 +020019122#define alc662_auto_init_input_src alc882_auto_init_input_src
19123
Takashi Iwaice764ab2011-04-27 16:35:23 +020019124/*
19125 * multi-io helper
19126 */
19127static int alc_auto_fill_multi_ios(struct hda_codec *codec,
19128 unsigned int location)
19129{
19130 struct alc_spec *spec = codec->spec;
19131 struct auto_pin_cfg *cfg = &spec->autocfg;
19132 int type, i, num_pins = 0;
19133
19134 for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) {
19135 for (i = 0; i < cfg->num_inputs; i++) {
19136 hda_nid_t nid = cfg->inputs[i].pin;
19137 hda_nid_t dac;
19138 unsigned int defcfg, caps;
19139 if (cfg->inputs[i].type != type)
19140 continue;
19141 defcfg = snd_hda_codec_get_pincfg(codec, nid);
19142 if (get_defcfg_connect(defcfg) != AC_JACK_PORT_COMPLEX)
19143 continue;
19144 if (location && get_defcfg_location(defcfg) != location)
19145 continue;
19146 caps = snd_hda_query_pin_caps(codec, nid);
19147 if (!(caps & AC_PINCAP_OUT))
19148 continue;
19149 dac = alc_auto_look_for_dac(codec, nid);
19150 if (!dac)
19151 continue;
19152 spec->multi_io[num_pins].pin = nid;
19153 spec->multi_io[num_pins].dac = dac;
19154 num_pins++;
19155 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19156 }
19157 }
19158 spec->multiout.num_dacs = 1;
19159 if (num_pins < 2)
19160 return 0;
19161 return num_pins;
19162}
19163
19164static int alc_auto_ch_mode_info(struct snd_kcontrol *kcontrol,
19165 struct snd_ctl_elem_info *uinfo)
19166{
19167 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
19168 struct alc_spec *spec = codec->spec;
19169
19170 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
19171 uinfo->count = 1;
19172 uinfo->value.enumerated.items = spec->multi_ios + 1;
19173 if (uinfo->value.enumerated.item > spec->multi_ios)
19174 uinfo->value.enumerated.item = spec->multi_ios;
19175 sprintf(uinfo->value.enumerated.name, "%dch",
19176 (uinfo->value.enumerated.item + 1) * 2);
19177 return 0;
19178}
19179
19180static int alc_auto_ch_mode_get(struct snd_kcontrol *kcontrol,
19181 struct snd_ctl_elem_value *ucontrol)
19182{
19183 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
19184 struct alc_spec *spec = codec->spec;
19185 ucontrol->value.enumerated.item[0] = (spec->ext_channel_count - 1) / 2;
19186 return 0;
19187}
19188
19189static int alc_set_multi_io(struct hda_codec *codec, int idx, bool output)
19190{
19191 struct alc_spec *spec = codec->spec;
19192 hda_nid_t nid = spec->multi_io[idx].pin;
19193
19194 if (!spec->multi_io[idx].ctl_in)
19195 spec->multi_io[idx].ctl_in =
19196 snd_hda_codec_read(codec, nid, 0,
19197 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
19198 if (output) {
19199 snd_hda_codec_update_cache(codec, nid, 0,
19200 AC_VERB_SET_PIN_WIDGET_CONTROL,
19201 PIN_OUT);
19202 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
19203 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
19204 HDA_AMP_MUTE, 0);
19205 alc_auto_select_dac(codec, nid, spec->multi_io[idx].dac);
19206 } else {
19207 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
19208 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
19209 HDA_AMP_MUTE, HDA_AMP_MUTE);
19210 snd_hda_codec_update_cache(codec, nid, 0,
19211 AC_VERB_SET_PIN_WIDGET_CONTROL,
19212 spec->multi_io[idx].ctl_in);
19213 }
19214 return 0;
19215}
19216
19217static int alc_auto_ch_mode_put(struct snd_kcontrol *kcontrol,
19218 struct snd_ctl_elem_value *ucontrol)
19219{
19220 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
19221 struct alc_spec *spec = codec->spec;
19222 int i, ch;
19223
19224 ch = ucontrol->value.enumerated.item[0];
19225 if (ch < 0 || ch > spec->multi_ios)
19226 return -EINVAL;
19227 if (ch == (spec->ext_channel_count - 1) / 2)
19228 return 0;
19229 spec->ext_channel_count = (ch + 1) * 2;
19230 for (i = 0; i < spec->multi_ios; i++)
19231 alc_set_multi_io(codec, i, i < ch);
19232 spec->multiout.max_channels = spec->ext_channel_count;
19233 return 1;
19234}
19235
19236static struct snd_kcontrol_new alc_auto_channel_mode_enum = {
19237 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
19238 .name = "Channel Mode",
19239 .info = alc_auto_ch_mode_info,
19240 .get = alc_auto_ch_mode_get,
19241 .put = alc_auto_ch_mode_put,
19242};
19243
19244static int alc_auto_add_multi_channel_mode(struct hda_codec *codec)
19245{
19246 struct alc_spec *spec = codec->spec;
19247 struct auto_pin_cfg *cfg = &spec->autocfg;
19248 unsigned int location, defcfg;
19249 int num_pins;
19250
19251 if (cfg->line_outs != 1 ||
19252 cfg->line_out_type != AUTO_PIN_LINE_OUT)
19253 return 0;
19254
19255 defcfg = snd_hda_codec_get_pincfg(codec, cfg->line_out_pins[0]);
19256 location = get_defcfg_location(defcfg);
19257
19258 num_pins = alc_auto_fill_multi_ios(codec, location);
19259 if (num_pins > 0) {
19260 struct snd_kcontrol_new *knew;
19261
19262 knew = alc_kcontrol_new(spec);
19263 if (!knew)
19264 return -ENOMEM;
19265 *knew = alc_auto_channel_mode_enum;
19266 knew->name = kstrdup("Channel Mode", GFP_KERNEL);
19267 if (!knew->name)
19268 return -ENOMEM;
19269
19270 spec->multi_ios = num_pins;
19271 spec->ext_channel_count = 2;
19272 spec->multiout.num_dacs = num_pins + 1;
19273 }
19274 return 0;
19275}
19276
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019277static int alc662_parse_auto_config(struct hda_codec *codec)
19278{
19279 struct alc_spec *spec = codec->spec;
19280 int err;
19281 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
19282
19283 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19284 alc662_ignore);
19285 if (err < 0)
19286 return err;
19287 if (!spec->autocfg.line_outs)
19288 return 0; /* can't find valid BIOS pin config */
19289
Takashi Iwai7085ec12009-10-02 09:03:58 +020019290 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019291 if (err < 0)
19292 return err;
Takashi Iwaice764ab2011-04-27 16:35:23 +020019293 err = alc_auto_add_multi_channel_mode(codec);
19294 if (err < 0)
19295 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019296 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019297 if (err < 0)
19298 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019299 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019300 spec->autocfg.speaker_pins[0],
19301 "Speaker");
19302 if (err < 0)
19303 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019304 if (err)
19305 spec->multiout.extra_out_nid[0] = err;
19306 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019307 "Headphone");
19308 if (err < 0)
19309 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019310 if (err)
19311 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019312 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019313 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019314 return err;
19315
19316 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
19317
Takashi Iwai757899a2010-07-30 10:48:14 +020019318 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019319
Takashi Iwai603c4012008-07-30 15:01:44 +020019320 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010019321 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019322
19323 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020019324 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020019325
Takashi Iwaiee979a142008-09-02 15:42:20 +020019326 err = alc_auto_add_mic_boost(codec);
19327 if (err < 0)
19328 return err;
19329
Kailang Yang6227cdc2010-02-25 08:36:52 +010019330 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
19331 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
19332 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
19333 else
19334 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020019335
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019336 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019337}
19338
19339/* additional initialization for auto-configuration model */
19340static void alc662_auto_init(struct hda_codec *codec)
19341{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019342 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019343 alc662_auto_init_multi_out(codec);
19344 alc662_auto_init_hp_out(codec);
19345 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020019346 alc662_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019347 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019348 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020019349 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019350}
19351
Todd Broch6be79482010-12-07 16:51:05 -080019352static void alc272_fixup_mario(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019353 const struct alc_fixup *fix, int action)
Takashi Iwai6fc398c2011-01-13 14:36:37 +010019354{
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019355 if (action != ALC_FIXUP_ACT_PROBE)
Takashi Iwai6fc398c2011-01-13 14:36:37 +010019356 return;
Todd Broch6be79482010-12-07 16:51:05 -080019357 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
19358 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
19359 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
19360 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
19361 (0 << AC_AMPCAP_MUTE_SHIFT)))
19362 printk(KERN_WARNING
19363 "hda_codec: failed to override amp caps for NID 0x2\n");
19364}
19365
David Henningsson6cb3b702010-09-09 08:51:44 +020019366enum {
Daniel T Chen2df03512010-10-10 22:39:28 -040019367 ALC662_FIXUP_ASPIRE,
David Henningsson6cb3b702010-09-09 08:51:44 +020019368 ALC662_FIXUP_IDEAPAD,
Todd Broch6be79482010-12-07 16:51:05 -080019369 ALC272_FIXUP_MARIO,
Anisse Astierd2ebd472011-01-20 12:36:21 +010019370 ALC662_FIXUP_CZC_P10T,
Takashi Iwaic6b35872011-03-28 12:05:31 +020019371 ALC662_FIXUP_GIGABYTE,
David Henningsson6cb3b702010-09-09 08:51:44 +020019372};
19373
19374static const struct alc_fixup alc662_fixups[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -040019375 [ALC662_FIXUP_ASPIRE] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019376 .type = ALC_FIXUP_PINS,
19377 .v.pins = (const struct alc_pincfg[]) {
Daniel T Chen2df03512010-10-10 22:39:28 -040019378 { 0x15, 0x99130112 }, /* subwoofer */
19379 { }
19380 }
19381 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019382 [ALC662_FIXUP_IDEAPAD] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019383 .type = ALC_FIXUP_PINS,
19384 .v.pins = (const struct alc_pincfg[]) {
David Henningsson6cb3b702010-09-09 08:51:44 +020019385 { 0x17, 0x99130112 }, /* subwoofer */
19386 { }
19387 }
19388 },
Todd Broch6be79482010-12-07 16:51:05 -080019389 [ALC272_FIXUP_MARIO] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019390 .type = ALC_FIXUP_FUNC,
19391 .v.func = alc272_fixup_mario,
Anisse Astierd2ebd472011-01-20 12:36:21 +010019392 },
19393 [ALC662_FIXUP_CZC_P10T] = {
19394 .type = ALC_FIXUP_VERBS,
19395 .v.verbs = (const struct hda_verb[]) {
19396 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
19397 {}
19398 }
19399 },
Takashi Iwaic6b35872011-03-28 12:05:31 +020019400 [ALC662_FIXUP_GIGABYTE] = {
19401 .type = ALC_FIXUP_PINS,
19402 .v.pins = (const struct alc_pincfg[]) {
19403 { 0x14, 0x1114410 }, /* set as speaker */
19404 { }
19405 }
19406 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019407};
19408
19409static struct snd_pci_quirk alc662_fixup_tbl[] = {
David Henningssona6c47a82011-02-10 15:39:19 +010019410 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
Daniel T Chen2df03512010-10-10 22:39:28 -040019411 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
Daniel T Chena0e90ac2010-11-20 10:20:35 -050019412 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
Takashi Iwaic6b35872011-03-28 12:05:31 +020019413 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte", ALC662_FIXUP_GIGABYTE),
Valentine Sinitsynd4118582010-10-01 22:24:08 +060019414 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
David Henningsson6cb3b702010-09-09 08:51:44 +020019415 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
Anisse Astierd2ebd472011-01-20 12:36:21 +010019416 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
David Henningsson6cb3b702010-09-09 08:51:44 +020019417 {}
19418};
19419
Todd Broch6be79482010-12-07 16:51:05 -080019420static const struct alc_model_fixup alc662_fixup_models[] = {
19421 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
19422 {}
19423};
David Henningsson6cb3b702010-09-09 08:51:44 +020019424
19425
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019426static int patch_alc662(struct hda_codec *codec)
19427{
19428 struct alc_spec *spec;
19429 int err, board_config;
Kailang Yang693194f2010-10-21 08:51:48 +020019430 int coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019431
19432 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19433 if (!spec)
19434 return -ENOMEM;
19435
19436 codec->spec = spec;
19437
Kailang Yangda00c242010-03-19 11:23:45 +010019438 alc_auto_parse_customize_define(codec);
19439
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020019440 alc_fix_pll_init(codec, 0x20, 0x04, 15);
19441
Kailang Yang693194f2010-10-21 08:51:48 +020019442 coef = alc_read_coef_idx(codec, 0);
19443 if (coef == 0x8020 || coef == 0x8011)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019444 alc_codec_rename(codec, "ALC661");
Kailang Yang693194f2010-10-21 08:51:48 +020019445 else if (coef & (1 << 14) &&
19446 codec->bus->pci->subsystem_vendor == 0x1025 &&
19447 spec->cdefine.platform_type == 1)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019448 alc_codec_rename(codec, "ALC272X");
Kailang Yang693194f2010-10-21 08:51:48 +020019449 else if (coef == 0x4011)
19450 alc_codec_rename(codec, "ALC656");
Kailang Yang274693f2009-12-03 10:07:50 +010019451
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019452 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
19453 alc662_models,
19454 alc662_cfg_tbl);
19455 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020019456 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19457 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019458 board_config = ALC662_AUTO;
19459 }
19460
19461 if (board_config == ALC662_AUTO) {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019462 alc_pick_fixup(codec, alc662_fixup_models,
19463 alc662_fixup_tbl, alc662_fixups);
19464 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019465 /* automatic parse from the BIOS config */
19466 err = alc662_parse_auto_config(codec);
19467 if (err < 0) {
19468 alc_free(codec);
19469 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019470 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019471 printk(KERN_INFO
19472 "hda_codec: Cannot set up configuration "
19473 "from BIOS. Using base mode...\n");
19474 board_config = ALC662_3ST_2ch_DIG;
19475 }
19476 }
19477
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019478 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020019479 err = snd_hda_attach_beep_device(codec, 0x1);
19480 if (err < 0) {
19481 alc_free(codec);
19482 return err;
19483 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090019484 }
19485
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019486 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020019487 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019488
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019489 spec->stream_analog_playback = &alc662_pcm_analog_playback;
19490 spec->stream_analog_capture = &alc662_pcm_analog_capture;
19491
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019492 spec->stream_digital_playback = &alc662_pcm_digital_playback;
19493 spec->stream_digital_capture = &alc662_pcm_digital_capture;
19494
Takashi Iwaidd704692009-08-11 08:45:11 +020019495 if (!spec->adc_nids) {
19496 spec->adc_nids = alc662_adc_nids;
19497 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
19498 }
19499 if (!spec->capsrc_nids)
19500 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019501
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019502 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019503 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019504
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019505 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010019506 switch (codec->vendor_id) {
19507 case 0x10ec0662:
19508 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
19509 break;
19510 case 0x10ec0272:
19511 case 0x10ec0663:
19512 case 0x10ec0665:
19513 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
19514 break;
19515 case 0x10ec0273:
19516 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
19517 break;
19518 }
Kailang Yangcec27c82010-02-04 14:18:18 +010019519 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010019520 spec->vmaster_nid = 0x02;
19521
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019522 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
19523
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019524 codec->patch_ops = alc_patch_ops;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019525 if (board_config == ALC662_AUTO)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019526 spec->init_hook = alc662_auto_init;
Takashi Iwai1c7161532011-04-07 10:37:16 +020019527 spec->shutup = alc_eapd_shutup;
David Henningsson6cb3b702010-09-09 08:51:44 +020019528
Kailang Yangbf1b0222010-10-21 08:49:56 +020019529 alc_init_jacks(codec);
19530
Takashi Iwaicb53c622007-08-10 17:21:45 +020019531#ifdef CONFIG_SND_HDA_POWER_SAVE
19532 if (!spec->loopback.amplist)
19533 spec->loopback.amplist = alc662_loopbacks;
19534#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019535
19536 return 0;
19537}
19538
Kailang Yang274693f2009-12-03 10:07:50 +010019539static int patch_alc888(struct hda_codec *codec)
19540{
19541 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19542 kfree(codec->chip_name);
Kailang Yang01e0f132010-11-22 10:59:36 +010019543 if (codec->vendor_id == 0x10ec0887)
19544 codec->chip_name = kstrdup("ALC887-VD", GFP_KERNEL);
19545 else
19546 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019547 if (!codec->chip_name) {
19548 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019549 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019550 }
19551 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019552 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019553 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019554}
19555
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019556/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019557 * ALC680 support
19558 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019559#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019560#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19561#define alc680_modes alc260_modes
19562
19563static hda_nid_t alc680_dac_nids[3] = {
19564 /* Lout1, Lout2, hp */
19565 0x02, 0x03, 0x04
19566};
19567
19568static hda_nid_t alc680_adc_nids[3] = {
19569 /* ADC0-2 */
19570 /* DMIC, MIC, Line-in*/
19571 0x07, 0x08, 0x09
19572};
19573
Kailang Yangc69aefa2010-08-17 10:39:22 +020019574/*
19575 * Analog capture ADC cgange
19576 */
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019577static void alc680_rec_autoswitch(struct hda_codec *codec)
19578{
19579 struct alc_spec *spec = codec->spec;
19580 struct auto_pin_cfg *cfg = &spec->autocfg;
19581 int pin_found = 0;
19582 int type_found = AUTO_PIN_LAST;
19583 hda_nid_t nid;
19584 int i;
19585
19586 for (i = 0; i < cfg->num_inputs; i++) {
19587 nid = cfg->inputs[i].pin;
19588 if (!(snd_hda_query_pin_caps(codec, nid) &
19589 AC_PINCAP_PRES_DETECT))
19590 continue;
19591 if (snd_hda_jack_detect(codec, nid)) {
19592 if (cfg->inputs[i].type < type_found) {
19593 type_found = cfg->inputs[i].type;
19594 pin_found = nid;
19595 }
19596 }
19597 }
19598
19599 nid = 0x07;
19600 if (pin_found)
19601 snd_hda_get_connections(codec, pin_found, &nid, 1);
19602
19603 if (nid != spec->cur_adc)
19604 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
19605 spec->cur_adc = nid;
19606 snd_hda_codec_setup_stream(codec, nid, spec->cur_adc_stream_tag, 0,
19607 spec->cur_adc_format);
19608}
19609
Kailang Yangc69aefa2010-08-17 10:39:22 +020019610static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19611 struct hda_codec *codec,
19612 unsigned int stream_tag,
19613 unsigned int format,
19614 struct snd_pcm_substream *substream)
19615{
19616 struct alc_spec *spec = codec->spec;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019617
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019618 spec->cur_adc = 0x07;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019619 spec->cur_adc_stream_tag = stream_tag;
19620 spec->cur_adc_format = format;
19621
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019622 alc680_rec_autoswitch(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019623 return 0;
19624}
19625
19626static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19627 struct hda_codec *codec,
19628 struct snd_pcm_substream *substream)
19629{
19630 snd_hda_codec_cleanup_stream(codec, 0x07);
19631 snd_hda_codec_cleanup_stream(codec, 0x08);
19632 snd_hda_codec_cleanup_stream(codec, 0x09);
19633 return 0;
19634}
19635
19636static struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
19637 .substreams = 1, /* can be overridden */
19638 .channels_min = 2,
19639 .channels_max = 2,
19640 /* NID is set in alc_build_pcms */
19641 .ops = {
19642 .prepare = alc680_capture_pcm_prepare,
19643 .cleanup = alc680_capture_pcm_cleanup
19644 },
19645};
19646
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019647static struct snd_kcontrol_new alc680_base_mixer[] = {
19648 /* output mixer control */
19649 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19650 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19651 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19652 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010019653 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x12, 0, HDA_INPUT),
19654 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
19655 HDA_CODEC_VOLUME("Line In Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019656 { }
19657};
19658
Kailang Yangc69aefa2010-08-17 10:39:22 +020019659static struct hda_bind_ctls alc680_bind_cap_vol = {
19660 .ops = &snd_hda_bind_vol,
19661 .values = {
19662 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19663 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19664 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19665 0
19666 },
19667};
19668
19669static struct hda_bind_ctls alc680_bind_cap_switch = {
19670 .ops = &snd_hda_bind_sw,
19671 .values = {
19672 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19673 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19674 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19675 0
19676 },
19677};
19678
19679static struct snd_kcontrol_new alc680_master_capture_mixer[] = {
19680 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19681 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019682 { } /* end */
19683};
19684
19685/*
19686 * generic initialization of ADC, input mixers and output mixers
19687 */
19688static struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019689 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19690 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19691 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019692
Kailang Yangc69aefa2010-08-17 10:39:22 +020019693 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19694 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19695 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19696 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19697 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19698 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019699
19700 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19701 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19702 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19703 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19704 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019705
19706 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19707 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019708 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019709
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019710 { }
19711};
19712
Kailang Yangc69aefa2010-08-17 10:39:22 +020019713/* toggle speaker-output according to the hp-jack state */
19714static void alc680_base_setup(struct hda_codec *codec)
19715{
19716 struct alc_spec *spec = codec->spec;
19717
19718 spec->autocfg.hp_pins[0] = 0x16;
19719 spec->autocfg.speaker_pins[0] = 0x14;
19720 spec->autocfg.speaker_pins[1] = 0x15;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019721 spec->autocfg.num_inputs = 2;
19722 spec->autocfg.inputs[0].pin = 0x18;
19723 spec->autocfg.inputs[0].type = AUTO_PIN_MIC;
19724 spec->autocfg.inputs[1].pin = 0x19;
Takashi Iwai86e29592010-09-09 14:50:17 +020019725 spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN;
Takashi Iwaid922b512011-04-28 12:18:53 +020019726 spec->automute = 1;
19727 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019728}
19729
19730static void alc680_unsol_event(struct hda_codec *codec,
19731 unsigned int res)
19732{
19733 if ((res >> 26) == ALC880_HP_EVENT)
Takashi Iwaid922b512011-04-28 12:18:53 +020019734 alc_hp_automute(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019735 if ((res >> 26) == ALC880_MIC_EVENT)
19736 alc680_rec_autoswitch(codec);
19737}
19738
19739static void alc680_inithook(struct hda_codec *codec)
19740{
Takashi Iwaid922b512011-04-28 12:18:53 +020019741 alc_hp_automute(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019742 alc680_rec_autoswitch(codec);
19743}
19744
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019745/* create input playback/capture controls for the given pin */
19746static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19747 const char *ctlname, int idx)
19748{
19749 hda_nid_t dac;
19750 int err;
19751
19752 switch (nid) {
19753 case 0x14:
19754 dac = 0x02;
19755 break;
19756 case 0x15:
19757 dac = 0x03;
19758 break;
19759 case 0x16:
19760 dac = 0x04;
19761 break;
19762 default:
19763 return 0;
19764 }
19765 if (spec->multiout.dac_nids[0] != dac &&
19766 spec->multiout.dac_nids[1] != dac) {
19767 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19768 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19769 HDA_OUTPUT));
19770 if (err < 0)
19771 return err;
19772
19773 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19774 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19775
19776 if (err < 0)
19777 return err;
19778 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19779 }
19780
19781 return 0;
19782}
19783
19784/* add playback controls from the parsed DAC table */
19785static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19786 const struct auto_pin_cfg *cfg)
19787{
19788 hda_nid_t nid;
19789 int err;
19790
19791 spec->multiout.dac_nids = spec->private_dac_nids;
19792
19793 nid = cfg->line_out_pins[0];
19794 if (nid) {
19795 const char *name;
19796 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19797 name = "Speaker";
19798 else
19799 name = "Front";
19800 err = alc680_new_analog_output(spec, nid, name, 0);
19801 if (err < 0)
19802 return err;
19803 }
19804
19805 nid = cfg->speaker_pins[0];
19806 if (nid) {
19807 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19808 if (err < 0)
19809 return err;
19810 }
19811 nid = cfg->hp_pins[0];
19812 if (nid) {
19813 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19814 if (err < 0)
19815 return err;
19816 }
19817
19818 return 0;
19819}
19820
19821static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19822 hda_nid_t nid, int pin_type)
19823{
19824 alc_set_pin_output(codec, nid, pin_type);
19825}
19826
19827static void alc680_auto_init_multi_out(struct hda_codec *codec)
19828{
19829 struct alc_spec *spec = codec->spec;
19830 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19831 if (nid) {
19832 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19833 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19834 }
19835}
19836
19837static void alc680_auto_init_hp_out(struct hda_codec *codec)
19838{
19839 struct alc_spec *spec = codec->spec;
19840 hda_nid_t pin;
19841
19842 pin = spec->autocfg.hp_pins[0];
19843 if (pin)
19844 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
19845 pin = spec->autocfg.speaker_pins[0];
19846 if (pin)
19847 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
19848}
19849
19850/* pcm configuration: identical with ALC880 */
19851#define alc680_pcm_analog_playback alc880_pcm_analog_playback
19852#define alc680_pcm_analog_capture alc880_pcm_analog_capture
19853#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
19854#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020019855#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019856
19857/*
19858 * BIOS auto configuration
19859 */
19860static int alc680_parse_auto_config(struct hda_codec *codec)
19861{
19862 struct alc_spec *spec = codec->spec;
19863 int err;
19864 static hda_nid_t alc680_ignore[] = { 0 };
19865
19866 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19867 alc680_ignore);
19868 if (err < 0)
19869 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019870
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019871 if (!spec->autocfg.line_outs) {
19872 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
19873 spec->multiout.max_channels = 2;
19874 spec->no_analog = 1;
19875 goto dig_only;
19876 }
19877 return 0; /* can't find valid BIOS pin config */
19878 }
19879 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
19880 if (err < 0)
19881 return err;
19882
19883 spec->multiout.max_channels = 2;
19884
19885 dig_only:
19886 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020019887 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019888 if (spec->kctls.list)
19889 add_mixer(spec, spec->kctls.list);
19890
19891 add_verb(spec, alc680_init_verbs);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019892
19893 err = alc_auto_add_mic_boost(codec);
19894 if (err < 0)
19895 return err;
19896
19897 return 1;
19898}
19899
19900#define alc680_auto_init_analog_input alc882_auto_init_analog_input
19901
19902/* init callback for auto-configuration model -- overriding the default init */
19903static void alc680_auto_init(struct hda_codec *codec)
19904{
19905 struct alc_spec *spec = codec->spec;
19906 alc680_auto_init_multi_out(codec);
19907 alc680_auto_init_hp_out(codec);
19908 alc680_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019909 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019910 if (spec->unsol_event)
19911 alc_inithook(codec);
19912}
19913
19914/*
19915 * configuration and preset
19916 */
Takashi Iwaiea734962011-01-17 11:29:34 +010019917static const char * const alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020019918 [ALC680_BASE] = "base",
19919 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019920};
19921
19922static struct snd_pci_quirk alc680_cfg_tbl[] = {
19923 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
19924 {}
19925};
19926
19927static struct alc_config_preset alc680_presets[] = {
19928 [ALC680_BASE] = {
19929 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020019930 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019931 .init_verbs = { alc680_init_verbs },
19932 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
19933 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019934 .dig_out_nid = ALC680_DIGOUT_NID,
19935 .num_channel_mode = ARRAY_SIZE(alc680_modes),
19936 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020019937 .unsol_event = alc680_unsol_event,
19938 .setup = alc680_base_setup,
19939 .init_hook = alc680_inithook,
19940
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019941 },
19942};
19943
19944static int patch_alc680(struct hda_codec *codec)
19945{
19946 struct alc_spec *spec;
19947 int board_config;
19948 int err;
19949
19950 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19951 if (spec == NULL)
19952 return -ENOMEM;
19953
19954 codec->spec = spec;
19955
19956 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
19957 alc680_models,
19958 alc680_cfg_tbl);
19959
19960 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
19961 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19962 codec->chip_name);
19963 board_config = ALC680_AUTO;
19964 }
19965
19966 if (board_config == ALC680_AUTO) {
19967 /* automatic parse from the BIOS config */
19968 err = alc680_parse_auto_config(codec);
19969 if (err < 0) {
19970 alc_free(codec);
19971 return err;
19972 } else if (!err) {
19973 printk(KERN_INFO
19974 "hda_codec: Cannot set up configuration "
19975 "from BIOS. Using base mode...\n");
19976 board_config = ALC680_BASE;
19977 }
19978 }
19979
19980 if (board_config != ALC680_AUTO)
19981 setup_preset(codec, &alc680_presets[board_config]);
19982
19983 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019984 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019985 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019986 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019987
19988 if (!spec->adc_nids) {
19989 spec->adc_nids = alc680_adc_nids;
19990 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids);
19991 }
19992
19993 if (!spec->cap_mixer)
19994 set_capture_mixer(codec);
19995
19996 spec->vmaster_nid = 0x02;
19997
19998 codec->patch_ops = alc_patch_ops;
19999 if (board_config == ALC680_AUTO)
20000 spec->init_hook = alc680_auto_init;
20001
20002 return 0;
20003}
20004
20005/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070020006 * patch entries
20007 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010020008static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070020009 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010020010 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010020011 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020020012 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010020013 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010020014 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020020015 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010020016 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020017 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020018 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020019 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
20020 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
20021 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020022 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020023 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020024 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
20025 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020020026 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010020027 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010020028 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020029 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020030 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070020031 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020020032 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020020033 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020034 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020020035 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020036 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010020037 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yang01e0f132010-11-22 10:59:36 +010020038 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc888 },
Kailang Yang44426082008-10-15 11:18:05 +020020039 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020040 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010020041 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020020042 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010020043 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070020044 {} /* terminator */
20045};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010020046
20047MODULE_ALIAS("snd-hda-codec-id:10ec*");
20048
20049MODULE_LICENSE("GPL");
20050MODULE_DESCRIPTION("Realtek HD-audio codec");
20051
20052static struct hda_codec_preset_list realtek_list = {
20053 .preset = snd_hda_preset_realtek,
20054 .owner = THIS_MODULE,
20055};
20056
20057static int __init patch_realtek_init(void)
20058{
20059 return snd_hda_add_codec_preset(&realtek_list);
20060}
20061
20062static void __exit patch_realtek_exit(void)
20063{
20064 snd_hda_delete_codec_preset(&realtek_list);
20065}
20066
20067module_init(patch_realtek_init)
20068module_exit(patch_realtek_exit)