blob: b960020956c82734f01dc69c6211dff641f723e6 [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ünther3e1647c2009-06-05 00:47:26 +0200255 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200256 ALC882_AUTO,
257 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200258};
259
Takashi Iwaid4a86d82010-06-23 17:51:26 +0200260/* ALC680 models */
261enum {
262 ALC680_BASE,
263 ALC680_AUTO,
264 ALC680_MODEL_LAST,
265};
266
Kailang Yangdf694da2005-12-05 19:42:22 +0100267/* for GPIO Poll */
268#define GPIO_MASK 0x03
269
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200270/* extra amp-initialization sequence types */
271enum {
272 ALC_INIT_NONE,
273 ALC_INIT_DEFAULT,
274 ALC_INIT_GPIO1,
275 ALC_INIT_GPIO2,
276 ALC_INIT_GPIO3,
277};
278
Takashi Iwai6c819492009-08-10 18:47:44 +0200279struct alc_mic_route {
280 hda_nid_t pin;
281 unsigned char mux_idx;
282 unsigned char amix_idx;
283};
284
285#define MUX_IDX_UNDEF ((unsigned char)-1)
286
Kailang Yangda00c242010-03-19 11:23:45 +0100287struct alc_customize_define {
288 unsigned int sku_cfg;
289 unsigned char port_connectivity;
290 unsigned char check_sum;
291 unsigned char customization;
292 unsigned char external_amp;
293 unsigned int enable_pcbeep:1;
294 unsigned int platform_type:1;
295 unsigned int swap:1;
296 unsigned int override:1;
David Henningsson90622912010-10-14 14:50:18 +0200297 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
Kailang Yangda00c242010-03-19 11:23:45 +0100298};
299
Takashi Iwaib5bfbc62011-01-13 14:22:32 +0100300struct alc_fixup;
301
Takashi Iwaice764ab2011-04-27 16:35:23 +0200302struct alc_multi_io {
303 hda_nid_t pin; /* multi-io widget pin NID */
304 hda_nid_t dac; /* DAC to be connected */
305 unsigned int ctl_in; /* cached input-pin control value */
306};
307
Takashi Iwaid922b512011-04-28 12:18:53 +0200308enum {
Takashi Iwai3b8510c2011-04-28 14:03:24 +0200309 ALC_AUTOMUTE_PIN, /* change the pin control */
310 ALC_AUTOMUTE_AMP, /* mute/unmute the pin AMP */
311 ALC_AUTOMUTE_MIXER, /* mute/unmute mixer widget AMP */
Takashi Iwaid922b512011-04-28 12:18:53 +0200312};
313
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314struct alc_spec {
315 /* codec parameterization */
Takashi Iwaia9111322011-05-02 11:30:18 +0200316 const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 unsigned int num_mixers;
Takashi Iwaia9111322011-05-02 11:30:18 +0200318 const 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 */
Takashi Iwaia9111322011-05-02 11:30:18 +0200328 const struct hda_pcm_stream *stream_analog_playback;
329 const struct hda_pcm_stream *stream_analog_capture;
330 const struct hda_pcm_stream *stream_analog_alt_playback;
331 const 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 */
Takashi Iwaia9111322011-05-02 11:30:18 +0200334 const struct hda_pcm_stream *stream_digital_playback;
335 const struct hda_pcm_stream *stream_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336
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;
Takashi Iwai4c6d72d2011-05-02 11:30:18 +0200348 const hda_nid_t *adc_nids;
349 const hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200350 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Takashi Iwai1f0f4b82011-06-27 10:52:59 +0200351 hda_nid_t mixer_nid; /* analog-mixer NID */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352
Takashi Iwai840b64c2010-07-13 22:49:01 +0200353 /* capture setup for dynamic dual-adc switch */
354 unsigned int cur_adc_idx;
355 hda_nid_t cur_adc;
356 unsigned int cur_adc_stream_tag;
357 unsigned int cur_adc_format;
358
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200360 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361 const struct hda_input_mux *input_mux;
362 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200363 struct alc_mic_route ext_mic;
Takashi Iwai8ed99d92011-05-17 12:05:02 +0200364 struct alc_mic_route dock_mic;
Takashi Iwai6c819492009-08-10 18:47:44 +0200365 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366
367 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100368 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200370 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200371 int const_channel_count;
372 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373
374 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100375 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200376
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200377 /* dynamic controls, init_verbs and input_mux */
378 struct auto_pin_cfg autocfg;
Kailang Yangda00c242010-03-19 11:23:45 +0100379 struct alc_customize_define cdefine;
Takashi Iwai603c4012008-07-30 15:01:44 +0200380 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200381 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200382 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200383 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
384 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100385
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100386 /* hooks */
387 void (*init_hook)(struct hda_codec *codec);
388 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
Hector Martinf5de24b2009-12-20 22:51:31 +0100389#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -0500390 void (*power_hook)(struct hda_codec *codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100391#endif
Takashi Iwai1c7161532011-04-07 10:37:16 +0200392 void (*shutup)(struct hda_codec *codec);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100393
Takashi Iwai834be882006-03-01 14:16:17 +0100394 /* for pin sensing */
Takashi Iwai834be882006-03-01 14:16:17 +0100395 unsigned int jack_present: 1;
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +0200396 unsigned int line_jack_present:1;
Takashi Iwaie9427962011-04-28 15:46:07 +0200397 unsigned int master_mute:1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200398 unsigned int auto_mic:1;
Takashi Iwaid922b512011-04-28 12:18:53 +0200399 unsigned int automute:1; /* HP automute enabled */
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +0200400 unsigned int detect_line:1; /* Line-out detection enabled */
401 unsigned int automute_lines:1; /* automute line-out as well */
Takashi Iwaiae8a60a2011-04-28 18:09:52 +0200402 unsigned int automute_hp_lo:1; /* both HP and LO available */
Takashi Iwaicb53c622007-08-10 17:21:45 +0200403
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100404 /* other flags */
405 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai840b64c2010-07-13 22:49:01 +0200406 unsigned int dual_adc_switch:1; /* switch ADCs (for ALC275) */
Takashi Iwai584c0c42011-03-10 12:51:11 +0100407 unsigned int single_input_src:1;
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +0200408 unsigned int vol_in_capsrc:1; /* use capsrc volume (ADC has no vol) */
Takashi Iwaid922b512011-04-28 12:18:53 +0200409
410 /* auto-mute control */
411 int automute_mode;
Takashi Iwai3b8510c2011-04-28 14:03:24 +0200412 hda_nid_t automute_mixer_nid[AUTO_CFG_MAX_OUTS];
Takashi Iwaid922b512011-04-28 12:18:53 +0200413
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200414 int init_amp;
Takashi Iwaid433a672010-09-20 15:11:54 +0200415 int codec_variant; /* flag for other variants */
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100416
Takashi Iwai2134ea42008-01-10 16:53:55 +0100417 /* for virtual master */
418 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200419#ifdef CONFIG_SND_HDA_POWER_SAVE
420 struct hda_loopback_check loopback;
421#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200422
423 /* for PLL fix */
424 hda_nid_t pll_nid;
425 unsigned int pll_coef_idx, pll_coef_bit;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +0100426
427 /* fix-up list */
428 int fixup_id;
429 const struct alc_fixup *fixup_list;
430 const char *fixup_name;
Takashi Iwaice764ab2011-04-27 16:35:23 +0200431
432 /* multi-io */
433 int multi_ios;
434 struct alc_multi_io multi_io[4];
Kailang Yangdf694da2005-12-05 19:42:22 +0100435};
436
437/*
438 * configuration template - to be copied to the spec instance
439 */
440struct alc_config_preset {
Takashi Iwaia9111322011-05-02 11:30:18 +0200441 const struct snd_kcontrol_new *mixers[5]; /* should be identical size
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200442 * with spec
443 */
Takashi Iwaia9111322011-05-02 11:30:18 +0200444 const struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100445 const struct hda_verb *init_verbs[5];
446 unsigned int num_dacs;
Takashi Iwai4c6d72d2011-05-02 11:30:18 +0200447 const hda_nid_t *dac_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100448 hda_nid_t dig_out_nid; /* optional */
449 hda_nid_t hp_nid; /* optional */
Takashi Iwai4c6d72d2011-05-02 11:30:18 +0200450 const hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100451 unsigned int num_adc_nids;
Takashi Iwai4c6d72d2011-05-02 11:30:18 +0200452 const hda_nid_t *adc_nids;
453 const hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100454 hda_nid_t dig_in_nid;
455 unsigned int num_channel_mode;
456 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200457 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200458 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200459 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100460 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100461 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200462 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100463 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200464#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaia9111322011-05-02 11:30:18 +0200465 const struct hda_amp_list *loopbacks;
Daniel T Chenc97259d2009-12-27 18:52:08 -0500466 void (*power_hook)(struct hda_codec *codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200467#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468};
469
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470
471/*
472 * input MUX handling
473 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200474static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
475 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476{
477 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
478 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200479 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
480 if (mux_idx >= spec->num_mux_defs)
481 mux_idx = 0;
Takashi Iwai53111142010-03-08 12:13:07 +0100482 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
483 mux_idx = 0;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200484 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485}
486
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200487static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
488 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489{
490 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
491 struct alc_spec *spec = codec->spec;
492 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
493
494 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
495 return 0;
496}
497
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200498static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
499 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500{
501 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
502 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100503 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100505 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100506 hda_nid_t nid = spec->capsrc_nids ?
507 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200508 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509
Takashi Iwaicd896c32008-11-18 12:36:33 +0100510 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
511 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +0100512 if (!imux->num_items && mux_idx > 0)
513 imux = &spec->input_mux[0];
Takashi Iwaicd896c32008-11-18 12:36:33 +0100514
Takashi Iwaia22d5432009-07-27 12:54:26 +0200515 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200516 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100517 /* Matrix-mixer style (e.g. ALC882) */
518 unsigned int *cur_val = &spec->cur_mux[adc_idx];
519 unsigned int i, idx;
520
521 idx = ucontrol->value.enumerated.item[0];
522 if (idx >= imux->num_items)
523 idx = imux->num_items - 1;
524 if (*cur_val == idx)
525 return 0;
526 for (i = 0; i < imux->num_items; i++) {
527 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
528 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
529 imux->items[i].index,
530 HDA_AMP_MUTE, v);
531 }
532 *cur_val = idx;
533 return 1;
534 } else {
535 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100536 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100537 &spec->cur_mux[adc_idx]);
538 }
539}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200540
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541/*
542 * channel mode setting
543 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200544static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
545 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546{
547 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
548 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100549 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
550 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551}
552
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200553static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
554 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555{
556 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
557 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100558 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200559 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200560 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561}
562
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200563static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
564 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565{
566 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
567 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200568 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
569 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200570 &spec->ext_channel_count);
571 if (err >= 0 && !spec->const_channel_count) {
572 spec->multiout.max_channels = spec->ext_channel_count;
573 if (spec->need_dac_fix)
574 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
575 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200576 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577}
578
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100580 * Control the mode of pin widget settings via the mixer. "pc" is used
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300581 * instead of "%" to avoid consequences of accidentally treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100582 * being part of a format specifier. Maximum allowed length of a value is
583 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100584 *
585 * Note: some retasking pin complexes seem to ignore requests for input
586 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
587 * are requested. Therefore order this list so that this behaviour will not
588 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200589 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
590 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200591 */
Takashi Iwaia9111322011-05-02 11:30:18 +0200592static const char * const alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100593 "Mic 50pc bias", "Mic 80pc bias",
594 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100595};
Takashi Iwaia9111322011-05-02 11:30:18 +0200596static const unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100597 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100598};
599/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200600 * in the pin being assumed to be exclusively an input or an output pin. In
601 * addition, "input" pins may or may not process the mic bias option
602 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
603 * accept requests for bias as of chip versions up to March 2006) and/or
604 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100605 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200606#define ALC_PIN_DIR_IN 0x00
607#define ALC_PIN_DIR_OUT 0x01
608#define ALC_PIN_DIR_INOUT 0x02
609#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
610#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100611
Kailang Yangea1fb292008-08-26 12:58:38 +0200612/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100613 * For each direction the minimum and maximum values are given.
614 */
Takashi Iwaia9111322011-05-02 11:30:18 +0200615static const signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100616 { 0, 2 }, /* ALC_PIN_DIR_IN */
617 { 3, 4 }, /* ALC_PIN_DIR_OUT */
618 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200619 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
620 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100621};
622#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
623#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
624#define alc_pin_mode_n_items(_dir) \
625 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
626
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200627static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
628 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200629{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100630 unsigned int item_num = uinfo->value.enumerated.item;
631 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
632
633 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200634 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100635 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
636
637 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
638 item_num = alc_pin_mode_min(dir);
639 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200640 return 0;
641}
642
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200643static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
644 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200645{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100646 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200647 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
648 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100649 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200650 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200651 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
652 AC_VERB_GET_PIN_WIDGET_CONTROL,
653 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200654
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100655 /* Find enumerated value for current pinctl setting */
656 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200657 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100658 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200659 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100660 return 0;
661}
662
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200663static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
664 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100665{
666 signed int change;
667 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
668 hda_nid_t nid = kcontrol->private_value & 0xffff;
669 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
670 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200671 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
672 AC_VERB_GET_PIN_WIDGET_CONTROL,
673 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100674
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200675 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100676 val = alc_pin_mode_min(dir);
677
678 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100679 if (change) {
680 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200681 snd_hda_codec_write_cache(codec, nid, 0,
682 AC_VERB_SET_PIN_WIDGET_CONTROL,
683 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100684
Kailang Yangea1fb292008-08-26 12:58:38 +0200685 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100686 * for the requested pin mode. Enum values of 2 or less are
687 * input modes.
688 *
689 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200690 * reduces noise slightly (particularly on input) so we'll
691 * do it. However, having both input and output buffers
692 * enabled simultaneously doesn't seem to be problematic if
693 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100694 */
695 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200696 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
697 HDA_AMP_MUTE, HDA_AMP_MUTE);
698 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
699 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100700 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200701 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
702 HDA_AMP_MUTE, HDA_AMP_MUTE);
703 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
704 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100705 }
706 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200707 return change;
708}
709
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100710#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200711 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100712 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100713 .info = alc_pin_mode_info, \
714 .get = alc_pin_mode_get, \
715 .put = alc_pin_mode_put, \
716 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100717
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100718/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
719 * together using a mask with more than one bit set. This control is
720 * currently used only by the ALC260 test model. At this stage they are not
721 * needed for any "production" models.
722 */
723#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200724#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200725
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200726static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
727 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100728{
729 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
730 hda_nid_t nid = kcontrol->private_value & 0xffff;
731 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
732 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200733 unsigned int val = snd_hda_codec_read(codec, nid, 0,
734 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100735
736 *valp = (val & mask) != 0;
737 return 0;
738}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200739static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
740 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100741{
742 signed int change;
743 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
744 hda_nid_t nid = kcontrol->private_value & 0xffff;
745 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
746 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200747 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
748 AC_VERB_GET_GPIO_DATA,
749 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100750
751 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200752 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
753 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100754 gpio_data &= ~mask;
755 else
756 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200757 snd_hda_codec_write_cache(codec, nid, 0,
758 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100759
760 return change;
761}
762#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
763 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100764 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100765 .info = alc_gpio_data_info, \
766 .get = alc_gpio_data_get, \
767 .put = alc_gpio_data_put, \
768 .private_value = nid | (mask<<16) }
769#endif /* CONFIG_SND_DEBUG */
770
Jonathan Woithe92621f12006-02-28 11:47:47 +0100771/* A switch control to allow the enabling of the digital IO pins on the
772 * ALC260. This is incredibly simplistic; the intention of this control is
773 * to provide something in the test model allowing digital outputs to be
774 * identified if present. If models are found which can utilise these
775 * outputs a more complete mixer control can be devised for those models if
776 * necessary.
777 */
778#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200779#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200780
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200781static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
782 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100783{
784 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
785 hda_nid_t nid = kcontrol->private_value & 0xffff;
786 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
787 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200788 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100789 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100790
791 *valp = (val & mask) != 0;
792 return 0;
793}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200794static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
795 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100796{
797 signed int change;
798 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
799 hda_nid_t nid = kcontrol->private_value & 0xffff;
800 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
801 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200802 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100803 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200804 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100805
806 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200807 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100808 if (val==0)
809 ctrl_data &= ~mask;
810 else
811 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200812 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
813 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100814
815 return change;
816}
817#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
818 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100819 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100820 .info = alc_spdif_ctrl_info, \
821 .get = alc_spdif_ctrl_get, \
822 .put = alc_spdif_ctrl_put, \
823 .private_value = nid | (mask<<16) }
824#endif /* CONFIG_SND_DEBUG */
825
Jonathan Woithef8225f62008-01-08 12:16:54 +0100826/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
827 * Again, this is only used in the ALC26x test models to help identify when
828 * the EAPD line must be asserted for features to work.
829 */
830#ifdef CONFIG_SND_DEBUG
831#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
832
833static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
834 struct snd_ctl_elem_value *ucontrol)
835{
836 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
837 hda_nid_t nid = kcontrol->private_value & 0xffff;
838 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
839 long *valp = ucontrol->value.integer.value;
840 unsigned int val = snd_hda_codec_read(codec, nid, 0,
841 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
842
843 *valp = (val & mask) != 0;
844 return 0;
845}
846
847static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
848 struct snd_ctl_elem_value *ucontrol)
849{
850 int change;
851 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
852 hda_nid_t nid = kcontrol->private_value & 0xffff;
853 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
854 long val = *ucontrol->value.integer.value;
855 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
856 AC_VERB_GET_EAPD_BTLENABLE,
857 0x00);
858
859 /* Set/unset the masked control bit(s) as needed */
860 change = (!val ? 0 : mask) != (ctrl_data & mask);
861 if (!val)
862 ctrl_data &= ~mask;
863 else
864 ctrl_data |= mask;
865 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
866 ctrl_data);
867
868 return change;
869}
870
871#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
872 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100873 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100874 .info = alc_eapd_ctrl_info, \
875 .get = alc_eapd_ctrl_get, \
876 .put = alc_eapd_ctrl_put, \
877 .private_value = nid | (mask<<16) }
878#endif /* CONFIG_SND_DEBUG */
879
Kailang Yangdf694da2005-12-05 19:42:22 +0100880/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100881 * set up the input pin config (depending on the given auto-pin type)
882 */
883static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
884 int auto_pin_type)
885{
886 unsigned int val = PIN_IN;
887
Takashi Iwai86e29592010-09-09 14:50:17 +0200888 if (auto_pin_type == AUTO_PIN_MIC) {
Takashi Iwai23f0c042009-02-26 13:03:58 +0100889 unsigned int pincap;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200890 unsigned int oldval;
891 oldval = snd_hda_codec_read(codec, nid, 0,
892 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Takashi Iwai1327a322009-03-23 13:07:47 +0100893 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100894 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200895 /* if the default pin setup is vref50, we give it priority */
896 if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50)
Takashi Iwai23f0c042009-02-26 13:03:58 +0100897 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200898 else if (pincap & AC_PINCAP_VREF_50)
899 val = PIN_VREF50;
900 else if (pincap & AC_PINCAP_VREF_100)
901 val = PIN_VREF100;
902 else if (pincap & AC_PINCAP_VREF_GRD)
903 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100904 }
905 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
906}
907
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200908static void alc_fixup_autocfg_pin_nums(struct hda_codec *codec)
909{
910 struct alc_spec *spec = codec->spec;
911 struct auto_pin_cfg *cfg = &spec->autocfg;
912
913 if (!cfg->line_outs) {
914 while (cfg->line_outs < AUTO_CFG_MAX_OUTS &&
915 cfg->line_out_pins[cfg->line_outs])
916 cfg->line_outs++;
917 }
918 if (!cfg->speaker_outs) {
919 while (cfg->speaker_outs < AUTO_CFG_MAX_OUTS &&
920 cfg->speaker_pins[cfg->speaker_outs])
921 cfg->speaker_outs++;
922 }
923 if (!cfg->hp_outs) {
924 while (cfg->hp_outs < AUTO_CFG_MAX_OUTS &&
925 cfg->hp_pins[cfg->hp_outs])
926 cfg->hp_outs++;
927 }
928}
929
Takashi Iwai23f0c042009-02-26 13:03:58 +0100930/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100931 */
Takashi Iwaia9111322011-05-02 11:30:18 +0200932static void add_mixer(struct alc_spec *spec, const struct snd_kcontrol_new *mix)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100933{
934 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
935 return;
936 spec->mixers[spec->num_mixers++] = mix;
937}
938
939static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
940{
941 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
942 return;
943 spec->init_verbs[spec->num_init_verbs++] = verb;
944}
945
946/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100947 * set up from the preset table
948 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200949static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200950 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100951{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200952 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100953 int i;
954
955 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100956 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100957 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200958 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
959 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100960 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200961
Kailang Yangdf694da2005-12-05 19:42:22 +0100962 spec->channel_mode = preset->channel_mode;
963 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200964 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200965 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100966
Hector Martin3b315d72009-06-02 10:54:19 +0200967 if (preset->const_channel_count)
968 spec->multiout.max_channels = preset->const_channel_count;
969 else
970 spec->multiout.max_channels = spec->channel_mode[0].channels;
971 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100972
973 spec->multiout.num_dacs = preset->num_dacs;
974 spec->multiout.dac_nids = preset->dac_nids;
975 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800976 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100977 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200978
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200979 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200980 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200981 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100982 spec->input_mux = preset->input_mux;
983
984 spec->num_adc_nids = preset->num_adc_nids;
985 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100986 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100987 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100988
989 spec->unsol_event = preset->unsol_event;
990 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200991#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100992 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200993 spec->loopback.amplist = preset->loopbacks;
994#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200995
996 if (preset->setup)
997 preset->setup(codec);
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200998
999 alc_fixup_autocfg_pin_nums(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01001000}
1001
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001002/* Enable GPIO mask and set output */
Takashi Iwaia9111322011-05-02 11:30:18 +02001003static const struct hda_verb alc_gpio1_init_verbs[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001004 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
1005 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1006 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
1007 { }
1008};
1009
Takashi Iwaia9111322011-05-02 11:30:18 +02001010static const struct hda_verb alc_gpio2_init_verbs[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001011 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1012 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1013 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
1014 { }
1015};
1016
Takashi Iwaia9111322011-05-02 11:30:18 +02001017static const struct hda_verb alc_gpio3_init_verbs[] = {
Kailang Yangbdd148a2007-05-08 15:19:08 +02001018 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
1019 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
1020 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
1021 { }
1022};
1023
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02001024/*
1025 * Fix hardware PLL issue
1026 * On some codecs, the analog PLL gating control must be off while
1027 * the default value is 1.
1028 */
1029static void alc_fix_pll(struct hda_codec *codec)
1030{
1031 struct alc_spec *spec = codec->spec;
1032 unsigned int val;
1033
1034 if (!spec->pll_nid)
1035 return;
1036 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1037 spec->pll_coef_idx);
1038 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
1039 AC_VERB_GET_PROC_COEF, 0);
1040 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1041 spec->pll_coef_idx);
1042 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
1043 val & ~(1 << spec->pll_coef_bit));
1044}
1045
1046static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
1047 unsigned int coef_idx, unsigned int coef_bit)
1048{
1049 struct alc_spec *spec = codec->spec;
1050 spec->pll_nid = nid;
1051 spec->pll_coef_idx = coef_idx;
1052 spec->pll_coef_bit = coef_bit;
1053 alc_fix_pll(codec);
1054}
1055
Kailang Yang9ad0e492010-09-14 23:22:00 +02001056static int alc_init_jacks(struct hda_codec *codec)
1057{
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001058#ifdef CONFIG_SND_HDA_INPUT_JACK
Kailang Yang9ad0e492010-09-14 23:22:00 +02001059 struct alc_spec *spec = codec->spec;
1060 int err;
1061 unsigned int hp_nid = spec->autocfg.hp_pins[0];
1062 unsigned int mic_nid = spec->ext_mic.pin;
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001063 unsigned int dock_nid = spec->dock_mic.pin;
Kailang Yang9ad0e492010-09-14 23:22:00 +02001064
Takashi Iwai265a0242010-09-21 11:26:21 +02001065 if (hp_nid) {
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001066 err = snd_hda_input_jack_add(codec, hp_nid,
1067 SND_JACK_HEADPHONE, NULL);
Takashi Iwai265a0242010-09-21 11:26:21 +02001068 if (err < 0)
1069 return err;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001070 snd_hda_input_jack_report(codec, hp_nid);
Takashi Iwai265a0242010-09-21 11:26:21 +02001071 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001072
Takashi Iwai265a0242010-09-21 11:26:21 +02001073 if (mic_nid) {
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001074 err = snd_hda_input_jack_add(codec, mic_nid,
1075 SND_JACK_MICROPHONE, NULL);
Takashi Iwai265a0242010-09-21 11:26:21 +02001076 if (err < 0)
1077 return err;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001078 snd_hda_input_jack_report(codec, mic_nid);
Takashi Iwai265a0242010-09-21 11:26:21 +02001079 }
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001080 if (dock_nid) {
1081 err = snd_hda_input_jack_add(codec, dock_nid,
1082 SND_JACK_MICROPHONE, NULL);
1083 if (err < 0)
1084 return err;
1085 snd_hda_input_jack_report(codec, dock_nid);
1086 }
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001087#endif /* CONFIG_SND_HDA_INPUT_JACK */
Kailang Yang9ad0e492010-09-14 23:22:00 +02001088 return 0;
1089}
Kailang Yang9ad0e492010-09-14 23:22:00 +02001090
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001091static int detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins)
Kailang Yangc9b58002007-10-16 14:30:01 +02001092{
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001093 int i, present = 0;
Kailang Yangc9b58002007-10-16 14:30:01 +02001094
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001095 for (i = 0; i < num_pins; i++) {
1096 hda_nid_t nid = pins[i];
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001097 if (!nid)
1098 break;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001099 snd_hda_input_jack_report(codec, nid);
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001100 present |= snd_hda_jack_detect(codec, nid);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001101 }
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001102 return present;
1103}
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001104
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001105static void do_automute(struct hda_codec *codec, int num_pins, hda_nid_t *pins,
Takashi Iwaie9427962011-04-28 15:46:07 +02001106 bool mute, bool hp_out)
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001107{
1108 struct alc_spec *spec = codec->spec;
1109 unsigned int mute_bits = mute ? HDA_AMP_MUTE : 0;
Takashi Iwaie9427962011-04-28 15:46:07 +02001110 unsigned int pin_bits = mute ? 0 : (hp_out ? PIN_HP : PIN_OUT);
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001111 int i;
1112
1113 for (i = 0; i < num_pins; i++) {
1114 hda_nid_t nid = pins[i];
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001115 if (!nid)
1116 break;
Takashi Iwai3b8510c2011-04-28 14:03:24 +02001117 switch (spec->automute_mode) {
1118 case ALC_AUTOMUTE_PIN:
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001119 snd_hda_codec_write(codec, nid, 0,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001120 AC_VERB_SET_PIN_WIDGET_CONTROL,
1121 pin_bits);
Takashi Iwai3b8510c2011-04-28 14:03:24 +02001122 break;
1123 case ALC_AUTOMUTE_AMP:
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001124 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001125 HDA_AMP_MUTE, mute_bits);
Takashi Iwai3b8510c2011-04-28 14:03:24 +02001126 break;
1127 case ALC_AUTOMUTE_MIXER:
1128 nid = spec->automute_mixer_nid[i];
1129 if (!nid)
1130 break;
1131 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001132 HDA_AMP_MUTE, mute_bits);
Takashi Iwai3b8510c2011-04-28 14:03:24 +02001133 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 1,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001134 HDA_AMP_MUTE, mute_bits);
Takashi Iwai3b8510c2011-04-28 14:03:24 +02001135 break;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001136 }
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001137 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001138}
1139
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001140/* Toggle internal speakers muting */
1141static void update_speakers(struct hda_codec *codec)
1142{
1143 struct alc_spec *spec = codec->spec;
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001144 int on;
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001145
Takashi Iwaic0a20262011-06-10 15:28:15 +02001146 /* Control HP pins/amps depending on master_mute state;
1147 * in general, HP pins/amps control should be enabled in all cases,
1148 * but currently set only for master_mute, just to be safe
1149 */
1150 do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins),
1151 spec->autocfg.hp_pins, spec->master_mute, true);
1152
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001153 if (!spec->automute)
1154 on = 0;
1155 else
1156 on = spec->jack_present | spec->line_jack_present;
1157 on |= spec->master_mute;
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001158 do_automute(codec, ARRAY_SIZE(spec->autocfg.speaker_pins),
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001159 spec->autocfg.speaker_pins, on, false);
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001160
1161 /* toggle line-out mutes if needed, too */
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001162 /* if LO is a copy of either HP or Speaker, don't need to handle it */
1163 if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0] ||
1164 spec->autocfg.line_out_pins[0] == spec->autocfg.speaker_pins[0])
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001165 return;
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001166 if (!spec->automute_lines || !spec->automute)
1167 on = 0;
1168 else
1169 on = spec->jack_present;
1170 on |= spec->master_mute;
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001171 do_automute(codec, ARRAY_SIZE(spec->autocfg.line_out_pins),
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001172 spec->autocfg.line_out_pins, on, false);
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001173}
1174
1175static void alc_hp_automute(struct hda_codec *codec)
1176{
1177 struct alc_spec *spec = codec->spec;
1178
1179 if (!spec->automute)
1180 return;
1181 spec->jack_present =
1182 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.hp_pins),
1183 spec->autocfg.hp_pins);
1184 update_speakers(codec);
1185}
1186
1187static void alc_line_automute(struct hda_codec *codec)
1188{
1189 struct alc_spec *spec = codec->spec;
1190
1191 if (!spec->automute || !spec->detect_line)
1192 return;
1193 spec->line_jack_present =
1194 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.line_out_pins),
1195 spec->autocfg.line_out_pins);
1196 update_speakers(codec);
1197}
1198
Takashi Iwai8d087c72011-06-28 12:45:47 +02001199#define get_connection_index(codec, mux, nid) \
1200 snd_hda_get_conn_index(codec, mux, nid, 0)
Takashi Iwai6c819492009-08-10 18:47:44 +02001201
Takashi Iwai840b64c2010-07-13 22:49:01 +02001202/* switch the current ADC according to the jack state */
1203static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1204{
1205 struct alc_spec *spec = codec->spec;
1206 unsigned int present;
1207 hda_nid_t new_adc;
1208
1209 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1210 if (present)
1211 spec->cur_adc_idx = 1;
1212 else
1213 spec->cur_adc_idx = 0;
1214 new_adc = spec->adc_nids[spec->cur_adc_idx];
1215 if (spec->cur_adc && spec->cur_adc != new_adc) {
1216 /* stream is running, let's swap the current ADC */
Takashi Iwaif0cea792010-08-13 11:56:53 +02001217 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
Takashi Iwai840b64c2010-07-13 22:49:01 +02001218 spec->cur_adc = new_adc;
1219 snd_hda_codec_setup_stream(codec, new_adc,
1220 spec->cur_adc_stream_tag, 0,
1221 spec->cur_adc_format);
1222 }
1223}
1224
Kailang Yang7fb0d782008-10-15 11:12:35 +02001225static void alc_mic_automute(struct hda_codec *codec)
1226{
1227 struct alc_spec *spec = codec->spec;
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001228 struct alc_mic_route *dead1, *dead2, *alive;
Takashi Iwai6c819492009-08-10 18:47:44 +02001229 unsigned int present, type;
1230 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001231
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001232 if (!spec->auto_mic)
1233 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001234 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1235 return;
1236 if (snd_BUG_ON(!spec->adc_nids))
1237 return;
1238
Takashi Iwai840b64c2010-07-13 22:49:01 +02001239 if (spec->dual_adc_switch) {
1240 alc_dual_mic_adc_auto_switch(codec);
1241 return;
1242 }
1243
Takashi Iwai6c819492009-08-10 18:47:44 +02001244 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1245
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001246 alive = &spec->int_mic;
1247 dead1 = &spec->ext_mic;
1248 dead2 = &spec->dock_mic;
1249
Wu Fengguang864f92b2009-11-18 12:38:02 +08001250 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001251 if (present) {
1252 alive = &spec->ext_mic;
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001253 dead1 = &spec->int_mic;
1254 dead2 = &spec->dock_mic;
1255 }
1256 if (!present && spec->dock_mic.pin > 0) {
1257 present = snd_hda_jack_detect(codec, spec->dock_mic.pin);
1258 if (present) {
1259 alive = &spec->dock_mic;
1260 dead1 = &spec->int_mic;
1261 dead2 = &spec->ext_mic;
1262 }
1263 snd_hda_input_jack_report(codec, spec->dock_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001264 }
1265
Takashi Iwai6c819492009-08-10 18:47:44 +02001266 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1267 if (type == AC_WID_AUD_MIX) {
1268 /* Matrix-mixer style (e.g. ALC882) */
1269 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1270 alive->mux_idx,
1271 HDA_AMP_MUTE, 0);
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001272 if (dead1->pin > 0)
1273 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1274 dead1->mux_idx,
1275 HDA_AMP_MUTE, HDA_AMP_MUTE);
1276 if (dead2->pin > 0)
1277 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1278 dead2->mux_idx,
1279 HDA_AMP_MUTE, HDA_AMP_MUTE);
Takashi Iwai6c819492009-08-10 18:47:44 +02001280 } else {
1281 /* MUX style (e.g. ALC880) */
1282 snd_hda_codec_write_cache(codec, cap_nid, 0,
1283 AC_VERB_SET_CONNECT_SEL,
1284 alive->mux_idx);
1285 }
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001286 snd_hda_input_jack_report(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001287
1288 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001289}
1290
Kailang Yangc9b58002007-10-16 14:30:01 +02001291/* unsolicited event for HP jack sensing */
1292static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1293{
1294 if (codec->vendor_id == 0x10ec0880)
1295 res >>= 28;
1296 else
1297 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001298 switch (res) {
1299 case ALC880_HP_EVENT:
Takashi Iwaid922b512011-04-28 12:18:53 +02001300 alc_hp_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001301 break;
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001302 case ALC880_FRONT_EVENT:
1303 alc_line_automute(codec);
1304 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001305 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001306 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001307 break;
1308 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001309}
1310
1311static void alc_inithook(struct hda_codec *codec)
1312{
Takashi Iwaid922b512011-04-28 12:18:53 +02001313 alc_hp_automute(codec);
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001314 alc_line_automute(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001315 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001316}
1317
Kailang Yangf9423e72008-05-27 12:32:25 +02001318/* additional initialization for ALC888 variants */
1319static void alc888_coef_init(struct hda_codec *codec)
1320{
1321 unsigned int tmp;
1322
1323 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1324 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1325 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001326 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001327 /* alc888S-VC */
1328 snd_hda_codec_read(codec, 0x20, 0,
1329 AC_VERB_SET_PROC_COEF, 0x830);
1330 else
1331 /* alc888-VB */
1332 snd_hda_codec_read(codec, 0x20, 0,
1333 AC_VERB_SET_PROC_COEF, 0x3030);
1334}
1335
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001336static void alc889_coef_init(struct hda_codec *codec)
1337{
1338 unsigned int tmp;
1339
1340 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1341 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1342 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1343 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1344}
1345
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001346/* turn on/off EAPD control (only if available) */
1347static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1348{
1349 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1350 return;
1351 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1352 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1353 on ? 2 : 0);
1354}
1355
Takashi Iwai691f1fc2011-04-07 10:31:43 +02001356/* turn on/off EAPD controls of the codec */
1357static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
1358{
1359 /* We currently only handle front, HP */
Takashi Iwai39fa84e2011-06-27 15:28:57 +02001360 static hda_nid_t pins[] = {
1361 0x0f, 0x10, 0x14, 0x15, 0
1362 };
1363 hda_nid_t *p;
1364 for (p = pins; *p; p++)
1365 set_eapd(codec, *p, on);
Takashi Iwai691f1fc2011-04-07 10:31:43 +02001366}
1367
Takashi Iwai1c7161532011-04-07 10:37:16 +02001368/* generic shutup callback;
1369 * just turning off EPAD and a little pause for avoiding pop-noise
1370 */
1371static void alc_eapd_shutup(struct hda_codec *codec)
1372{
1373 alc_auto_setup_eapd(codec, false);
1374 msleep(200);
1375}
1376
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001377static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001378{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001379 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001380
Takashi Iwai39fa84e2011-06-27 15:28:57 +02001381 alc_auto_setup_eapd(codec, true);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001382 switch (type) {
1383 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001384 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1385 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001386 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001387 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1388 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001389 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001390 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1391 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001392 case ALC_INIT_DEFAULT:
Kailang Yangc9b58002007-10-16 14:30:01 +02001393 switch (codec->vendor_id) {
1394 case 0x10ec0260:
1395 snd_hda_codec_write(codec, 0x1a, 0,
1396 AC_VERB_SET_COEF_INDEX, 7);
1397 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1398 AC_VERB_GET_PROC_COEF, 0);
1399 snd_hda_codec_write(codec, 0x1a, 0,
1400 AC_VERB_SET_COEF_INDEX, 7);
1401 snd_hda_codec_write(codec, 0x1a, 0,
1402 AC_VERB_SET_PROC_COEF,
1403 tmp | 0x2010);
1404 break;
1405 case 0x10ec0262:
1406 case 0x10ec0880:
1407 case 0x10ec0882:
1408 case 0x10ec0883:
1409 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001410 case 0x10ec0887:
Takashi Iwai20b67dd2011-03-23 22:54:32 +01001411 /*case 0x10ec0889:*/ /* this causes an SPDIF problem */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001412 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001413 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001414 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001415 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001416 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001417#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001418 case 0x10ec0267:
1419 case 0x10ec0268:
1420 snd_hda_codec_write(codec, 0x20, 0,
1421 AC_VERB_SET_COEF_INDEX, 7);
1422 tmp = snd_hda_codec_read(codec, 0x20, 0,
1423 AC_VERB_GET_PROC_COEF, 0);
1424 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001425 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001426 snd_hda_codec_write(codec, 0x20, 0,
1427 AC_VERB_SET_PROC_COEF,
1428 tmp | 0x3000);
1429 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001430#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001431 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001432 break;
1433 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001434}
Kailang Yangea1fb292008-08-26 12:58:38 +02001435
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001436static int alc_automute_mode_info(struct snd_kcontrol *kcontrol,
1437 struct snd_ctl_elem_info *uinfo)
1438{
Takashi Iwaiae8a60a2011-04-28 18:09:52 +02001439 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1440 struct alc_spec *spec = codec->spec;
1441 static const char * const texts2[] = {
1442 "Disabled", "Enabled"
1443 };
1444 static const char * const texts3[] = {
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001445 "Disabled", "Speaker Only", "Line-Out+Speaker"
1446 };
Takashi Iwaiae8a60a2011-04-28 18:09:52 +02001447 const char * const *texts;
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001448
1449 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1450 uinfo->count = 1;
Takashi Iwaiae8a60a2011-04-28 18:09:52 +02001451 if (spec->automute_hp_lo) {
1452 uinfo->value.enumerated.items = 3;
1453 texts = texts3;
1454 } else {
1455 uinfo->value.enumerated.items = 2;
1456 texts = texts2;
1457 }
1458 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
1459 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001460 strcpy(uinfo->value.enumerated.name,
1461 texts[uinfo->value.enumerated.item]);
1462 return 0;
1463}
1464
1465static int alc_automute_mode_get(struct snd_kcontrol *kcontrol,
1466 struct snd_ctl_elem_value *ucontrol)
1467{
1468 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1469 struct alc_spec *spec = codec->spec;
1470 unsigned int val;
1471 if (!spec->automute)
1472 val = 0;
1473 else if (!spec->automute_lines)
1474 val = 1;
1475 else
1476 val = 2;
1477 ucontrol->value.enumerated.item[0] = val;
1478 return 0;
1479}
1480
1481static int alc_automute_mode_put(struct snd_kcontrol *kcontrol,
1482 struct snd_ctl_elem_value *ucontrol)
1483{
1484 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1485 struct alc_spec *spec = codec->spec;
1486
1487 switch (ucontrol->value.enumerated.item[0]) {
1488 case 0:
1489 if (!spec->automute)
1490 return 0;
1491 spec->automute = 0;
1492 break;
1493 case 1:
1494 if (spec->automute && !spec->automute_lines)
1495 return 0;
1496 spec->automute = 1;
1497 spec->automute_lines = 0;
1498 break;
1499 case 2:
Takashi Iwaiae8a60a2011-04-28 18:09:52 +02001500 if (!spec->automute_hp_lo)
1501 return -EINVAL;
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001502 if (spec->automute && spec->automute_lines)
1503 return 0;
1504 spec->automute = 1;
1505 spec->automute_lines = 1;
1506 break;
1507 default:
1508 return -EINVAL;
1509 }
1510 update_speakers(codec);
1511 return 1;
1512}
1513
Takashi Iwaia9111322011-05-02 11:30:18 +02001514static const struct snd_kcontrol_new alc_automute_mode_enum = {
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001515 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1516 .name = "Auto-Mute Mode",
1517 .info = alc_automute_mode_info,
1518 .get = alc_automute_mode_get,
1519 .put = alc_automute_mode_put,
1520};
1521
1522static struct snd_kcontrol_new *alc_kcontrol_new(struct alc_spec *spec);
1523
1524static int alc_add_automute_mode_enum(struct hda_codec *codec)
1525{
1526 struct alc_spec *spec = codec->spec;
1527 struct snd_kcontrol_new *knew;
1528
1529 knew = alc_kcontrol_new(spec);
1530 if (!knew)
1531 return -ENOMEM;
1532 *knew = alc_automute_mode_enum;
1533 knew->name = kstrdup("Auto-Mute Mode", GFP_KERNEL);
1534 if (!knew->name)
1535 return -ENOMEM;
1536 return 0;
1537}
1538
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001539static void alc_init_auto_hp(struct hda_codec *codec)
1540{
1541 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001542 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai1daf5f42011-04-28 17:57:46 +02001543 int present = 0;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001544 int i;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001545
Takashi Iwai1daf5f42011-04-28 17:57:46 +02001546 if (cfg->hp_pins[0])
1547 present++;
1548 if (cfg->line_out_pins[0])
1549 present++;
1550 if (cfg->speaker_pins[0])
1551 present++;
1552 if (present < 2) /* need two different output types */
1553 return;
Takashi Iwaiae8a60a2011-04-28 18:09:52 +02001554 if (present == 3)
1555 spec->automute_hp_lo = 1; /* both HP and LO automute */
Kailang Yangc9b58002007-10-16 14:30:01 +02001556
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001557 if (!cfg->speaker_pins[0]) {
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001558 memcpy(cfg->speaker_pins, cfg->line_out_pins,
1559 sizeof(cfg->speaker_pins));
1560 cfg->speaker_outs = cfg->line_outs;
1561 }
1562
1563 if (!cfg->hp_pins[0]) {
1564 memcpy(cfg->hp_pins, cfg->line_out_pins,
1565 sizeof(cfg->hp_pins));
1566 cfg->hp_outs = cfg->line_outs;
1567 }
1568
1569 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001570 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwai06dec222011-05-17 10:00:16 +02001571 if (!is_jack_detectable(codec, nid))
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001572 continue;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001573 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001574 nid);
1575 snd_hda_codec_write_cache(codec, nid, 0,
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001576 AC_VERB_SET_UNSOLICITED_ENABLE,
1577 AC_USRSP_EN | ALC880_HP_EVENT);
Takashi Iwaid922b512011-04-28 12:18:53 +02001578 spec->automute = 1;
1579 spec->automute_mode = ALC_AUTOMUTE_PIN;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001580 }
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001581 if (spec->automute && cfg->line_out_pins[0] &&
1582 cfg->line_out_pins[0] != cfg->hp_pins[0] &&
1583 cfg->line_out_pins[0] != cfg->speaker_pins[0]) {
1584 for (i = 0; i < cfg->line_outs; i++) {
1585 hda_nid_t nid = cfg->line_out_pins[i];
Takashi Iwai06dec222011-05-17 10:00:16 +02001586 if (!is_jack_detectable(codec, nid))
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001587 continue;
1588 snd_printdd("realtek: Enable Line-Out auto-muting "
1589 "on NID 0x%x\n", nid);
1590 snd_hda_codec_write_cache(codec, nid, 0,
1591 AC_VERB_SET_UNSOLICITED_ENABLE,
1592 AC_USRSP_EN | ALC880_FRONT_EVENT);
1593 spec->detect_line = 1;
1594 }
Takashi Iwai52d3cb82011-05-17 10:04:08 +02001595 spec->automute_lines = spec->detect_line;
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001596 }
Takashi Iwaiae8a60a2011-04-28 18:09:52 +02001597
1598 if (spec->automute) {
1599 /* create a control for automute mode */
1600 alc_add_automute_mode_enum(codec);
1601 spec->unsol_event = alc_sku_unsol_event;
1602 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001603}
1604
Takashi Iwai6c819492009-08-10 18:47:44 +02001605static void alc_init_auto_mic(struct hda_codec *codec)
1606{
1607 struct alc_spec *spec = codec->spec;
1608 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001609 hda_nid_t fixed, ext, dock;
Takashi Iwai6c819492009-08-10 18:47:44 +02001610 int i;
1611
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001612 fixed = ext = dock = 0;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001613 for (i = 0; i < cfg->num_inputs; i++) {
1614 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai6c819492009-08-10 18:47:44 +02001615 unsigned int defcfg;
Takashi Iwai6c819492009-08-10 18:47:44 +02001616 defcfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001617 switch (snd_hda_get_input_pin_attr(defcfg)) {
1618 case INPUT_PIN_ATTR_INT:
Takashi Iwai6c819492009-08-10 18:47:44 +02001619 if (fixed)
1620 return; /* already occupied */
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001621 if (cfg->inputs[i].type != AUTO_PIN_MIC)
1622 return; /* invalid type */
Takashi Iwai6c819492009-08-10 18:47:44 +02001623 fixed = nid;
1624 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001625 case INPUT_PIN_ATTR_UNUSED:
1626 return; /* invalid entry */
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001627 case INPUT_PIN_ATTR_DOCK:
1628 if (dock)
1629 return; /* already occupied */
1630 if (cfg->inputs[i].type > AUTO_PIN_LINE_IN)
1631 return; /* invalid type */
1632 dock = nid;
1633 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001634 default:
Takashi Iwai6c819492009-08-10 18:47:44 +02001635 if (ext)
1636 return; /* already occupied */
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001637 if (cfg->inputs[i].type != AUTO_PIN_MIC)
1638 return; /* invalid type */
Takashi Iwai6c819492009-08-10 18:47:44 +02001639 ext = nid;
1640 break;
Takashi Iwai6c819492009-08-10 18:47:44 +02001641 }
1642 }
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001643 if (!ext && dock) {
1644 ext = dock;
1645 dock = 0;
1646 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001647 if (!ext || !fixed)
1648 return;
Takashi Iwaie35d9d62011-05-17 11:28:16 +02001649 if (!is_jack_detectable(codec, ext))
Takashi Iwai6c819492009-08-10 18:47:44 +02001650 return; /* no unsol support */
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001651 if (dock && !is_jack_detectable(codec, dock))
1652 return; /* no unsol support */
1653 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n",
1654 ext, fixed, dock);
Takashi Iwai6c819492009-08-10 18:47:44 +02001655 spec->ext_mic.pin = ext;
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001656 spec->dock_mic.pin = dock;
Takashi Iwai6c819492009-08-10 18:47:44 +02001657 spec->int_mic.pin = fixed;
1658 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001659 spec->dock_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
Takashi Iwai6c819492009-08-10 18:47:44 +02001660 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1661 spec->auto_mic = 1;
1662 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1663 AC_VERB_SET_UNSOLICITED_ENABLE,
1664 AC_USRSP_EN | ALC880_MIC_EVENT);
1665 spec->unsol_event = alc_sku_unsol_event;
1666}
1667
David Henningsson90622912010-10-14 14:50:18 +02001668/* Could be any non-zero and even value. When used as fixup, tells
1669 * the driver to ignore any present sku defines.
1670 */
1671#define ALC_FIXUP_SKU_IGNORE (2)
1672
Kailang Yangda00c242010-03-19 11:23:45 +01001673static int alc_auto_parse_customize_define(struct hda_codec *codec)
1674{
1675 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +01001676 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +01001677 struct alc_spec *spec = codec->spec;
1678
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001679 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1680
David Henningsson90622912010-10-14 14:50:18 +02001681 if (spec->cdefine.fixup) {
1682 ass = spec->cdefine.sku_cfg;
1683 if (ass == ALC_FIXUP_SKU_IGNORE)
1684 return -1;
1685 goto do_sku;
1686 }
1687
Kailang Yangda00c242010-03-19 11:23:45 +01001688 ass = codec->subsystem_id & 0xffff;
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001689 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
Kailang Yangda00c242010-03-19 11:23:45 +01001690 goto do_sku;
1691
1692 nid = 0x1d;
1693 if (codec->vendor_id == 0x10ec0260)
1694 nid = 0x17;
1695 ass = snd_hda_codec_get_pincfg(codec, nid);
1696
1697 if (!(ass & 1)) {
1698 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1699 codec->chip_name, ass);
1700 return -1;
1701 }
1702
1703 /* check sum */
1704 tmp = 0;
1705 for (i = 1; i < 16; i++) {
1706 if ((ass >> i) & 1)
1707 tmp++;
1708 }
1709 if (((ass >> 16) & 0xf) != tmp)
1710 return -1;
1711
1712 spec->cdefine.port_connectivity = ass >> 30;
1713 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1714 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1715 spec->cdefine.customization = ass >> 8;
1716do_sku:
1717 spec->cdefine.sku_cfg = ass;
1718 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1719 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1720 spec->cdefine.swap = (ass & 0x2) >> 1;
1721 spec->cdefine.override = ass & 0x1;
1722
1723 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1724 nid, spec->cdefine.sku_cfg);
1725 snd_printd("SKU: port_connectivity=0x%x\n",
1726 spec->cdefine.port_connectivity);
1727 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1728 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1729 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1730 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1731 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1732 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1733 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1734
1735 return 0;
1736}
1737
Takashi Iwai3af9ee62011-06-27 12:34:01 +02001738static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
1739{
1740 int i;
1741 for (i = 0; i < nums; i++)
1742 if (list[i] == nid)
1743 return true;
1744 return false;
1745}
1746
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001747/* check subsystem ID and set up device-specific initialization;
1748 * return 1 if initialized, 0 if invalid SSID
1749 */
1750/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1751 * 31 ~ 16 : Manufacture ID
1752 * 15 ~ 8 : SKU ID
1753 * 7 ~ 0 : Assembly ID
1754 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1755 */
1756static int alc_subsystem_id(struct hda_codec *codec,
1757 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001758 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001759{
1760 unsigned int ass, tmp, i;
1761 unsigned nid;
1762 struct alc_spec *spec = codec->spec;
1763
David Henningsson90622912010-10-14 14:50:18 +02001764 if (spec->cdefine.fixup) {
1765 ass = spec->cdefine.sku_cfg;
1766 if (ass == ALC_FIXUP_SKU_IGNORE)
1767 return 0;
1768 goto do_sku;
1769 }
1770
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001771 ass = codec->subsystem_id & 0xffff;
1772 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1773 goto do_sku;
1774
1775 /* invalid SSID, check the special NID pin defcfg instead */
1776 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001777 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001778 * 29~21 : reserve
1779 * 20 : PCBEEP input
1780 * 19~16 : Check sum (15:1)
1781 * 15~1 : Custom
1782 * 0 : override
1783 */
1784 nid = 0x1d;
1785 if (codec->vendor_id == 0x10ec0260)
1786 nid = 0x17;
1787 ass = snd_hda_codec_get_pincfg(codec, nid);
1788 snd_printd("realtek: No valid SSID, "
1789 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001790 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001791 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001792 return 0;
1793 if ((ass >> 30) != 1) /* no physical connection */
1794 return 0;
1795
1796 /* check sum */
1797 tmp = 0;
1798 for (i = 1; i < 16; i++) {
1799 if ((ass >> i) & 1)
1800 tmp++;
1801 }
1802 if (((ass >> 16) & 0xf) != tmp)
1803 return 0;
1804do_sku:
1805 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1806 ass & 0xffff, codec->vendor_id);
1807 /*
1808 * 0 : override
1809 * 1 : Swap Jack
1810 * 2 : 0 --> Desktop, 1 --> Laptop
1811 * 3~5 : External Amplifier control
1812 * 7~6 : Reserved
1813 */
1814 tmp = (ass & 0x38) >> 3; /* external Amp control */
1815 switch (tmp) {
1816 case 1:
1817 spec->init_amp = ALC_INIT_GPIO1;
1818 break;
1819 case 3:
1820 spec->init_amp = ALC_INIT_GPIO2;
1821 break;
1822 case 7:
1823 spec->init_amp = ALC_INIT_GPIO3;
1824 break;
1825 case 5:
Takashi Iwai5a8cfb42010-11-26 17:11:18 +01001826 default:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001827 spec->init_amp = ALC_INIT_DEFAULT;
1828 break;
1829 }
1830
1831 /* is laptop or Desktop and enable the function "Mute internal speaker
1832 * when the external headphone out jack is plugged"
1833 */
1834 if (!(ass & 0x8000))
1835 return 1;
1836 /*
1837 * 10~8 : Jack location
1838 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1839 * 14~13: Resvered
1840 * 15 : 1 --> enable the function "Mute internal speaker
1841 * when the external headphone out jack is plugged"
1842 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001843 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001844 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001845 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1846 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001847 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001848 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001849 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001850 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001851 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001852 else if (tmp == 3)
1853 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001854 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001855 return 1;
Takashi Iwai3af9ee62011-06-27 12:34:01 +02001856 if (found_in_nid_list(nid, spec->autocfg.line_out_pins,
1857 spec->autocfg.line_outs))
1858 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001859 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001860 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001861 return 1;
1862}
Kailang Yangea1fb292008-08-26 12:58:38 +02001863
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001864static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001865 hda_nid_t porta, hda_nid_t porte,
1866 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001867{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001868 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001869 struct alc_spec *spec = codec->spec;
1870 snd_printd("realtek: "
1871 "Enable default setup for auto mode as fallback\n");
1872 spec->init_amp = ALC_INIT_DEFAULT;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001873 }
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001874
1875 alc_init_auto_hp(codec);
1876 alc_init_auto_mic(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001877}
1878
Takashi Iwai41e41f12005-06-08 14:48:49 +02001879/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001880 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001881 */
1882
1883struct alc_pincfg {
1884 hda_nid_t nid;
1885 u32 val;
1886};
1887
Todd Broche1eb5f12010-12-06 11:19:51 -08001888struct alc_model_fixup {
1889 const int id;
1890 const char *name;
1891};
1892
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001893struct alc_fixup {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001894 int type;
Takashi Iwai361fe6e2011-01-14 09:55:32 +01001895 bool chained;
1896 int chain_id;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001897 union {
1898 unsigned int sku;
1899 const struct alc_pincfg *pins;
1900 const struct hda_verb *verbs;
1901 void (*func)(struct hda_codec *codec,
1902 const struct alc_fixup *fix,
1903 int action);
1904 } v;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001905};
1906
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001907enum {
1908 ALC_FIXUP_INVALID,
1909 ALC_FIXUP_SKU,
1910 ALC_FIXUP_PINS,
1911 ALC_FIXUP_VERBS,
1912 ALC_FIXUP_FUNC,
1913};
Takashi Iwaif95474e2007-07-10 00:47:43 +02001914
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001915enum {
1916 ALC_FIXUP_ACT_PRE_PROBE,
1917 ALC_FIXUP_ACT_PROBE,
Takashi Iwai58701122011-01-13 15:41:45 +01001918 ALC_FIXUP_ACT_INIT,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001919};
1920
1921static void alc_apply_fixup(struct hda_codec *codec, int action)
1922{
1923 struct alc_spec *spec = codec->spec;
1924 int id = spec->fixup_id;
Takashi Iwaiaa1d0c52011-01-19 17:27:58 +01001925#ifdef CONFIG_SND_DEBUG_VERBOSE
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001926 const char *modelname = spec->fixup_name;
Takashi Iwaiaa1d0c52011-01-19 17:27:58 +01001927#endif
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001928 int depth = 0;
1929
1930 if (!spec->fixup_list)
1931 return;
1932
1933 while (id >= 0) {
1934 const struct alc_fixup *fix = spec->fixup_list + id;
1935 const struct alc_pincfg *cfg;
1936
1937 switch (fix->type) {
1938 case ALC_FIXUP_SKU:
1939 if (action != ALC_FIXUP_ACT_PRE_PROBE || !fix->v.sku)
1940 break;;
1941 snd_printdd(KERN_INFO "hda_codec: %s: "
1942 "Apply sku override for %s\n",
1943 codec->chip_name, modelname);
1944 spec->cdefine.sku_cfg = fix->v.sku;
1945 spec->cdefine.fixup = 1;
1946 break;
1947 case ALC_FIXUP_PINS:
1948 cfg = fix->v.pins;
1949 if (action != ALC_FIXUP_ACT_PRE_PROBE || !cfg)
1950 break;
1951 snd_printdd(KERN_INFO "hda_codec: %s: "
1952 "Apply pincfg for %s\n",
1953 codec->chip_name, modelname);
1954 for (; cfg->nid; cfg++)
1955 snd_hda_codec_set_pincfg(codec, cfg->nid,
1956 cfg->val);
1957 break;
1958 case ALC_FIXUP_VERBS:
1959 if (action != ALC_FIXUP_ACT_PROBE || !fix->v.verbs)
1960 break;
1961 snd_printdd(KERN_INFO "hda_codec: %s: "
1962 "Apply fix-verbs for %s\n",
1963 codec->chip_name, modelname);
1964 add_verb(codec->spec, fix->v.verbs);
1965 break;
1966 case ALC_FIXUP_FUNC:
1967 if (!fix->v.func)
1968 break;
1969 snd_printdd(KERN_INFO "hda_codec: %s: "
1970 "Apply fix-func for %s\n",
1971 codec->chip_name, modelname);
1972 fix->v.func(codec, fix, action);
1973 break;
1974 default:
1975 snd_printk(KERN_ERR "hda_codec: %s: "
1976 "Invalid fixup type %d\n",
1977 codec->chip_name, fix->type);
1978 break;
1979 }
Takashi Iwai24af2b12011-05-02 13:55:36 +02001980 if (!fix->chained)
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001981 break;
1982 if (++depth > 10)
1983 break;
Takashi Iwai24af2b12011-05-02 13:55:36 +02001984 id = fix->chain_id;
Takashi Iwai9d578832010-11-22 13:29:19 +01001985 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001986}
1987
Todd Broche1eb5f12010-12-06 11:19:51 -08001988static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001989 const struct alc_model_fixup *models,
1990 const struct snd_pci_quirk *quirk,
1991 const struct alc_fixup *fixlist)
Todd Broche1eb5f12010-12-06 11:19:51 -08001992{
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001993 struct alc_spec *spec = codec->spec;
1994 int id = -1;
1995 const char *name = NULL;
Todd Broche1eb5f12010-12-06 11:19:51 -08001996
Todd Broche1eb5f12010-12-06 11:19:51 -08001997 if (codec->modelname && models) {
1998 while (models->name) {
1999 if (!strcmp(codec->modelname, models->name)) {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01002000 id = models->id;
2001 name = models->name;
Todd Broche1eb5f12010-12-06 11:19:51 -08002002 break;
2003 }
2004 models++;
2005 }
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01002006 }
2007 if (id < 0) {
2008 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
2009 if (quirk) {
2010 id = quirk->value;
2011#ifdef CONFIG_SND_DEBUG_VERBOSE
2012 name = quirk->name;
2013#endif
2014 }
2015 }
2016
2017 spec->fixup_id = id;
2018 if (id >= 0) {
2019 spec->fixup_list = fixlist;
2020 spec->fixup_name = name;
Todd Broche1eb5f12010-12-06 11:19:51 -08002021 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02002022}
2023
Kailang Yang274693f2009-12-03 10:07:50 +01002024static int alc_read_coef_idx(struct hda_codec *codec,
2025 unsigned int coef_idx)
2026{
2027 unsigned int val;
2028 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
2029 coef_idx);
2030 val = snd_hda_codec_read(codec, 0x20, 0,
2031 AC_VERB_GET_PROC_COEF, 0);
2032 return val;
2033}
2034
Kailang Yang977ddd62010-09-15 10:02:29 +02002035static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
2036 unsigned int coef_val)
2037{
2038 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
2039 coef_idx);
2040 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
2041 coef_val);
2042}
2043
Takashi Iwai757899a2010-07-30 10:48:14 +02002044/* set right pin controls for digital I/O */
2045static void alc_auto_init_digital(struct hda_codec *codec)
2046{
2047 struct alc_spec *spec = codec->spec;
2048 int i;
Takashi Iwai1f0f4b82011-06-27 10:52:59 +02002049 hda_nid_t pin, dac;
Takashi Iwai757899a2010-07-30 10:48:14 +02002050
2051 for (i = 0; i < spec->autocfg.dig_outs; i++) {
2052 pin = spec->autocfg.dig_out_pins[i];
Takashi Iwai1f0f4b82011-06-27 10:52:59 +02002053 if (!pin)
2054 continue;
2055 snd_hda_codec_write(codec, pin, 0,
2056 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
2057 if (!i)
2058 dac = spec->multiout.dig_out_nid;
2059 else
2060 dac = spec->slave_dig_outs[i - 1];
2061 if (!dac || !(get_wcaps(codec, dac) & AC_WCAP_OUT_AMP))
2062 continue;
2063 snd_hda_codec_write(codec, dac, 0,
2064 AC_VERB_SET_AMP_GAIN_MUTE,
2065 AMP_OUT_UNMUTE);
Takashi Iwai757899a2010-07-30 10:48:14 +02002066 }
2067 pin = spec->autocfg.dig_in_pin;
2068 if (pin)
2069 snd_hda_codec_write(codec, pin, 0,
2070 AC_VERB_SET_PIN_WIDGET_CONTROL,
2071 PIN_IN);
2072}
2073
2074/* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
2075static void alc_auto_parse_digital(struct hda_codec *codec)
2076{
2077 struct alc_spec *spec = codec->spec;
2078 int i, err;
2079 hda_nid_t dig_nid;
2080
2081 /* support multiple SPDIFs; the secondary is set up as a slave */
2082 for (i = 0; i < spec->autocfg.dig_outs; i++) {
2083 err = snd_hda_get_connections(codec,
2084 spec->autocfg.dig_out_pins[i],
2085 &dig_nid, 1);
2086 if (err < 0)
2087 continue;
2088 if (!i) {
2089 spec->multiout.dig_out_nid = dig_nid;
2090 spec->dig_out_type = spec->autocfg.dig_out_type[0];
2091 } else {
2092 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
2093 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
2094 break;
2095 spec->slave_dig_outs[i - 1] = dig_nid;
2096 }
2097 }
2098
2099 if (spec->autocfg.dig_in_pin) {
Takashi Iwai01fdf182010-09-24 09:09:42 +02002100 dig_nid = codec->start_nid;
2101 for (i = 0; i < codec->num_nodes; i++, dig_nid++) {
2102 unsigned int wcaps = get_wcaps(codec, dig_nid);
2103 if (get_wcaps_type(wcaps) != AC_WID_AUD_IN)
2104 continue;
2105 if (!(wcaps & AC_WCAP_DIGITAL))
2106 continue;
2107 if (!(wcaps & AC_WCAP_CONN_LIST))
2108 continue;
2109 err = get_connection_index(codec, dig_nid,
2110 spec->autocfg.dig_in_pin);
2111 if (err >= 0) {
2112 spec->dig_in_nid = dig_nid;
2113 break;
2114 }
2115 }
Takashi Iwai757899a2010-07-30 10:48:14 +02002116 }
2117}
2118
Takashi Iwaif95474e2007-07-10 00:47:43 +02002119/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002120 * ALC888
2121 */
2122
2123/*
2124 * 2ch mode
2125 */
Takashi Iwaia9111322011-05-02 11:30:18 +02002126static const struct hda_verb alc888_4ST_ch2_intel_init[] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002127/* Mic-in jack as mic in */
2128 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2129 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2130/* Line-in jack as Line in */
2131 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2132 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2133/* Line-Out as Front */
2134 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
2135 { } /* end */
2136};
2137
2138/*
2139 * 4ch mode
2140 */
Takashi Iwaia9111322011-05-02 11:30:18 +02002141static const struct hda_verb alc888_4ST_ch4_intel_init[] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002142/* Mic-in jack as mic in */
2143 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2144 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2145/* Line-in jack as Surround */
2146 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2147 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2148/* Line-Out as Front */
2149 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
2150 { } /* end */
2151};
2152
2153/*
2154 * 6ch mode
2155 */
Takashi Iwaia9111322011-05-02 11:30:18 +02002156static const struct hda_verb alc888_4ST_ch6_intel_init[] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002157/* Mic-in jack as CLFE */
2158 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2159 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2160/* Line-in jack as Surround */
2161 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2162 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2163/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
2164 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
2165 { } /* end */
2166};
2167
2168/*
2169 * 8ch mode
2170 */
Takashi Iwaia9111322011-05-02 11:30:18 +02002171static const struct hda_verb alc888_4ST_ch8_intel_init[] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002172/* Mic-in jack as CLFE */
2173 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2174 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2175/* Line-in jack as Surround */
2176 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2177 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2178/* Line-Out as Side */
2179 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
2180 { } /* end */
2181};
2182
Takashi Iwaia9111322011-05-02 11:30:18 +02002183static const struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002184 { 2, alc888_4ST_ch2_intel_init },
2185 { 4, alc888_4ST_ch4_intel_init },
2186 { 6, alc888_4ST_ch6_intel_init },
2187 { 8, alc888_4ST_ch8_intel_init },
2188};
2189
2190/*
2191 * ALC888 Fujitsu Siemens Amillo xa3530
2192 */
2193
Takashi Iwaia9111322011-05-02 11:30:18 +02002194static const struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002195/* Front Mic: set to PIN_IN (empty by default) */
2196 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2197/* Connect Internal HP to Front */
2198 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2199 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2200 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2201/* Connect Bass HP to Front */
2202 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2203 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2204 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2205/* Connect Line-Out side jack (SPDIF) to Side */
2206 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2207 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2208 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
2209/* Connect Mic jack to CLFE */
2210 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2211 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2212 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
2213/* Connect Line-in jack to Surround */
2214 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2215 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2216 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
2217/* Connect HP out jack to Front */
2218 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2219 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2220 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2221/* Enable unsolicited event for HP jack and Line-out jack */
2222 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2223 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2224 {}
2225};
2226
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002227static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02002228{
2229 struct alc_spec *spec = codec->spec;
2230
2231 spec->autocfg.hp_pins[0] = 0x15;
2232 spec->autocfg.speaker_pins[0] = 0x14;
2233 spec->autocfg.speaker_pins[1] = 0x16;
2234 spec->autocfg.speaker_pins[2] = 0x17;
2235 spec->autocfg.speaker_pins[3] = 0x19;
2236 spec->autocfg.speaker_pins[4] = 0x1a;
Takashi Iwaid922b512011-04-28 12:18:53 +02002237 spec->automute = 1;
2238 spec->automute_mode = ALC_AUTOMUTE_AMP;
Wu Fengguang6732bd02009-07-30 09:19:14 +02002239}
2240
2241static void alc889_intel_init_hook(struct hda_codec *codec)
2242{
2243 alc889_coef_init(codec);
Takashi Iwaid922b512011-04-28 12:18:53 +02002244 alc_hp_automute(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02002245}
2246
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002247static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002248{
2249 struct alc_spec *spec = codec->spec;
2250
2251 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
2252 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
2253 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
2254 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaid922b512011-04-28 12:18:53 +02002255 spec->automute = 1;
2256 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002257}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002258
2259/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002260 * ALC888 Acer Aspire 4930G model
2261 */
2262
Takashi Iwaia9111322011-05-02 11:30:18 +02002263static const struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002264/* Front Mic: set to PIN_IN (empty by default) */
2265 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2266/* Unselect Front Mic by default in input mixer 3 */
2267 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002268/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002269 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2270/* Connect Internal HP to front */
2271 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2272 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2273 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2274/* Connect HP out to front */
2275 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2276 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2277 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie2e93292011-01-12 08:03:39 +01002278 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002279 { }
2280};
2281
Hector Martin3b315d72009-06-02 10:54:19 +02002282/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01002283 * ALC888 Acer Aspire 6530G model
2284 */
2285
Takashi Iwaia9111322011-05-02 11:30:18 +02002286static const struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
Tony Vroond1284182010-04-05 16:30:43 +01002287/* Route to built-in subwoofer as well as speakers */
2288 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2289 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2290 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2291 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002292/* Bias voltage on for external mic port */
2293 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02002294/* Front Mic: set to PIN_IN (empty by default) */
2295 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2296/* Unselect Front Mic by default in input mixer 3 */
2297 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002298/* Enable unsolicited event for HP jack */
2299 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2300/* Enable speaker output */
2301 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2302 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tony Vroond1284182010-04-05 16:30:43 +01002303 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002304/* Enable headphone output */
2305 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2306 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2307 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Tony Vroond1284182010-04-05 16:30:43 +01002308 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002309 { }
2310};
2311
2312/*
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002313 *ALC888 Acer Aspire 7730G model
2314 */
2315
Takashi Iwaia9111322011-05-02 11:30:18 +02002316static const struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002317/* Bias voltage on for external mic port */
2318 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
2319/* Front Mic: set to PIN_IN (empty by default) */
2320 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2321/* Unselect Front Mic by default in input mixer 3 */
2322 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2323/* Enable unsolicited event for HP jack */
2324 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2325/* Enable speaker output */
2326 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2327 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2328 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
2329/* Enable headphone output */
2330 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2331 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2332 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2333 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
2334/*Enable internal subwoofer */
2335 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2336 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2337 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
2338 {0x17, AC_VERB_SET_EAPD_BTLENABLE, 2},
2339 { }
2340};
2341
2342/*
Hector Martin018df412009-06-04 00:13:40 +02002343 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02002344 */
2345
Takashi Iwaia9111322011-05-02 11:30:18 +02002346static const struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02002347/* Front Mic: set to PIN_IN (empty by default) */
2348 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2349/* Unselect Front Mic by default in input mixer 3 */
2350 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2351/* Enable unsolicited event for HP jack */
2352 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2353/* Connect Internal Front to Front */
2354 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2355 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2356 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2357/* Connect Internal Rear to Rear */
2358 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2359 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2360 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
2361/* Connect Internal CLFE to CLFE */
2362 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2363 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2364 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
2365/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02002366 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02002367 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2368 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2369/* Enable all DACs */
2370/* DAC DISABLE/MUTE 1? */
2371/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
2372 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
2373 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
2374/* DAC DISABLE/MUTE 2? */
2375/* some bit here disables the other DACs. Init=0x4900 */
2376 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
2377 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02002378/* DMIC fix
2379 * This laptop has a stereo digital microphone. The mics are only 1cm apart
2380 * which makes the stereo useless. However, either the mic or the ALC889
2381 * makes the signal become a difference/sum signal instead of standard
2382 * stereo, which is annoying. So instead we flip this bit which makes the
2383 * codec replicate the sum signal to both channels, turning it into a
2384 * normal mono mic.
2385 */
2386/* DMIC_CONTROL? Init value = 0x0001 */
2387 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
2388 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02002389 { }
2390};
2391
Takashi Iwaia9111322011-05-02 11:30:18 +02002392static const struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002393 /* Front mic only available on one ADC */
2394 {
2395 .num_items = 4,
2396 .items = {
2397 { "Mic", 0x0 },
2398 { "Line", 0x2 },
2399 { "CD", 0x4 },
2400 { "Front Mic", 0xb },
2401 },
2402 },
2403 {
2404 .num_items = 3,
2405 .items = {
2406 { "Mic", 0x0 },
2407 { "Line", 0x2 },
2408 { "CD", 0x4 },
2409 },
2410 }
2411};
2412
Takashi Iwaia9111322011-05-02 11:30:18 +02002413static const struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
Tony Vroond2fd4b02009-06-21 00:40:10 +01002414 /* Interal mic only available on one ADC */
2415 {
Tony Vroon684a8842009-06-26 09:27:50 +01002416 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002417 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +01002418 { "Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002419 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002420 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002421 { "Input Mix", 0xa },
David Henningsson28c4edb2010-12-20 14:24:29 +01002422 { "Internal Mic", 0xb },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002423 },
2424 },
2425 {
Tony Vroon684a8842009-06-26 09:27:50 +01002426 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002427 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +01002428 { "Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002429 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002430 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002431 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002432 },
2433 }
2434};
2435
Takashi Iwaia9111322011-05-02 11:30:18 +02002436static const struct hda_input_mux alc889_capture_sources[3] = {
Hector Martin018df412009-06-04 00:13:40 +02002437 /* Digital mic only available on first "ADC" */
2438 {
2439 .num_items = 5,
2440 .items = {
2441 { "Mic", 0x0 },
2442 { "Line", 0x2 },
2443 { "CD", 0x4 },
2444 { "Front Mic", 0xb },
2445 { "Input Mix", 0xa },
2446 },
2447 },
2448 {
2449 .num_items = 4,
2450 .items = {
2451 { "Mic", 0x0 },
2452 { "Line", 0x2 },
2453 { "CD", 0x4 },
2454 { "Input Mix", 0xa },
2455 },
2456 },
2457 {
2458 .num_items = 4,
2459 .items = {
2460 { "Mic", 0x0 },
2461 { "Line", 0x2 },
2462 { "CD", 0x4 },
2463 { "Input Mix", 0xa },
2464 },
2465 }
2466};
2467
Takashi Iwaia9111322011-05-02 11:30:18 +02002468static const struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002469 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2470 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2471 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2472 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2473 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2474 HDA_OUTPUT),
2475 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2476 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2477 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2478 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2479 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2480 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2481 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2482 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2483 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2484 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01002485 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002486 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002487 { } /* end */
2488};
2489
Takashi Iwaia9111322011-05-02 11:30:18 +02002490static const struct snd_kcontrol_new alc888_acer_aspire_4930g_mixer[] = {
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +01002491 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2492 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2493 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2494 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Łukasz Wojniłowicz786c51f2011-02-24 10:03:31 +01002495 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +01002496 HDA_OUTPUT),
Łukasz Wojniłowicz786c51f2011-02-24 10:03:31 +01002497 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2498 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2499 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2500 HDA_CODEC_VOLUME_MONO("Internal LFE Playback Volume", 0x0f, 1, 0x0, HDA_OUTPUT),
2501 HDA_BIND_MUTE_MONO("Internal LFE Playback Switch", 0x0f, 1, 2, HDA_INPUT),
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +01002502 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2503 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2504 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2505 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2506 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2507 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
2508 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2509 { } /* end */
2510};
2511
Takashi Iwaia9111322011-05-02 11:30:18 +02002512static const struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
Hector Martin556eea92009-12-20 22:51:23 +01002513 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2514 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2515 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2516 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2517 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2518 HDA_OUTPUT),
2519 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2520 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2521 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2522 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2523 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2524 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01002525 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Hector Martin556eea92009-12-20 22:51:23 +01002526 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2527 { } /* end */
2528};
2529
2530
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002531static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002532{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002533 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002534
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002535 spec->autocfg.hp_pins[0] = 0x15;
2536 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01002537 spec->autocfg.speaker_pins[1] = 0x16;
2538 spec->autocfg.speaker_pins[2] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02002539 spec->automute = 1;
2540 spec->automute_mode = ALC_AUTOMUTE_AMP;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002541}
2542
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002543static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02002544{
2545 struct alc_spec *spec = codec->spec;
2546
2547 spec->autocfg.hp_pins[0] = 0x15;
2548 spec->autocfg.speaker_pins[0] = 0x14;
2549 spec->autocfg.speaker_pins[1] = 0x16;
2550 spec->autocfg.speaker_pins[2] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02002551 spec->automute = 1;
2552 spec->automute_mode = ALC_AUTOMUTE_AMP;
Emilio López320d5922009-06-25 08:18:44 +02002553}
2554
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002555static void alc888_acer_aspire_7730g_setup(struct hda_codec *codec)
2556{
2557 struct alc_spec *spec = codec->spec;
2558
2559 spec->autocfg.hp_pins[0] = 0x15;
2560 spec->autocfg.speaker_pins[0] = 0x14;
2561 spec->autocfg.speaker_pins[1] = 0x16;
2562 spec->autocfg.speaker_pins[2] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02002563 spec->automute = 1;
2564 spec->automute_mode = ALC_AUTOMUTE_AMP;
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002565}
2566
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002567static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02002568{
2569 struct alc_spec *spec = codec->spec;
2570
2571 spec->autocfg.hp_pins[0] = 0x15;
2572 spec->autocfg.speaker_pins[0] = 0x14;
2573 spec->autocfg.speaker_pins[1] = 0x16;
2574 spec->autocfg.speaker_pins[2] = 0x1b;
Takashi Iwaid922b512011-04-28 12:18:53 +02002575 spec->automute = 1;
2576 spec->automute_mode = ALC_AUTOMUTE_AMP;
Hector Martin3b315d72009-06-02 10:54:19 +02002577}
2578
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002579/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002580 * ALC880 3-stack model
2581 *
2582 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002583 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2584 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07002585 */
2586
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02002587static const hda_nid_t alc880_dac_nids[4] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002588 /* front, rear, clfe, rear_surr */
2589 0x02, 0x05, 0x04, 0x03
2590};
2591
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02002592static const hda_nid_t alc880_adc_nids[3] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002593 /* ADC0-2 */
2594 0x07, 0x08, 0x09,
2595};
2596
2597/* The datasheet says the node 0x07 is connected from inputs,
2598 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01002599 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07002600 */
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02002601static const hda_nid_t alc880_adc_nids_alt[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002602 /* ADC1-2 */
2603 0x08, 0x09,
2604};
2605
2606#define ALC880_DIGOUT_NID 0x06
2607#define ALC880_DIGIN_NID 0x0a
2608
Takashi Iwaia9111322011-05-02 11:30:18 +02002609static const struct hda_input_mux alc880_capture_source = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002610 .num_items = 4,
2611 .items = {
2612 { "Mic", 0x0 },
2613 { "Front Mic", 0x3 },
2614 { "Line", 0x2 },
2615 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002616 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002617};
2618
2619/* channel source setting (2/6 channel selection for 3-stack) */
2620/* 2ch mode */
Takashi Iwaia9111322011-05-02 11:30:18 +02002621static const struct hda_verb alc880_threestack_ch2_init[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002622 /* set line-in to input, mute it */
2623 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2624 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2625 /* set mic-in to input vref 80%, mute it */
2626 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2627 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002628 { } /* end */
2629};
2630
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002631/* 6ch mode */
Takashi Iwaia9111322011-05-02 11:30:18 +02002632static const struct hda_verb alc880_threestack_ch6_init[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002633 /* set line-in to output, unmute it */
2634 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2635 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2636 /* set mic-in to output, unmute it */
2637 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2638 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2639 { } /* end */
2640};
2641
Takashi Iwaia9111322011-05-02 11:30:18 +02002642static const struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002643 { 2, alc880_threestack_ch2_init },
2644 { 6, alc880_threestack_ch6_init },
2645};
2646
Takashi Iwaia9111322011-05-02 11:30:18 +02002647static const struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002648 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002649 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002650 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002651 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002652 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2653 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002654 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2655 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002656 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2657 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2658 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2659 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2660 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2661 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2662 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2663 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002664 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002665 {
2666 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2667 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002668 .info = alc_ch_mode_info,
2669 .get = alc_ch_mode_get,
2670 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002671 },
2672 { } /* end */
2673};
2674
2675/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002676static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2677 struct snd_ctl_elem_info *uinfo)
2678{
2679 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2680 struct alc_spec *spec = codec->spec;
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +02002681 unsigned long val;
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002682 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002683
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002684 mutex_lock(&codec->control_mutex);
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +02002685 if (spec->vol_in_capsrc)
2686 val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT);
2687 else
2688 val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT);
2689 kcontrol->private_value = val;
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002690 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002691 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002692 return err;
2693}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002694
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002695static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2696 unsigned int size, unsigned int __user *tlv)
2697{
2698 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2699 struct alc_spec *spec = codec->spec;
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +02002700 unsigned long val;
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002701 int err;
2702
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002703 mutex_lock(&codec->control_mutex);
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +02002704 if (spec->vol_in_capsrc)
2705 val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT);
2706 else
2707 val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT);
2708 kcontrol->private_value = val;
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002709 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002710 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002711 return err;
2712}
2713
2714typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2715 struct snd_ctl_elem_value *ucontrol);
2716
2717static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2718 struct snd_ctl_elem_value *ucontrol,
Takashi Iwai9c7a0832011-07-07 09:25:54 +02002719 getput_call_t func, bool check_adc_switch)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002720{
2721 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2722 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7a0832011-07-07 09:25:54 +02002723 int i, err;
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002724
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002725 mutex_lock(&codec->control_mutex);
Takashi Iwai9c7a0832011-07-07 09:25:54 +02002726 if (check_adc_switch && spec->dual_adc_switch) {
2727 for (i = 0; i < spec->num_adc_nids; i++) {
2728 kcontrol->private_value =
2729 HDA_COMPOSE_AMP_VAL(spec->adc_nids[i],
2730 3, 0, HDA_INPUT);
2731 err = func(kcontrol, ucontrol);
2732 if (err < 0)
2733 goto error;
2734 }
2735 } else {
2736 i = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +02002737 if (spec->vol_in_capsrc)
2738 kcontrol->private_value =
2739 HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[i],
2740 3, 0, HDA_OUTPUT);
2741 else
2742 kcontrol->private_value =
2743 val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[i],
2744 3, 0, HDA_INPUT);
Takashi Iwai9c7a0832011-07-07 09:25:54 +02002745 err = func(kcontrol, ucontrol);
2746 }
2747 error:
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002748 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002749 return err;
2750}
2751
2752static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2753 struct snd_ctl_elem_value *ucontrol)
2754{
2755 return alc_cap_getput_caller(kcontrol, ucontrol,
Takashi Iwai9c7a0832011-07-07 09:25:54 +02002756 snd_hda_mixer_amp_volume_get, false);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002757}
2758
2759static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2760 struct snd_ctl_elem_value *ucontrol)
2761{
2762 return alc_cap_getput_caller(kcontrol, ucontrol,
Takashi Iwai9c7a0832011-07-07 09:25:54 +02002763 snd_hda_mixer_amp_volume_put, true);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002764}
2765
2766/* capture mixer elements */
2767#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2768
2769static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2770 struct snd_ctl_elem_value *ucontrol)
2771{
2772 return alc_cap_getput_caller(kcontrol, ucontrol,
Takashi Iwai9c7a0832011-07-07 09:25:54 +02002773 snd_hda_mixer_amp_switch_get, false);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002774}
2775
2776static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2777 struct snd_ctl_elem_value *ucontrol)
2778{
2779 return alc_cap_getput_caller(kcontrol, ucontrol,
Takashi Iwai9c7a0832011-07-07 09:25:54 +02002780 snd_hda_mixer_amp_switch_put, true);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002781}
2782
Takashi Iwaia23b6882009-03-23 15:21:36 +01002783#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002784 { \
2785 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2786 .name = "Capture Switch", \
2787 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2788 .count = num, \
2789 .info = alc_cap_sw_info, \
2790 .get = alc_cap_sw_get, \
2791 .put = alc_cap_sw_put, \
2792 }, \
2793 { \
2794 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2795 .name = "Capture Volume", \
2796 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2797 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2798 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2799 .count = num, \
2800 .info = alc_cap_vol_info, \
2801 .get = alc_cap_vol_get, \
2802 .put = alc_cap_vol_put, \
2803 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002804 }
2805
2806#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002807 { \
2808 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2809 /* .name = "Capture Source", */ \
2810 .name = "Input Source", \
2811 .count = num, \
2812 .info = alc_mux_enum_info, \
2813 .get = alc_mux_enum_get, \
2814 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002815 }
2816
2817#define DEFINE_CAPMIX(num) \
Takashi Iwaia9111322011-05-02 11:30:18 +02002818static const struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002819 _DEFINE_CAPMIX(num), \
2820 _DEFINE_CAPSRC(num), \
2821 { } /* end */ \
2822}
2823
2824#define DEFINE_CAPMIX_NOSRC(num) \
Takashi Iwaia9111322011-05-02 11:30:18 +02002825static const struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002826 _DEFINE_CAPMIX(num), \
2827 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002828}
2829
2830/* up to three ADCs */
2831DEFINE_CAPMIX(1);
2832DEFINE_CAPMIX(2);
2833DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002834DEFINE_CAPMIX_NOSRC(1);
2835DEFINE_CAPMIX_NOSRC(2);
2836DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002837
2838/*
2839 * ALC880 5-stack model
2840 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002841 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2842 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002843 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2844 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2845 */
2846
2847/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaia9111322011-05-02 11:30:18 +02002848static const struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002849 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002850 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002851 { } /* end */
2852};
2853
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002854/* channel source setting (6/8 channel selection for 5-stack) */
2855/* 6ch mode */
Takashi Iwaia9111322011-05-02 11:30:18 +02002856static const struct hda_verb alc880_fivestack_ch6_init[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002857 /* set line-in to input, mute it */
2858 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2859 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002860 { } /* end */
2861};
2862
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002863/* 8ch mode */
Takashi Iwaia9111322011-05-02 11:30:18 +02002864static const struct hda_verb alc880_fivestack_ch8_init[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002865 /* set line-in to output, unmute it */
2866 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2867 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2868 { } /* end */
2869};
2870
Takashi Iwaia9111322011-05-02 11:30:18 +02002871static const struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002872 { 6, alc880_fivestack_ch6_init },
2873 { 8, alc880_fivestack_ch8_init },
2874};
2875
2876
2877/*
2878 * ALC880 6-stack model
2879 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002880 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2881 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002882 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2883 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2884 */
2885
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02002886static const hda_nid_t alc880_6st_dac_nids[4] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002887 /* front, rear, clfe, rear_surr */
2888 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002889};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002890
Takashi Iwaia9111322011-05-02 11:30:18 +02002891static const struct hda_input_mux alc880_6stack_capture_source = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002892 .num_items = 4,
2893 .items = {
2894 { "Mic", 0x0 },
2895 { "Front Mic", 0x1 },
2896 { "Line", 0x2 },
2897 { "CD", 0x4 },
2898 },
2899};
2900
2901/* fixed 8-channels */
Takashi Iwaia9111322011-05-02 11:30:18 +02002902static const struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002903 { 8, NULL },
2904};
2905
Takashi Iwaia9111322011-05-02 11:30:18 +02002906static const struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002907 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002908 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002909 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002910 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002911 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2912 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002913 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2914 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002915 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002916 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002917 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2918 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2919 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2920 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2921 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2922 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2923 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2924 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002925 {
2926 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2927 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002928 .info = alc_ch_mode_info,
2929 .get = alc_ch_mode_get,
2930 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002931 },
2932 { } /* end */
2933};
2934
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002935
2936/*
2937 * ALC880 W810 model
2938 *
2939 * W810 has rear IO for:
2940 * Front (DAC 02)
2941 * Surround (DAC 03)
2942 * Center/LFE (DAC 04)
2943 * Digital out (06)
2944 *
2945 * The system also has a pair of internal speakers, and a headphone jack.
2946 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002947 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002948 * There is a variable resistor to control the speaker or headphone
2949 * volume. This is a hardware-only device without a software API.
2950 *
2951 * Plugging headphones in will disable the internal speakers. This is
2952 * implemented in hardware, not via the driver using jack sense. In
2953 * a similar fashion, plugging into the rear socket marked "front" will
2954 * disable both the speakers and headphones.
2955 *
2956 * For input, there's a microphone jack, and an "audio in" jack.
2957 * These may not do anything useful with this driver yet, because I
2958 * haven't setup any initialization verbs for these yet...
2959 */
2960
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02002961static const hda_nid_t alc880_w810_dac_nids[3] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002962 /* front, rear/surround, clfe */
2963 0x02, 0x03, 0x04
2964};
2965
2966/* fixed 6 channels */
Takashi Iwaia9111322011-05-02 11:30:18 +02002967static const struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002968 { 6, NULL }
2969};
2970
2971/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaia9111322011-05-02 11:30:18 +02002972static const struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002973 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002974 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002975 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002976 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002977 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2978 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002979 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2980 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002981 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2982 { } /* end */
2983};
2984
2985
2986/*
2987 * Z710V model
2988 *
2989 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002990 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2991 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002992 */
2993
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02002994static const hda_nid_t alc880_z71v_dac_nids[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002995 0x02
2996};
2997#define ALC880_Z71V_HP_DAC 0x03
2998
2999/* fixed 2 channels */
Takashi Iwaia9111322011-05-02 11:30:18 +02003000static const struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003001 { 2, NULL }
3002};
3003
Takashi Iwaia9111322011-05-02 11:30:18 +02003004static const struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003005 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003006 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003007 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003008 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003009 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
3010 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
3011 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3012 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3013 { } /* end */
3014};
3015
3016
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003017/*
3018 * ALC880 F1734 model
3019 *
3020 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
3021 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
3022 */
3023
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02003024static const hda_nid_t alc880_f1734_dac_nids[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003025 0x03
3026};
3027#define ALC880_F1734_HP_DAC 0x02
3028
Takashi Iwaia9111322011-05-02 11:30:18 +02003029static const struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02003030 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003031 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01003032 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3033 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003034 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
3035 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01003036 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3037 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003038 { } /* end */
3039};
3040
Takashi Iwaia9111322011-05-02 11:30:18 +02003041static const struct hda_input_mux alc880_f1734_capture_source = {
Takashi Iwai937b4162008-02-11 14:52:36 +01003042 .num_items = 2,
3043 .items = {
3044 { "Mic", 0x1 },
3045 { "CD", 0x4 },
3046 },
3047};
3048
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003049
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003050/*
3051 * ALC880 ASUS model
3052 *
3053 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
3054 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
3055 * Mic = 0x18, Line = 0x1a
3056 */
3057
3058#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
3059#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
3060
Takashi Iwaia9111322011-05-02 11:30:18 +02003061static const struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02003062 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003063 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003064 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003065 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003066 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3067 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003068 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3069 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003070 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
3071 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
3072 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3073 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
3074 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3075 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003076 {
3077 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3078 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003079 .info = alc_ch_mode_info,
3080 .get = alc_ch_mode_get,
3081 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02003082 },
3083 { } /* end */
3084};
3085
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003086/*
3087 * ALC880 ASUS W1V model
3088 *
3089 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
3090 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
3091 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
3092 */
3093
3094/* additional mixers to alc880_asus_mixer */
Takashi Iwaia9111322011-05-02 11:30:18 +02003095static const struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02003096 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
3097 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003098 { } /* end */
3099};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003100
Kailang Yangdf694da2005-12-05 19:42:22 +01003101/* TCL S700 */
Takashi Iwaia9111322011-05-02 11:30:18 +02003102static const struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01003103 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3104 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
3105 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
3106 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
3107 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
3108 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
3109 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
3110 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
3111 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003112 { } /* end */
3113};
3114
Kailang Yangccc656c2006-10-17 12:32:26 +02003115/* Uniwill */
Takashi Iwaia9111322011-05-02 11:30:18 +02003116static const struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003117 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3118 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
3119 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3120 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02003121 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3122 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3123 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3124 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3125 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
3126 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
3127 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3128 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
3129 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3130 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3131 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3132 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02003133 {
3134 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3135 .name = "Channel Mode",
3136 .info = alc_ch_mode_info,
3137 .get = alc_ch_mode_get,
3138 .put = alc_ch_mode_put,
3139 },
3140 { } /* end */
3141};
3142
Takashi Iwaia9111322011-05-02 11:30:18 +02003143static const struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003144 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3145 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
3146 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3147 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
3148 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
3149 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson8607f7c2010-12-20 14:43:54 +01003150 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3151 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01003152 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3153 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003154 { } /* end */
3155};
3156
Takashi Iwaia9111322011-05-02 11:30:18 +02003157static const struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003158 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3159 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
3160 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3161 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02003162 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3163 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3164 { } /* end */
3165};
3166
Linus Torvalds1da177e2005-04-16 15:20:36 -07003167/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01003168 * virtual master controls
3169 */
3170
3171/*
3172 * slave controls for virtual master
3173 */
Takashi Iwaiea734962011-01-17 11:29:34 +01003174static const char * const alc_slave_vols[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003175 "Front Playback Volume",
3176 "Surround Playback Volume",
3177 "Center Playback Volume",
3178 "LFE Playback Volume",
3179 "Side Playback Volume",
3180 "Headphone Playback Volume",
3181 "Speaker Playback Volume",
3182 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01003183 "Line-Out Playback Volume",
3184 NULL,
3185};
3186
Takashi Iwaiea734962011-01-17 11:29:34 +01003187static const char * const alc_slave_sws[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003188 "Front Playback Switch",
3189 "Surround Playback Switch",
3190 "Center Playback Switch",
3191 "LFE Playback Switch",
3192 "Side Playback Switch",
3193 "Headphone Playback Switch",
3194 "Speaker Playback Switch",
3195 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01003196 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01003197 "Line-Out Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01003198 NULL,
3199};
3200
3201/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003202 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07003203 */
Takashi Iwai603c4012008-07-30 15:01:44 +02003204
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003205#define NID_MAPPING (-1)
3206
3207#define SUBDEV_SPEAKER_ (0 << 6)
3208#define SUBDEV_HP_ (1 << 6)
3209#define SUBDEV_LINE_ (2 << 6)
3210#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
3211#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
3212#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
3213
Takashi Iwai603c4012008-07-30 15:01:44 +02003214static void alc_free_kctls(struct hda_codec *codec);
3215
Takashi Iwai67d634c2009-11-16 15:35:59 +01003216#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003217/* additional beep mixers; the actual parameters are overwritten at build */
Takashi Iwaia9111322011-05-02 11:30:18 +02003218static const struct snd_kcontrol_new alc_beep_mixer[] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003219 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003220 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003221 { } /* end */
3222};
Takashi Iwai67d634c2009-11-16 15:35:59 +01003223#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003224
Linus Torvalds1da177e2005-04-16 15:20:36 -07003225static int alc_build_controls(struct hda_codec *codec)
3226{
3227 struct alc_spec *spec = codec->spec;
Takashi Iwai2f44f842010-06-22 11:12:32 +02003228 struct snd_kcontrol *kctl = NULL;
Takashi Iwaia9111322011-05-02 11:30:18 +02003229 const struct snd_kcontrol_new *knew;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003230 int i, j, err;
3231 unsigned int u;
3232 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003233
3234 for (i = 0; i < spec->num_mixers; i++) {
3235 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
3236 if (err < 0)
3237 return err;
3238 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003239 if (spec->cap_mixer) {
3240 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
3241 if (err < 0)
3242 return err;
3243 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003244 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003245 err = snd_hda_create_spdif_out_ctls(codec,
Stephen Warren74b654c2011-06-01 11:14:18 -06003246 spec->multiout.dig_out_nid,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003247 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003248 if (err < 0)
3249 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003250 if (!spec->no_analog) {
3251 err = snd_hda_create_spdif_share_sw(codec,
3252 &spec->multiout);
3253 if (err < 0)
3254 return err;
3255 spec->multiout.share_spdif = 1;
3256 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003257 }
3258 if (spec->dig_in_nid) {
3259 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
3260 if (err < 0)
3261 return err;
3262 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01003263
Takashi Iwai67d634c2009-11-16 15:35:59 +01003264#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003265 /* create beep controls if needed */
3266 if (spec->beep_amp) {
Takashi Iwaia9111322011-05-02 11:30:18 +02003267 const struct snd_kcontrol_new *knew;
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003268 for (knew = alc_beep_mixer; knew->name; knew++) {
3269 struct snd_kcontrol *kctl;
3270 kctl = snd_ctl_new1(knew, codec);
3271 if (!kctl)
3272 return -ENOMEM;
3273 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01003274 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003275 if (err < 0)
3276 return err;
3277 }
3278 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01003279#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003280
Takashi Iwai2134ea42008-01-10 16:53:55 +01003281 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003282 if (!spec->no_analog &&
3283 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01003284 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01003285 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01003286 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01003287 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01003288 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01003289 if (err < 0)
3290 return err;
3291 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003292 if (!spec->no_analog &&
3293 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003294 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
3295 NULL, alc_slave_sws);
3296 if (err < 0)
3297 return err;
3298 }
3299
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003300 /* assign Capture Source enums to NID */
Takashi Iwaifbe618f2010-06-11 11:24:58 +02003301 if (spec->capsrc_nids || spec->adc_nids) {
3302 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
3303 if (!kctl)
3304 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
3305 for (i = 0; kctl && i < kctl->count; i++) {
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02003306 const hda_nid_t *nids = spec->capsrc_nids;
Takashi Iwaifbe618f2010-06-11 11:24:58 +02003307 if (!nids)
3308 nids = spec->adc_nids;
3309 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
3310 if (err < 0)
3311 return err;
3312 }
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003313 }
3314 if (spec->cap_mixer) {
3315 const char *kname = kctl ? kctl->id.name : NULL;
3316 for (knew = spec->cap_mixer; knew->name; knew++) {
3317 if (kname && strcmp(knew->name, kname) == 0)
3318 continue;
3319 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3320 for (i = 0; kctl && i < kctl->count; i++) {
3321 err = snd_hda_add_nid(codec, kctl, i,
3322 spec->adc_nids[i]);
3323 if (err < 0)
3324 return err;
3325 }
3326 }
3327 }
3328
3329 /* other nid->control mapping */
3330 for (i = 0; i < spec->num_mixers; i++) {
3331 for (knew = spec->mixers[i]; knew->name; knew++) {
3332 if (knew->iface != NID_MAPPING)
3333 continue;
3334 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3335 if (kctl == NULL)
3336 continue;
3337 u = knew->subdevice;
3338 for (j = 0; j < 4; j++, u >>= 8) {
3339 nid = u & 0x3f;
3340 if (nid == 0)
3341 continue;
3342 switch (u & 0xc0) {
3343 case SUBDEV_SPEAKER_:
3344 nid = spec->autocfg.speaker_pins[nid];
3345 break;
3346 case SUBDEV_LINE_:
3347 nid = spec->autocfg.line_out_pins[nid];
3348 break;
3349 case SUBDEV_HP_:
3350 nid = spec->autocfg.hp_pins[nid];
3351 break;
3352 default:
3353 continue;
3354 }
3355 err = snd_hda_add_nid(codec, kctl, 0, nid);
3356 if (err < 0)
3357 return err;
3358 }
3359 u = knew->private_value;
3360 for (j = 0; j < 4; j++, u >>= 8) {
3361 nid = u & 0xff;
3362 if (nid == 0)
3363 continue;
3364 err = snd_hda_add_nid(codec, kctl, 0, nid);
3365 if (err < 0)
3366 return err;
3367 }
3368 }
3369 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01003370
3371 alc_free_kctls(codec); /* no longer needed */
3372
Linus Torvalds1da177e2005-04-16 15:20:36 -07003373 return 0;
3374}
3375
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003376
Linus Torvalds1da177e2005-04-16 15:20:36 -07003377/*
3378 * initialize the codec volumes, etc
3379 */
3380
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003381/*
3382 * generic initialization of ADC, input mixers and output mixers
3383 */
Takashi Iwaia9111322011-05-02 11:30:18 +02003384static const struct hda_verb alc880_volume_init_verbs[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003385 /*
3386 * Unmute ADC0-2 and set the default input to mic-in
3387 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003388 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003389 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003390 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003391 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003392 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003393 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003394
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003395 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3396 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003397 * Note: PASD motherboards uses the Line In 2 as the input for front
3398 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003399 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003400 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003401 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3402 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3403 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3404 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3405 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3406 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3407 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003408
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003409 /*
3410 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003411 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003412 /* set vol=0 to output mixers */
3413 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3414 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3415 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3416 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3417 /* set up input amps for analog loopback */
3418 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003419 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3420 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003421 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3422 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003423 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3424 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003425 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3426 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003427
3428 { }
3429};
3430
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003431/*
3432 * 3-stack pin configuration:
3433 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
3434 */
Takashi Iwaia9111322011-05-02 11:30:18 +02003435static const struct hda_verb alc880_pin_3stack_init_verbs[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003436 /*
3437 * preset connection lists of input pins
3438 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3439 */
3440 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3441 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3442 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3443
3444 /*
3445 * Set pin mode and muting
3446 */
3447 /* set front pin widgets 0x14 for output */
3448 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3449 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3450 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3451 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3452 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3453 /* Mic2 (as headphone out) for HP output */
3454 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3455 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3456 /* Line In pin widget for input */
3457 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3458 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3459 /* Line2 (as front mic) pin widget for input and vref at 80% */
3460 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3461 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3462 /* CD pin widget for input */
3463 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3464
3465 { }
3466};
3467
3468/*
3469 * 5-stack pin configuration:
3470 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
3471 * line-in/side = 0x1a, f-mic = 0x1b
3472 */
Takashi Iwaia9111322011-05-02 11:30:18 +02003473static const struct hda_verb alc880_pin_5stack_init_verbs[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003474 /*
3475 * preset connection lists of input pins
3476 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3477 */
3478 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3479 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
3480
3481 /*
3482 * Set pin mode and muting
3483 */
3484 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02003485 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3486 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3487 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3488 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003489 /* unmute pins for output (no gain on this amp) */
3490 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3491 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3492 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3493 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3494
Linus Torvalds1da177e2005-04-16 15:20:36 -07003495 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003496 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003497 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3498 /* Mic2 (as headphone out) for HP output */
3499 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003500 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003501 /* Line In pin widget for input */
3502 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3503 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3504 /* Line2 (as front mic) pin widget for input and vref at 80% */
3505 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3506 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3507 /* CD pin widget for input */
3508 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003509
3510 { }
3511};
3512
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003513/*
3514 * W810 pin configuration:
3515 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
3516 */
Takashi Iwaia9111322011-05-02 11:30:18 +02003517static const struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003518 /* hphone/speaker input selector: front DAC */
3519 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
3520
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003521 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3522 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3523 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3524 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3525 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3526 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3527
3528 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003529 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003530
Linus Torvalds1da177e2005-04-16 15:20:36 -07003531 { }
3532};
3533
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003534/*
3535 * Z71V pin configuration:
3536 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
3537 */
Takashi Iwaia9111322011-05-02 11:30:18 +02003538static const struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003539 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003540 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02003541 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003542 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003543
Takashi Iwai16ded522005-06-10 19:58:24 +02003544 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003545 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003546 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003547 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003548
3549 { }
3550};
3551
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003552/*
3553 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003554 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
3555 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003556 */
Takashi Iwaia9111322011-05-02 11:30:18 +02003557static const struct hda_verb alc880_pin_6stack_init_verbs[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003558 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3559
Takashi Iwai16ded522005-06-10 19:58:24 +02003560 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003561 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003562 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003563 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003564 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003565 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003566 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003567 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3568
Takashi Iwai16ded522005-06-10 19:58:24 +02003569 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003570 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003571 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003572 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003573 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003574 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003575 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02003576 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003577 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003578
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003579 { }
3580};
Takashi Iwai16ded522005-06-10 19:58:24 +02003581
Kailang Yangccc656c2006-10-17 12:32:26 +02003582/*
3583 * Uniwill pin configuration:
3584 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3585 * line = 0x1a
3586 */
Takashi Iwaia9111322011-05-02 11:30:18 +02003587static const struct hda_verb alc880_uniwill_init_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02003588 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3589
3590 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3591 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3592 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3593 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3594 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3595 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3596 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3597 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3598 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3599 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3600 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3601 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3602 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3603 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3604
3605 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3606 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3607 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3608 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3609 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3610 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3611 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3612 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3613 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3614
3615 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3616 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3617
3618 { }
3619};
3620
3621/*
3622* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02003623* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02003624 */
Takashi Iwaia9111322011-05-02 11:30:18 +02003625static const struct hda_verb alc880_uniwill_p53_init_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02003626 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3627
3628 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3629 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3630 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3631 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3632 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3633 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3634 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3635 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3636 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3637 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3638 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3639 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3640
3641 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3642 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3643 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3644 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3645 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3646 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3647
3648 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3649 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3650
3651 { }
3652};
3653
Takashi Iwaia9111322011-05-02 11:30:18 +02003654static const struct hda_verb alc880_beep_init_verbs[] = {
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003655 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3656 { }
3657};
3658
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003659/* auto-toggle front mic */
Anisse Astiereeb43382010-12-16 12:19:47 +01003660static void alc88x_simple_mic_automute(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003661{
3662 unsigned int present;
3663 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02003664
Wu Fengguang864f92b2009-11-18 12:38:02 +08003665 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003666 bits = present ? HDA_AMP_MUTE : 0;
3667 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003668}
3669
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003670static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003671{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003672 struct alc_spec *spec = codec->spec;
3673
3674 spec->autocfg.hp_pins[0] = 0x14;
3675 spec->autocfg.speaker_pins[0] = 0x15;
3676 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwaid922b512011-04-28 12:18:53 +02003677 spec->automute = 1;
3678 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003679}
3680
3681static void alc880_uniwill_init_hook(struct hda_codec *codec)
3682{
Takashi Iwaid922b512011-04-28 12:18:53 +02003683 alc_hp_automute(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +01003684 alc88x_simple_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02003685}
3686
3687static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3688 unsigned int res)
3689{
3690 /* Looks like the unsol event is incompatible with the standard
3691 * definition. 4bit tag is placed at 28 bit!
3692 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003693 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003694 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +01003695 alc88x_simple_mic_automute(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003696 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003697 default:
Takashi Iwaid922b512011-04-28 12:18:53 +02003698 alc_sku_unsol_event(codec, res);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003699 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003700 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003701}
3702
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003703static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003704{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003705 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003706
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003707 spec->autocfg.hp_pins[0] = 0x14;
3708 spec->autocfg.speaker_pins[0] = 0x15;
Takashi Iwaid922b512011-04-28 12:18:53 +02003709 spec->automute = 1;
3710 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yangccc656c2006-10-17 12:32:26 +02003711}
3712
3713static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3714{
3715 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003716
Kailang Yangccc656c2006-10-17 12:32:26 +02003717 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003718 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3719 present &= HDA_AMP_VOLMASK;
3720 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3721 HDA_AMP_VOLMASK, present);
3722 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3723 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003724}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003725
Kailang Yangccc656c2006-10-17 12:32:26 +02003726static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3727 unsigned int res)
3728{
3729 /* Looks like the unsol event is incompatible with the standard
3730 * definition. 4bit tag is placed at 28 bit!
3731 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003732 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003733 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003734 else
Takashi Iwaid922b512011-04-28 12:18:53 +02003735 alc_sku_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003736}
3737
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003738/*
3739 * F1734 pin configuration:
3740 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3741 */
Takashi Iwaia9111322011-05-02 11:30:18 +02003742static const struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003743 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003744 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3745 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3746 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3747 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3748
3749 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3750 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3751 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3752 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3753
3754 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3755 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003756 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003757 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3758 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3759 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3760 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3761 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3762 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003763
Takashi Iwai937b4162008-02-11 14:52:36 +01003764 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3765 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3766
Takashi Iwai16ded522005-06-10 19:58:24 +02003767 { }
3768};
3769
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003770/*
3771 * ASUS pin configuration:
3772 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3773 */
Takashi Iwaia9111322011-05-02 11:30:18 +02003774static const struct hda_verb alc880_pin_asus_init_verbs[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003775 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3776 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3777 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3778 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3779
3780 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3781 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3782 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3783 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3784 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3785 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3786 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3787 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3788
3789 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3790 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3791 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3792 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3793 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3794 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3795 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3796 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3797 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003798
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003799 { }
3800};
3801
3802/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003803#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3804#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003805#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003806
Kailang Yangdf694da2005-12-05 19:42:22 +01003807/* Clevo m520g init */
Takashi Iwaia9111322011-05-02 11:30:18 +02003808static const struct hda_verb alc880_pin_clevo_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01003809 /* headphone output */
3810 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3811 /* line-out */
3812 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3813 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3814 /* Line-in */
3815 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3816 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3817 /* CD */
3818 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3819 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3820 /* Mic1 (rear panel) */
3821 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3822 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3823 /* Mic2 (front panel) */
3824 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3825 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3826 /* headphone */
3827 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3828 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3829 /* change to EAPD mode */
3830 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3831 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3832
3833 { }
3834};
3835
Takashi Iwaia9111322011-05-02 11:30:18 +02003836static const struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003837 /* change to EAPD mode */
3838 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3839 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3840
Kailang Yangdf694da2005-12-05 19:42:22 +01003841 /* Headphone output */
3842 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3843 /* Front output*/
3844 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3845 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3846
3847 /* Line In pin widget for input */
3848 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3849 /* CD pin widget for input */
3850 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3851 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3852 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3853
3854 /* change to EAPD mode */
3855 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3856 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3857
3858 { }
3859};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003860
3861/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003862 * LG m1 express dual
3863 *
3864 * Pin assignment:
3865 * Rear Line-In/Out (blue): 0x14
3866 * Build-in Mic-In: 0x15
3867 * Speaker-out: 0x17
3868 * HP-Out (green): 0x1b
3869 * Mic-In/Out (red): 0x19
3870 * SPDIF-Out: 0x1e
3871 */
3872
3873/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02003874static const hda_nid_t alc880_lg_dac_nids[3] = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003875 0x05, 0x02, 0x03
3876};
3877
3878/* seems analog CD is not working */
Takashi Iwaia9111322011-05-02 11:30:18 +02003879static const struct hda_input_mux alc880_lg_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003880 .num_items = 3,
3881 .items = {
3882 { "Mic", 0x1 },
3883 { "Line", 0x5 },
3884 { "Internal Mic", 0x6 },
3885 },
3886};
3887
3888/* 2,4,6 channel modes */
Takashi Iwaia9111322011-05-02 11:30:18 +02003889static const struct hda_verb alc880_lg_ch2_init[] = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003890 /* set line-in and mic-in to input */
3891 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3892 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3893 { }
3894};
3895
Takashi Iwaia9111322011-05-02 11:30:18 +02003896static const struct hda_verb alc880_lg_ch4_init[] = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003897 /* set line-in to out and mic-in to input */
3898 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3899 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3900 { }
3901};
3902
Takashi Iwaia9111322011-05-02 11:30:18 +02003903static const struct hda_verb alc880_lg_ch6_init[] = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003904 /* set line-in and mic-in to output */
3905 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3906 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3907 { }
3908};
3909
Takashi Iwaia9111322011-05-02 11:30:18 +02003910static const struct hda_channel_mode alc880_lg_ch_modes[3] = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003911 { 2, alc880_lg_ch2_init },
3912 { 4, alc880_lg_ch4_init },
3913 { 6, alc880_lg_ch6_init },
3914};
3915
Takashi Iwaia9111322011-05-02 11:30:18 +02003916static const struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003917 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3918 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003919 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3920 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3921 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3922 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3923 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3924 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3925 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3926 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3927 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3928 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3929 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3930 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3931 {
3932 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3933 .name = "Channel Mode",
3934 .info = alc_ch_mode_info,
3935 .get = alc_ch_mode_get,
3936 .put = alc_ch_mode_put,
3937 },
3938 { } /* end */
3939};
3940
Takashi Iwaia9111322011-05-02 11:30:18 +02003941static const struct hda_verb alc880_lg_init_verbs[] = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003942 /* set capture source to mic-in */
3943 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3944 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3945 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3946 /* mute all amp mixer inputs */
3947 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003948 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3949 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003950 /* line-in to input */
3951 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3952 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3953 /* built-in mic */
3954 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3955 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3956 /* speaker-out */
3957 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3958 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3959 /* mic-in to input */
3960 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3961 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3962 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3963 /* HP-out */
3964 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3965 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3966 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3967 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003968 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003969 { }
3970};
3971
3972/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003973static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003974{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003975 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003976
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003977 spec->autocfg.hp_pins[0] = 0x1b;
3978 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02003979 spec->automute = 1;
3980 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003981}
3982
3983/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003984 * LG LW20
3985 *
3986 * Pin assignment:
3987 * Speaker-out: 0x14
3988 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003989 * Built-in Mic-In: 0x19
3990 * Line-In: 0x1b
3991 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003992 * SPDIF-Out: 0x1e
3993 */
3994
Takashi Iwaia9111322011-05-02 11:30:18 +02003995static const struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003996 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003997 .items = {
3998 { "Mic", 0x0 },
3999 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02004000 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004001 },
4002};
4003
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004004#define alc880_lg_lw_modes alc880_threestack_modes
4005
Takashi Iwaia9111322011-05-02 11:30:18 +02004006static const struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004007 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4008 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4009 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
4010 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
4011 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4012 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4013 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4014 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4015 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4016 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01004017 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4018 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4019 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
4020 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004021 {
4022 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4023 .name = "Channel Mode",
4024 .info = alc_ch_mode_info,
4025 .get = alc_ch_mode_get,
4026 .put = alc_ch_mode_put,
4027 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004028 { } /* end */
4029};
4030
Takashi Iwaia9111322011-05-02 11:30:18 +02004031static const struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004032 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
4033 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
4034 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
4035
Takashi Iwaid6815182006-03-23 16:06:23 +01004036 /* set capture source to mic-in */
4037 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4038 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4039 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02004040 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01004041 /* speaker-out */
4042 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4043 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4044 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01004045 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4046 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4047 /* mic-in to input */
4048 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4049 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4050 /* built-in mic */
4051 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4052 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4053 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004054 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01004055 { }
4056};
4057
4058/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004059static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01004060{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004061 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01004062
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004063 spec->autocfg.hp_pins[0] = 0x1b;
4064 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +02004065 spec->automute = 1;
4066 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwaid6815182006-03-23 16:06:23 +01004067}
4068
Takashi Iwaia9111322011-05-02 11:30:18 +02004069static const struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004070 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4071 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
4072 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4073 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4074 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4075 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
4076 { } /* end */
4077};
4078
Takashi Iwaia9111322011-05-02 11:30:18 +02004079static const struct hda_input_mux alc880_medion_rim_capture_source = {
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004080 .num_items = 2,
4081 .items = {
4082 { "Mic", 0x0 },
4083 { "Internal Mic", 0x1 },
4084 },
4085};
4086
Takashi Iwaia9111322011-05-02 11:30:18 +02004087static const struct hda_verb alc880_medion_rim_init_verbs[] = {
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004088 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
4089
4090 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4091 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4092
4093 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4094 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4095 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4096 /* Mic2 (as headphone out) for HP output */
4097 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4098 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4099 /* Internal Speaker */
4100 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4101 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4102
4103 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
4104 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
4105
4106 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4107 { }
4108};
4109
4110/* toggle speaker-output according to the hp-jack state */
4111static void alc880_medion_rim_automute(struct hda_codec *codec)
4112{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004113 struct alc_spec *spec = codec->spec;
Takashi Iwaid922b512011-04-28 12:18:53 +02004114 alc_hp_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004115 /* toggle EAPD */
4116 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004117 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
4118 else
4119 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
4120}
4121
4122static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
4123 unsigned int res)
4124{
4125 /* Looks like the unsol event is incompatible with the standard
4126 * definition. 4bit tag is placed at 28 bit!
4127 */
4128 if ((res >> 28) == ALC880_HP_EVENT)
4129 alc880_medion_rim_automute(codec);
4130}
4131
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004132static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004133{
4134 struct alc_spec *spec = codec->spec;
4135
4136 spec->autocfg.hp_pins[0] = 0x14;
4137 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaid922b512011-04-28 12:18:53 +02004138 spec->automute = 1;
4139 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004140}
4141
Takashi Iwaicb53c622007-08-10 17:21:45 +02004142#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaia9111322011-05-02 11:30:18 +02004143static const struct hda_amp_list alc880_loopbacks[] = {
Takashi Iwaicb53c622007-08-10 17:21:45 +02004144 { 0x0b, HDA_INPUT, 0 },
4145 { 0x0b, HDA_INPUT, 1 },
4146 { 0x0b, HDA_INPUT, 2 },
4147 { 0x0b, HDA_INPUT, 3 },
4148 { 0x0b, HDA_INPUT, 4 },
4149 { } /* end */
4150};
4151
Takashi Iwaia9111322011-05-02 11:30:18 +02004152static const struct hda_amp_list alc880_lg_loopbacks[] = {
Takashi Iwaicb53c622007-08-10 17:21:45 +02004153 { 0x0b, HDA_INPUT, 1 },
4154 { 0x0b, HDA_INPUT, 6 },
4155 { 0x0b, HDA_INPUT, 7 },
4156 { } /* end */
4157};
4158#endif
4159
Takashi Iwaid6815182006-03-23 16:06:23 +01004160/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004161 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004162 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004163
Takashi Iwai584c0c42011-03-10 12:51:11 +01004164static void alc_init_special_input_src(struct hda_codec *codec);
4165
Linus Torvalds1da177e2005-04-16 15:20:36 -07004166static int alc_init(struct hda_codec *codec)
4167{
4168 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004169 unsigned int i;
4170
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02004171 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004172 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02004173
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004174 for (i = 0; i < spec->num_init_verbs; i++)
4175 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwai584c0c42011-03-10 12:51:11 +01004176 alc_init_special_input_src(codec);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004177
4178 if (spec->init_hook)
4179 spec->init_hook(codec);
4180
Takashi Iwai58701122011-01-13 15:41:45 +01004181 alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT);
4182
Takashi Iwai9e5341b2010-09-21 09:57:06 +02004183 hda_call_check_power_status(codec, 0x01);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004184 return 0;
4185}
4186
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004187static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
4188{
4189 struct alc_spec *spec = codec->spec;
4190
4191 if (spec->unsol_event)
4192 spec->unsol_event(codec, res);
4193}
4194
Takashi Iwaicb53c622007-08-10 17:21:45 +02004195#ifdef CONFIG_SND_HDA_POWER_SAVE
4196static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
4197{
4198 struct alc_spec *spec = codec->spec;
4199 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
4200}
4201#endif
4202
Linus Torvalds1da177e2005-04-16 15:20:36 -07004203/*
4204 * Analog playback callbacks
4205 */
4206static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
4207 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004208 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004209{
4210 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01004211 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
4212 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004213}
4214
4215static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
4216 struct hda_codec *codec,
4217 unsigned int stream_tag,
4218 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004219 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004220{
4221 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004222 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
4223 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004224}
4225
4226static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
4227 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004228 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004229{
4230 struct alc_spec *spec = codec->spec;
4231 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
4232}
4233
4234/*
4235 * Digital out
4236 */
4237static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
4238 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004239 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004240{
4241 struct alc_spec *spec = codec->spec;
4242 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
4243}
4244
Takashi Iwai6b97eb42007-04-05 14:51:48 +02004245static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
4246 struct hda_codec *codec,
4247 unsigned int stream_tag,
4248 unsigned int format,
4249 struct snd_pcm_substream *substream)
4250{
4251 struct alc_spec *spec = codec->spec;
4252 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
4253 stream_tag, format, substream);
4254}
4255
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01004256static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
4257 struct hda_codec *codec,
4258 struct snd_pcm_substream *substream)
4259{
4260 struct alc_spec *spec = codec->spec;
4261 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
4262}
4263
Linus Torvalds1da177e2005-04-16 15:20:36 -07004264static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
4265 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004266 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004267{
4268 struct alc_spec *spec = codec->spec;
4269 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
4270}
4271
4272/*
4273 * Analog capture
4274 */
Takashi Iwai63300792008-01-24 15:31:36 +01004275static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004276 struct hda_codec *codec,
4277 unsigned int stream_tag,
4278 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004279 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004280{
4281 struct alc_spec *spec = codec->spec;
4282
Takashi Iwai63300792008-01-24 15:31:36 +01004283 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07004284 stream_tag, 0, format);
4285 return 0;
4286}
4287
Takashi Iwai63300792008-01-24 15:31:36 +01004288static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004289 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004290 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004291{
4292 struct alc_spec *spec = codec->spec;
4293
Takashi Iwai888afa12008-03-18 09:57:50 +01004294 snd_hda_codec_cleanup_stream(codec,
4295 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004296 return 0;
4297}
4298
Takashi Iwai840b64c2010-07-13 22:49:01 +02004299/* analog capture with dynamic dual-adc changes */
4300static int dualmic_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
4301 struct hda_codec *codec,
4302 unsigned int stream_tag,
4303 unsigned int format,
4304 struct snd_pcm_substream *substream)
4305{
4306 struct alc_spec *spec = codec->spec;
4307 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
4308 spec->cur_adc_stream_tag = stream_tag;
4309 spec->cur_adc_format = format;
4310 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
4311 return 0;
4312}
4313
4314static int dualmic_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
4315 struct hda_codec *codec,
4316 struct snd_pcm_substream *substream)
4317{
4318 struct alc_spec *spec = codec->spec;
4319 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
4320 spec->cur_adc = 0;
4321 return 0;
4322}
4323
Takashi Iwaia9111322011-05-02 11:30:18 +02004324static const struct hda_pcm_stream dualmic_pcm_analog_capture = {
Takashi Iwai840b64c2010-07-13 22:49:01 +02004325 .substreams = 1,
4326 .channels_min = 2,
4327 .channels_max = 2,
4328 .nid = 0, /* fill later */
4329 .ops = {
4330 .prepare = dualmic_capture_pcm_prepare,
4331 .cleanup = dualmic_capture_pcm_cleanup
4332 },
4333};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004334
4335/*
4336 */
Takashi Iwaia9111322011-05-02 11:30:18 +02004337static const struct hda_pcm_stream alc880_pcm_analog_playback = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004338 .substreams = 1,
4339 .channels_min = 2,
4340 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004341 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004342 .ops = {
4343 .open = alc880_playback_pcm_open,
4344 .prepare = alc880_playback_pcm_prepare,
4345 .cleanup = alc880_playback_pcm_cleanup
4346 },
4347};
4348
Takashi Iwaia9111322011-05-02 11:30:18 +02004349static const struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01004350 .substreams = 1,
4351 .channels_min = 2,
4352 .channels_max = 2,
4353 /* NID is set in alc_build_pcms */
4354};
4355
Takashi Iwaia9111322011-05-02 11:30:18 +02004356static const struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
Takashi Iwai63300792008-01-24 15:31:36 +01004357 .substreams = 1,
4358 .channels_min = 2,
4359 .channels_max = 2,
4360 /* NID is set in alc_build_pcms */
4361};
4362
Takashi Iwaia9111322011-05-02 11:30:18 +02004363static const struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01004364 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004365 .channels_min = 2,
4366 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004367 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004368 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01004369 .prepare = alc880_alt_capture_pcm_prepare,
4370 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004371 },
4372};
4373
Takashi Iwaia9111322011-05-02 11:30:18 +02004374static const struct hda_pcm_stream alc880_pcm_digital_playback = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004375 .substreams = 1,
4376 .channels_min = 2,
4377 .channels_max = 2,
4378 /* NID is set in alc_build_pcms */
4379 .ops = {
4380 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02004381 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01004382 .prepare = alc880_dig_playback_pcm_prepare,
4383 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004384 },
4385};
4386
Takashi Iwaia9111322011-05-02 11:30:18 +02004387static const struct hda_pcm_stream alc880_pcm_digital_capture = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004388 .substreams = 1,
4389 .channels_min = 2,
4390 .channels_max = 2,
4391 /* NID is set in alc_build_pcms */
4392};
4393
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004394/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwaia9111322011-05-02 11:30:18 +02004395static const struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004396 .substreams = 0,
4397 .channels_min = 0,
4398 .channels_max = 0,
4399};
4400
Linus Torvalds1da177e2005-04-16 15:20:36 -07004401static int alc_build_pcms(struct hda_codec *codec)
4402{
4403 struct alc_spec *spec = codec->spec;
4404 struct hda_pcm *info = spec->pcm_rec;
4405 int i;
4406
4407 codec->num_pcms = 1;
4408 codec->pcm_info = info;
4409
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004410 if (spec->no_analog)
4411 goto skip_analog;
4412
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004413 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
4414 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004415 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01004416
Takashi Iwai4a471b72005-12-07 13:56:29 +01004417 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004418 if (snd_BUG_ON(!spec->multiout.dac_nids))
4419 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004420 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
4421 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
4422 }
4423 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004424 if (snd_BUG_ON(!spec->adc_nids))
4425 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004426 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
4427 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
4428 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004429
Takashi Iwai4a471b72005-12-07 13:56:29 +01004430 if (spec->channel_mode) {
4431 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
4432 for (i = 0; i < spec->num_channel_mode; i++) {
4433 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
4434 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
4435 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004436 }
4437 }
4438
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004439 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02004440 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004441 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004442 snprintf(spec->stream_name_digital,
4443 sizeof(spec->stream_name_digital),
4444 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02004445 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08004446 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004447 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004448 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01004449 if (spec->dig_out_type)
4450 info->pcm_type = spec->dig_out_type;
4451 else
4452 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004453 if (spec->multiout.dig_out_nid &&
4454 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004455 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
4456 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
4457 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004458 if (spec->dig_in_nid &&
4459 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004460 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
4461 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
4462 }
Takashi Iwai963f8032008-08-11 10:04:40 +02004463 /* FIXME: do we need this for all Realtek codec models? */
4464 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004465 }
4466
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004467 if (spec->no_analog)
4468 return 0;
4469
Takashi Iwaie08a0072006-09-07 17:52:14 +02004470 /* If the use of more than one ADC is requested for the current
4471 * model, configure a second analog capture-only PCM.
4472 */
4473 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01004474 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
4475 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02004476 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004477 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004478 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01004479 if (spec->alt_dac_nid) {
4480 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4481 *spec->stream_analog_alt_playback;
4482 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
4483 spec->alt_dac_nid;
4484 } else {
4485 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4486 alc_pcm_null_stream;
4487 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
4488 }
Raymond Yauce85c9a2011-05-03 13:33:53 +08004489 if (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture) {
Takashi Iwai63300792008-01-24 15:31:36 +01004490 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4491 *spec->stream_analog_alt_capture;
4492 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
4493 spec->adc_nids[1];
4494 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
4495 spec->num_adc_nids - 1;
4496 } else {
4497 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4498 alc_pcm_null_stream;
4499 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004500 }
4501 }
4502
Linus Torvalds1da177e2005-04-16 15:20:36 -07004503 return 0;
4504}
4505
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004506static inline void alc_shutup(struct hda_codec *codec)
4507{
Takashi Iwai1c7161532011-04-07 10:37:16 +02004508 struct alc_spec *spec = codec->spec;
4509
4510 if (spec && spec->shutup)
4511 spec->shutup(codec);
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004512 snd_hda_shutup_pins(codec);
4513}
4514
Takashi Iwai603c4012008-07-30 15:01:44 +02004515static void alc_free_kctls(struct hda_codec *codec)
4516{
4517 struct alc_spec *spec = codec->spec;
4518
4519 if (spec->kctls.list) {
4520 struct snd_kcontrol_new *kctl = spec->kctls.list;
4521 int i;
4522 for (i = 0; i < spec->kctls.used; i++)
4523 kfree(kctl[i].name);
4524 }
4525 snd_array_free(&spec->kctls);
4526}
4527
Linus Torvalds1da177e2005-04-16 15:20:36 -07004528static void alc_free(struct hda_codec *codec)
4529{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004530 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004531
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004532 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004533 return;
4534
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004535 alc_shutup(codec);
Takashi Iwaicd372fb2011-03-03 14:40:14 +01004536 snd_hda_input_jack_free(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02004537 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004538 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004539 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004540}
4541
Hector Martinf5de24b2009-12-20 22:51:31 +01004542#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05004543static void alc_power_eapd(struct hda_codec *codec)
4544{
Takashi Iwai691f1fc2011-04-07 10:31:43 +02004545 alc_auto_setup_eapd(codec, false);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004546}
4547
Hector Martinf5de24b2009-12-20 22:51:31 +01004548static int alc_suspend(struct hda_codec *codec, pm_message_t state)
4549{
4550 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004551 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004552 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05004553 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004554 return 0;
4555}
4556#endif
4557
Takashi Iwaie044c392008-10-27 16:56:24 +01004558#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01004559static int alc_resume(struct hda_codec *codec)
4560{
Takashi Iwai1c7161532011-04-07 10:37:16 +02004561 msleep(150); /* to avoid pop noise */
Takashi Iwaie044c392008-10-27 16:56:24 +01004562 codec->patch_ops.init(codec);
4563 snd_hda_codec_resume_amp(codec);
4564 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +02004565 hda_call_check_power_status(codec, 0x01);
Takashi Iwaie044c392008-10-27 16:56:24 +01004566 return 0;
4567}
Takashi Iwaie044c392008-10-27 16:56:24 +01004568#endif
4569
Linus Torvalds1da177e2005-04-16 15:20:36 -07004570/*
4571 */
Takashi Iwaia9111322011-05-02 11:30:18 +02004572static const struct hda_codec_ops alc_patch_ops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004573 .build_controls = alc_build_controls,
4574 .build_pcms = alc_build_pcms,
4575 .init = alc_init,
4576 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004577 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01004578#ifdef SND_HDA_NEEDS_RESUME
4579 .resume = alc_resume,
4580#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02004581#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01004582 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004583 .check_power_status = alc_check_power_status,
4584#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05004585 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004586};
4587
Kailang Yangc027ddc2010-03-19 11:33:06 +01004588/* replace the codec chip_name with the given string */
4589static int alc_codec_rename(struct hda_codec *codec, const char *name)
4590{
4591 kfree(codec->chip_name);
4592 codec->chip_name = kstrdup(name, GFP_KERNEL);
4593 if (!codec->chip_name) {
4594 alc_free(codec);
4595 return -ENOMEM;
4596 }
4597 return 0;
4598}
4599
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004600/*
4601 * Test configuration for debugging
4602 *
4603 * Almost all inputs/outputs are enabled. I/O pins can be configured via
4604 * enum controls.
4605 */
4606#ifdef CONFIG_SND_DEBUG
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02004607static const hda_nid_t alc880_test_dac_nids[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004608 0x02, 0x03, 0x04, 0x05
4609};
4610
Takashi Iwaia9111322011-05-02 11:30:18 +02004611static const struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004612 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004613 .items = {
4614 { "In-1", 0x0 },
4615 { "In-2", 0x1 },
4616 { "In-3", 0x2 },
4617 { "In-4", 0x3 },
4618 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004619 { "Front", 0x5 },
4620 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004621 },
4622};
4623
Takashi Iwaia9111322011-05-02 11:30:18 +02004624static const struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004625 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004626 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004627 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004628 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004629};
4630
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004631static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
4632 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004633{
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02004634 static const char * const texts[] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004635 "N/A", "Line Out", "HP Out",
4636 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
4637 };
4638 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4639 uinfo->count = 1;
4640 uinfo->value.enumerated.items = 8;
4641 if (uinfo->value.enumerated.item >= 8)
4642 uinfo->value.enumerated.item = 7;
4643 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4644 return 0;
4645}
4646
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004647static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
4648 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004649{
4650 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4651 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4652 unsigned int pin_ctl, item = 0;
4653
4654 pin_ctl = snd_hda_codec_read(codec, nid, 0,
4655 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4656 if (pin_ctl & AC_PINCTL_OUT_EN) {
4657 if (pin_ctl & AC_PINCTL_HP_EN)
4658 item = 2;
4659 else
4660 item = 1;
4661 } else if (pin_ctl & AC_PINCTL_IN_EN) {
4662 switch (pin_ctl & AC_PINCTL_VREFEN) {
4663 case AC_PINCTL_VREF_HIZ: item = 3; break;
4664 case AC_PINCTL_VREF_50: item = 4; break;
4665 case AC_PINCTL_VREF_GRD: item = 5; break;
4666 case AC_PINCTL_VREF_80: item = 6; break;
4667 case AC_PINCTL_VREF_100: item = 7; break;
4668 }
4669 }
4670 ucontrol->value.enumerated.item[0] = item;
4671 return 0;
4672}
4673
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004674static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
4675 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004676{
4677 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4678 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02004679 static const unsigned int ctls[] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004680 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
4681 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
4682 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
4683 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
4684 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
4685 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
4686 };
4687 unsigned int old_ctl, new_ctl;
4688
4689 old_ctl = snd_hda_codec_read(codec, nid, 0,
4690 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4691 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
4692 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004693 int val;
4694 snd_hda_codec_write_cache(codec, nid, 0,
4695 AC_VERB_SET_PIN_WIDGET_CONTROL,
4696 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02004697 val = ucontrol->value.enumerated.item[0] >= 3 ?
4698 HDA_AMP_MUTE : 0;
4699 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
4700 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004701 return 1;
4702 }
4703 return 0;
4704}
4705
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004706static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
4707 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004708{
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02004709 static const char * const texts[] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004710 "Front", "Surround", "CLFE", "Side"
4711 };
4712 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4713 uinfo->count = 1;
4714 uinfo->value.enumerated.items = 4;
4715 if (uinfo->value.enumerated.item >= 4)
4716 uinfo->value.enumerated.item = 3;
4717 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4718 return 0;
4719}
4720
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004721static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
4722 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004723{
4724 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4725 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4726 unsigned int sel;
4727
4728 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4729 ucontrol->value.enumerated.item[0] = sel & 3;
4730 return 0;
4731}
4732
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004733static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4734 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004735{
4736 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4737 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4738 unsigned int sel;
4739
4740 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4741 if (ucontrol->value.enumerated.item[0] != sel) {
4742 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004743 snd_hda_codec_write_cache(codec, nid, 0,
4744 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004745 return 1;
4746 }
4747 return 0;
4748}
4749
4750#define PIN_CTL_TEST(xname,nid) { \
4751 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4752 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004753 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004754 .info = alc_test_pin_ctl_info, \
4755 .get = alc_test_pin_ctl_get, \
4756 .put = alc_test_pin_ctl_put, \
4757 .private_value = nid \
4758 }
4759
4760#define PIN_SRC_TEST(xname,nid) { \
4761 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4762 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004763 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004764 .info = alc_test_pin_src_info, \
4765 .get = alc_test_pin_src_get, \
4766 .put = alc_test_pin_src_put, \
4767 .private_value = nid \
4768 }
4769
Takashi Iwaia9111322011-05-02 11:30:18 +02004770static const struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004771 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4772 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4773 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4774 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004775 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4776 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4777 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4778 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004779 PIN_CTL_TEST("Front Pin Mode", 0x14),
4780 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4781 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4782 PIN_CTL_TEST("Side Pin Mode", 0x17),
4783 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4784 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4785 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4786 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4787 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4788 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4789 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4790 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4791 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4792 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4793 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4794 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4795 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4796 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4797 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4798 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4799 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4800 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004801 {
4802 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4803 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004804 .info = alc_ch_mode_info,
4805 .get = alc_ch_mode_get,
4806 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004807 },
4808 { } /* end */
4809};
4810
Takashi Iwaia9111322011-05-02 11:30:18 +02004811static const struct hda_verb alc880_test_init_verbs[] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004812 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004813 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4814 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4815 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4816 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4817 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4818 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4819 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4820 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004821 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004822 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4823 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4824 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4825 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004826 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004827 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4828 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4829 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4830 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004831 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004832 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4833 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4834 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4835 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004836 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004837 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4838 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004839 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4840 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4841 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004842 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004843 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4844 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4845 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4846 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004847 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004848 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004849 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004850 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004851 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004852 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004853 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004854 /* Analog input/passthru */
4855 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4856 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4857 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4858 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4859 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004860 { }
4861};
4862#endif
4863
Linus Torvalds1da177e2005-04-16 15:20:36 -07004864/*
4865 */
4866
Takashi Iwaiea734962011-01-17 11:29:34 +01004867static const char * const alc880_models[ALC880_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004868 [ALC880_3ST] = "3stack",
4869 [ALC880_TCL_S700] = "tcl",
4870 [ALC880_3ST_DIG] = "3stack-digout",
4871 [ALC880_CLEVO] = "clevo",
4872 [ALC880_5ST] = "5stack",
4873 [ALC880_5ST_DIG] = "5stack-digout",
4874 [ALC880_W810] = "w810",
4875 [ALC880_Z71V] = "z71v",
4876 [ALC880_6ST] = "6stack",
4877 [ALC880_6ST_DIG] = "6stack-digout",
4878 [ALC880_ASUS] = "asus",
4879 [ALC880_ASUS_W1V] = "asus-w1v",
4880 [ALC880_ASUS_DIG] = "asus-dig",
4881 [ALC880_ASUS_DIG2] = "asus-dig2",
4882 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004883 [ALC880_UNIWILL_P53] = "uniwill-p53",
4884 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004885 [ALC880_F1734] = "F1734",
4886 [ALC880_LG] = "lg",
4887 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004888 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004889#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004890 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004891#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004892 [ALC880_AUTO] = "auto",
4893};
4894
Takashi Iwaia9111322011-05-02 11:30:18 +02004895static const struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004896 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004897 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4898 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4899 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4900 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4901 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4902 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4903 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4904 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004905 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004906 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4907 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4908 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4909 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4910 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4911 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4912 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4913 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4914 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4915 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004916 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004917 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4918 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4919 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004920 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004921 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004922 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4923 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004924 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4925 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004926 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4927 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4928 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4929 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004930 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4931 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004932 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004933 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004934 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Justin P. Mattocka2e2bc22011-02-24 22:16:02 -08004935 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004936 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4937 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004938 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004939 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004940 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004941 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004942 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004943 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Daniel T Chen33535412010-04-22 07:15:26 -04004944 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004945 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004946 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004947 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
Daniel T Chen77c4d5c2010-12-02 22:45:45 -05004948 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004949 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004950 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004951 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4952 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4953 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4954 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004955 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4956 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004957 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004958 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004959 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4960 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004961 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4962 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4963 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004964 /* default Intel */
4965 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004966 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4967 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004968 {}
4969};
4970
Takashi Iwai16ded522005-06-10 19:58:24 +02004971/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004972 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004973 */
Takashi Iwaia9111322011-05-02 11:30:18 +02004974static const struct alc_config_preset alc880_presets[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02004975 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004976 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004977 .init_verbs = { alc880_volume_init_verbs,
4978 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004979 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004980 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004981 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4982 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004983 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004984 .input_mux = &alc880_capture_source,
4985 },
4986 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004987 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004988 .init_verbs = { alc880_volume_init_verbs,
4989 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004990 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004991 .dac_nids = alc880_dac_nids,
4992 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004993 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4994 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004995 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004996 .input_mux = &alc880_capture_source,
4997 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004998 [ALC880_TCL_S700] = {
4999 .mixers = { alc880_tcl_s700_mixer },
5000 .init_verbs = { alc880_volume_init_verbs,
5001 alc880_pin_tcl_S700_init_verbs,
5002 alc880_gpio2_init_verbs },
5003 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
5004 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005005 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
5006 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01005007 .hp_nid = 0x03,
5008 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
5009 .channel_mode = alc880_2_jack_modes,
5010 .input_mux = &alc880_capture_source,
5011 },
Takashi Iwai16ded522005-06-10 19:58:24 +02005012 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005013 .mixers = { alc880_three_stack_mixer,
5014 alc880_five_stack_mixer},
5015 .init_verbs = { alc880_volume_init_verbs,
5016 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02005017 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
5018 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02005019 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
5020 .channel_mode = alc880_fivestack_modes,
5021 .input_mux = &alc880_capture_source,
5022 },
5023 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005024 .mixers = { alc880_three_stack_mixer,
5025 alc880_five_stack_mixer },
5026 .init_verbs = { alc880_volume_init_verbs,
5027 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02005028 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
5029 .dac_nids = alc880_dac_nids,
5030 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02005031 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
5032 .channel_mode = alc880_fivestack_modes,
5033 .input_mux = &alc880_capture_source,
5034 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02005035 [ALC880_6ST] = {
5036 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005037 .init_verbs = { alc880_volume_init_verbs,
5038 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02005039 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
5040 .dac_nids = alc880_6st_dac_nids,
5041 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
5042 .channel_mode = alc880_sixstack_modes,
5043 .input_mux = &alc880_6stack_capture_source,
5044 },
Takashi Iwai16ded522005-06-10 19:58:24 +02005045 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005046 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005047 .init_verbs = { alc880_volume_init_verbs,
5048 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02005049 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
5050 .dac_nids = alc880_6st_dac_nids,
5051 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02005052 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
5053 .channel_mode = alc880_sixstack_modes,
5054 .input_mux = &alc880_6stack_capture_source,
5055 },
5056 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005057 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005058 .init_verbs = { alc880_volume_init_verbs,
5059 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02005060 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02005061 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
5062 .dac_nids = alc880_w810_dac_nids,
5063 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02005064 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
5065 .channel_mode = alc880_w810_modes,
5066 .input_mux = &alc880_capture_source,
5067 },
5068 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005069 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005070 .init_verbs = { alc880_volume_init_verbs,
5071 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02005072 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
5073 .dac_nids = alc880_z71v_dac_nids,
5074 .dig_out_nid = ALC880_DIGOUT_NID,
5075 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005076 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
5077 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02005078 .input_mux = &alc880_capture_source,
5079 },
5080 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005081 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005082 .init_verbs = { alc880_volume_init_verbs,
5083 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005084 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
5085 .dac_nids = alc880_f1734_dac_nids,
5086 .hp_nid = 0x02,
5087 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
5088 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01005089 .input_mux = &alc880_f1734_capture_source,
5090 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02005091 .setup = alc880_uniwill_p53_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +02005092 .init_hook = alc_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02005093 },
5094 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005095 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005096 .init_verbs = { alc880_volume_init_verbs,
5097 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005098 alc880_gpio1_init_verbs },
5099 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
5100 .dac_nids = alc880_asus_dac_nids,
5101 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
5102 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005103 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02005104 .input_mux = &alc880_capture_source,
5105 },
5106 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005107 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005108 .init_verbs = { alc880_volume_init_verbs,
5109 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005110 alc880_gpio1_init_verbs },
5111 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
5112 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02005113 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005114 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
5115 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005116 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02005117 .input_mux = &alc880_capture_source,
5118 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005119 [ALC880_ASUS_DIG2] = {
5120 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005121 .init_verbs = { alc880_volume_init_verbs,
5122 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01005123 alc880_gpio2_init_verbs }, /* use GPIO2 */
5124 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
5125 .dac_nids = alc880_asus_dac_nids,
5126 .dig_out_nid = ALC880_DIGOUT_NID,
5127 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
5128 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005129 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01005130 .input_mux = &alc880_capture_source,
5131 },
Takashi Iwai16ded522005-06-10 19:58:24 +02005132 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005133 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005134 .init_verbs = { alc880_volume_init_verbs,
5135 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005136 alc880_gpio1_init_verbs },
5137 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
5138 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02005139 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005140 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
5141 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005142 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02005143 .input_mux = &alc880_capture_source,
5144 },
5145 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005146 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02005147 .init_verbs = { alc880_volume_init_verbs,
5148 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005149 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
5150 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02005151 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005152 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
5153 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005154 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02005155 .input_mux = &alc880_capture_source,
5156 },
Kailang Yangccc656c2006-10-17 12:32:26 +02005157 [ALC880_UNIWILL] = {
5158 .mixers = { alc880_uniwill_mixer },
5159 .init_verbs = { alc880_volume_init_verbs,
5160 alc880_uniwill_init_verbs },
5161 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
5162 .dac_nids = alc880_asus_dac_nids,
5163 .dig_out_nid = ALC880_DIGOUT_NID,
5164 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5165 .channel_mode = alc880_threestack_modes,
5166 .need_dac_fix = 1,
5167 .input_mux = &alc880_capture_source,
5168 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02005169 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02005170 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02005171 },
5172 [ALC880_UNIWILL_P53] = {
5173 .mixers = { alc880_uniwill_p53_mixer },
5174 .init_verbs = { alc880_volume_init_verbs,
5175 alc880_uniwill_p53_init_verbs },
5176 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
5177 .dac_nids = alc880_asus_dac_nids,
5178 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01005179 .channel_mode = alc880_threestack_modes,
5180 .input_mux = &alc880_capture_source,
5181 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02005182 .setup = alc880_uniwill_p53_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +02005183 .init_hook = alc_hp_automute,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01005184 },
5185 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005186 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01005187 .init_verbs = { alc880_volume_init_verbs,
5188 alc880_uniwill_p53_init_verbs,
5189 alc880_beep_init_verbs },
5190 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
5191 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02005192 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01005193 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
5194 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02005195 .input_mux = &alc880_capture_source,
5196 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02005197 .setup = alc880_uniwill_p53_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +02005198 .init_hook = alc_hp_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02005199 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005200 [ALC880_CLEVO] = {
5201 .mixers = { alc880_three_stack_mixer },
5202 .init_verbs = { alc880_volume_init_verbs,
5203 alc880_pin_clevo_init_verbs },
5204 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
5205 .dac_nids = alc880_dac_nids,
5206 .hp_nid = 0x03,
5207 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5208 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005209 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01005210 .input_mux = &alc880_capture_source,
5211 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005212 [ALC880_LG] = {
5213 .mixers = { alc880_lg_mixer },
5214 .init_verbs = { alc880_volume_init_verbs,
5215 alc880_lg_init_verbs },
5216 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
5217 .dac_nids = alc880_lg_dac_nids,
5218 .dig_out_nid = ALC880_DIGOUT_NID,
5219 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
5220 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005221 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005222 .input_mux = &alc880_lg_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +02005223 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02005224 .setup = alc880_lg_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +02005225 .init_hook = alc_hp_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02005226#ifdef CONFIG_SND_HDA_POWER_SAVE
5227 .loopbacks = alc880_lg_loopbacks,
5228#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005229 },
Takashi Iwaid6815182006-03-23 16:06:23 +01005230 [ALC880_LG_LW] = {
5231 .mixers = { alc880_lg_lw_mixer },
5232 .init_verbs = { alc880_volume_init_verbs,
5233 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02005234 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01005235 .dac_nids = alc880_dac_nids,
5236 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02005237 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
5238 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01005239 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +02005240 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02005241 .setup = alc880_lg_lw_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +02005242 .init_hook = alc_hp_automute,
Takashi Iwaid6815182006-03-23 16:06:23 +01005243 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02005244 [ALC880_MEDION_RIM] = {
5245 .mixers = { alc880_medion_rim_mixer },
5246 .init_verbs = { alc880_volume_init_verbs,
5247 alc880_medion_rim_init_verbs,
5248 alc_gpio2_init_verbs },
5249 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
5250 .dac_nids = alc880_dac_nids,
5251 .dig_out_nid = ALC880_DIGOUT_NID,
5252 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
5253 .channel_mode = alc880_2_jack_modes,
5254 .input_mux = &alc880_medion_rim_capture_source,
5255 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02005256 .setup = alc880_medion_rim_setup,
5257 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02005258 },
Takashi Iwai16ded522005-06-10 19:58:24 +02005259#ifdef CONFIG_SND_DEBUG
5260 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005261 .mixers = { alc880_test_mixer },
5262 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02005263 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
5264 .dac_nids = alc880_test_dac_nids,
5265 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02005266 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
5267 .channel_mode = alc880_test_modes,
5268 .input_mux = &alc880_test_capture_source,
5269 },
5270#endif
5271};
5272
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005273/*
5274 * Automatic parse of I/O pins from the BIOS configuration
5275 */
5276
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005277enum {
5278 ALC_CTL_WIDGET_VOL,
5279 ALC_CTL_WIDGET_MUTE,
5280 ALC_CTL_BIND_MUTE,
5281};
Takashi Iwaia9111322011-05-02 11:30:18 +02005282static const struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005283 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
5284 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01005285 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005286};
5287
Takashi Iwaice764ab2011-04-27 16:35:23 +02005288static struct snd_kcontrol_new *alc_kcontrol_new(struct alc_spec *spec)
5289{
5290 snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32);
5291 return snd_array_new(&spec->kctls);
5292}
5293
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005294/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005295static int add_control(struct alc_spec *spec, int type, const char *name,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005296 int cidx, unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005297{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005298 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005299
Takashi Iwaice764ab2011-04-27 16:35:23 +02005300 knew = alc_kcontrol_new(spec);
Takashi Iwai603c4012008-07-30 15:01:44 +02005301 if (!knew)
5302 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005303 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07005304 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005305 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005306 return -ENOMEM;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005307 knew->index = cidx;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01005308 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01005309 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005310 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005311 return 0;
5312}
5313
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005314static int add_control_with_pfx(struct alc_spec *spec, int type,
5315 const char *pfx, const char *dir,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005316 const char *sfx, int cidx, unsigned long val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005317{
5318 char name[32];
5319 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005320 return add_control(spec, type, name, cidx, val);
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005321}
5322
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005323#define add_pb_vol_ctrl(spec, type, pfx, val) \
5324 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
5325#define add_pb_sw_ctrl(spec, type, pfx, val) \
5326 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
5327#define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
5328 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
5329#define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
5330 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005331
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005332#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
5333#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
5334#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
5335#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005336#define alc880_idx_to_dac(nid) ((nid) + 0x02)
5337#define alc880_dac_to_idx(nid) ((nid) - 0x02)
5338#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
5339#define alc880_idx_to_selector(nid) ((nid) + 0x10)
5340#define ALC880_PIN_CD_NID 0x1c
5341
Takashi Iwai6843ca12011-06-24 11:03:58 +02005342static const char *alc_get_line_out_pfx(struct alc_spec *spec, int ch,
5343 bool can_be_master, int *index)
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005344{
Takashi Iwaice764ab2011-04-27 16:35:23 +02005345 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai6843ca12011-06-24 11:03:58 +02005346 static const char * const chname[4] = {
5347 "Front", "Surround", NULL /*CLFE*/, "Side"
5348 };
Takashi Iwaice764ab2011-04-27 16:35:23 +02005349
Takashi Iwai6843ca12011-06-24 11:03:58 +02005350 *index = 0;
Takashi Iwaice764ab2011-04-27 16:35:23 +02005351 if (cfg->line_outs == 1 && !spec->multi_ios &&
5352 !cfg->hp_outs && !cfg->speaker_outs && can_be_master)
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005353 return "Master";
5354
5355 switch (cfg->line_out_type) {
5356 case AUTO_PIN_SPEAKER_OUT:
David Henningssonebbeb3d2011-03-04 14:08:30 +01005357 if (cfg->line_outs == 1)
5358 return "Speaker";
5359 break;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005360 case AUTO_PIN_HP_OUT:
Takashi Iwai6843ca12011-06-24 11:03:58 +02005361 /* for multi-io case, only the primary out */
5362 if (ch && spec->multi_ios)
5363 break;
5364 *index = ch;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005365 return "Headphone";
5366 default:
Takashi Iwaice764ab2011-04-27 16:35:23 +02005367 if (cfg->line_outs == 1 && !spec->multi_ios)
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005368 return "PCM";
5369 break;
5370 }
Takashi Iwai6843ca12011-06-24 11:03:58 +02005371 return chname[ch];
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005372}
5373
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005374/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005375static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005376 const char *ctlname, int ctlidx,
Kailang Yangdf694da2005-12-05 19:42:22 +01005377 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005378{
Kailang Yangdf694da2005-12-05 19:42:22 +01005379 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005380
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005381 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005382 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5383 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005384 return err;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005385 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005386 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5387 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005388 return err;
5389 return 0;
5390}
5391
Takashi Iwai05f5f472009-08-25 13:10:18 +02005392static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005393{
Takashi Iwai05f5f472009-08-25 13:10:18 +02005394 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
5395 return (pincap & AC_PINCAP_IN) != 0;
5396}
5397
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +02005398static int alc_auto_fill_adc_caps(struct hda_codec *codec)
Takashi Iwaib7821702011-07-06 15:12:46 +02005399{
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +02005400 struct alc_spec *spec = codec->spec;
Takashi Iwaib7821702011-07-06 15:12:46 +02005401 hda_nid_t nid;
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +02005402 hda_nid_t *adc_nids = spec->private_adc_nids;
5403 hda_nid_t *cap_nids = spec->private_capsrc_nids;
5404 int max_nums = ARRAY_SIZE(spec->private_adc_nids);
5405 bool indep_capsrc = false;
Takashi Iwaib7821702011-07-06 15:12:46 +02005406 int i, nums = 0;
5407
5408 nid = codec->start_nid;
5409 for (i = 0; i < codec->num_nodes; i++, nid++) {
5410 hda_nid_t src;
5411 const hda_nid_t *list;
5412 unsigned int caps = get_wcaps(codec, nid);
5413 int type = get_wcaps_type(caps);
5414
5415 if (type != AC_WID_AUD_IN || (caps & AC_WCAP_DIGITAL))
5416 continue;
5417 adc_nids[nums] = nid;
5418 cap_nids[nums] = nid;
5419 src = nid;
5420 for (;;) {
5421 int n;
5422 type = get_wcaps_type(get_wcaps(codec, src));
5423 if (type == AC_WID_PIN)
5424 break;
5425 if (type == AC_WID_AUD_SEL) {
5426 cap_nids[nums] = src;
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +02005427 indep_capsrc = true;
Takashi Iwaib7821702011-07-06 15:12:46 +02005428 break;
5429 }
5430 n = snd_hda_get_conn_list(codec, src, &list);
5431 if (n > 1) {
5432 cap_nids[nums] = src;
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +02005433 indep_capsrc = true;
Takashi Iwaib7821702011-07-06 15:12:46 +02005434 break;
5435 } else if (n != 1)
5436 break;
5437 src = *list;
5438 }
5439 if (++nums >= max_nums)
5440 break;
5441 }
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +02005442 spec->adc_nids = spec->private_adc_nids;
5443 if (indep_capsrc)
5444 spec->capsrc_nids = spec->private_capsrc_nids;
5445 spec->num_adc_nids = nums;
Takashi Iwaib7821702011-07-06 15:12:46 +02005446 return nums;
5447}
5448
Takashi Iwai05f5f472009-08-25 13:10:18 +02005449/* create playback/capture controls for input pins */
Takashi Iwaib7821702011-07-06 15:12:46 +02005450static int alc_auto_create_input_ctls(struct hda_codec *codec)
Takashi Iwai05f5f472009-08-25 13:10:18 +02005451{
5452 struct alc_spec *spec = codec->spec;
Takashi Iwaib7821702011-07-06 15:12:46 +02005453 const struct auto_pin_cfg *cfg = &spec->autocfg;
5454 hda_nid_t mixer = spec->mixer_nid;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005455 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwaib7821702011-07-06 15:12:46 +02005456 int num_adcs;
Takashi Iwaib7821702011-07-06 15:12:46 +02005457 int i, c, err, idx, type_idx = 0;
David Henningsson5322bf22011-01-05 11:03:56 +01005458 const char *prev_label = NULL;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005459
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +02005460 num_adcs = alc_auto_fill_adc_caps(codec);
Takashi Iwaib7821702011-07-06 15:12:46 +02005461 if (num_adcs < 0)
5462 return 0;
5463
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005464 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02005465 hda_nid_t pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005466 const char *label;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005467
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005468 pin = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005469 if (!alc_is_input_pin(codec, pin))
5470 continue;
5471
David Henningsson5322bf22011-01-05 11:03:56 +01005472 label = hda_get_autocfg_input_label(codec, cfg, i);
5473 if (prev_label && !strcmp(label, prev_label))
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005474 type_idx++;
5475 else
5476 type_idx = 0;
David Henningsson5322bf22011-01-05 11:03:56 +01005477 prev_label = label;
5478
Takashi Iwai05f5f472009-08-25 13:10:18 +02005479 if (mixer) {
5480 idx = get_connection_index(codec, mixer, pin);
5481 if (idx >= 0) {
5482 err = new_analog_input(spec, pin,
Takashi Iwai10a20af2010-09-09 16:28:02 +02005483 label, type_idx,
5484 idx, mixer);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005485 if (err < 0)
5486 return err;
5487 }
5488 }
5489
Takashi Iwaib7821702011-07-06 15:12:46 +02005490 for (c = 0; c < num_adcs; c++) {
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +02005491 hda_nid_t cap = spec->capsrc_nids ?
5492 spec->capsrc_nids[c] : spec->adc_nids[c];
5493 idx = get_connection_index(codec, cap, pin);
Takashi Iwaib7821702011-07-06 15:12:46 +02005494 if (idx >= 0) {
5495 snd_hda_add_imux_item(imux, label, idx, NULL);
5496 break;
5497 }
5498 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005499 }
5500 return 0;
5501}
5502
Takashi Iwai343a04b2011-07-06 14:28:39 +02005503static int alc_auto_fill_dac_nids(struct hda_codec *codec);
5504static int alc_auto_create_multi_out_ctls(struct hda_codec *codec,
5505 const struct auto_pin_cfg *cfg);
5506static int alc_auto_create_hp_out(struct hda_codec *codec);
5507static int alc_auto_create_speaker_out(struct hda_codec *codec);
5508static void alc_auto_init_multi_out(struct hda_codec *codec);
5509static void alc_auto_init_extra_out(struct hda_codec *codec);
5510
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005511static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
5512 unsigned int pin_type)
5513{
5514 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5515 pin_type);
5516 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01005517 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5518 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005519}
5520
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005521static int get_pin_type(int line_out_type)
5522{
5523 if (line_out_type == AUTO_PIN_HP_OUT)
5524 return PIN_HP;
5525 else
5526 return PIN_OUT;
5527}
5528
Takashi Iwai0a7f5322011-07-06 15:15:12 +02005529static void alc_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005530{
5531 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005532 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005533 int i;
5534
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005535 for (i = 0; i < cfg->num_inputs; i++) {
5536 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005537 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02005538 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai1f0f4b82011-06-27 10:52:59 +02005539 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005540 snd_hda_codec_write(codec, nid, 0,
5541 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005542 AMP_OUT_MUTE);
5543 }
5544 }
Takashi Iwai1f0f4b82011-06-27 10:52:59 +02005545
5546 /* mute all loopback inputs */
5547 if (spec->mixer_nid) {
5548 int nums = snd_hda_get_conn_list(codec, spec->mixer_nid, NULL);
5549 for (i = 0; i < nums; i++)
5550 snd_hda_codec_write(codec, spec->mixer_nid, 0,
5551 AC_VERB_SET_AMP_GAIN_MUTE,
5552 AMP_IN_MUTE(i));
5553 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005554}
5555
Takashi Iwaicb053a82011-06-27 11:32:07 +02005556static int alc_auto_add_multi_channel_mode(struct hda_codec *codec,
5557 int (*fill_dac)(struct hda_codec *));
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +02005558static void alc_remove_invalid_adc_nids(struct hda_codec *codec);
Takashi Iwaif970de22011-07-06 17:39:59 +02005559static void alc_auto_init_input_src(struct hda_codec *codec);
Takashi Iwaice764ab2011-04-27 16:35:23 +02005560
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005561/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005562/* return 1 if successful, 0 if the proper config is not found,
5563 * or a negative error code
5564 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005565static int alc880_parse_auto_config(struct hda_codec *codec)
5566{
5567 struct alc_spec *spec = codec->spec;
Takashi Iwai757899a2010-07-30 10:48:14 +02005568 int err;
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02005569 static const hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005570
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005571 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5572 alc880_ignore);
5573 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005574 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005575 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005576 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01005577
Takashi Iwai343a04b2011-07-06 14:28:39 +02005578 err = alc_auto_fill_dac_nids(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005579 if (err < 0)
5580 return err;
Takashi Iwai343a04b2011-07-06 14:28:39 +02005581 err = alc_auto_add_multi_channel_mode(codec, alc_auto_fill_dac_nids);
Takashi Iwaice764ab2011-04-27 16:35:23 +02005582 if (err < 0)
5583 return err;
Takashi Iwai343a04b2011-07-06 14:28:39 +02005584 err = alc_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005585 if (err < 0)
5586 return err;
Takashi Iwai343a04b2011-07-06 14:28:39 +02005587 err = alc_auto_create_hp_out(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005588 if (err < 0)
5589 return err;
Takashi Iwai343a04b2011-07-06 14:28:39 +02005590 err = alc_auto_create_speaker_out(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005591 if (err < 0)
5592 return err;
Takashi Iwaib7821702011-07-06 15:12:46 +02005593 err = alc_auto_create_input_ctls(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005594 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005595 return err;
5596
5597 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5598
Takashi Iwai757899a2010-07-30 10:48:14 +02005599 alc_auto_parse_digital(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005600
Takashi Iwai603c4012008-07-30 15:01:44 +02005601 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005602 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005603
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005604 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005605 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005606
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +02005607 if (!spec->dual_adc_switch)
5608 alc_remove_invalid_adc_nids(codec);
5609
Kailang Yang6227cdc2010-02-25 08:36:52 +01005610 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005611
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005612 return 1;
5613}
5614
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005615/* additional initialization for auto-configuration model */
5616static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005617{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005618 struct alc_spec *spec = codec->spec;
Takashi Iwai343a04b2011-07-06 14:28:39 +02005619 alc_auto_init_multi_out(codec);
5620 alc_auto_init_extra_out(codec);
Takashi Iwai0a7f5322011-07-06 15:15:12 +02005621 alc_auto_init_analog_input(codec);
Takashi Iwaif970de22011-07-06 17:39:59 +02005622 alc_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02005623 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005624 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005625 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005626}
5627
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005628/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5629 * one of two digital mic pins, e.g. on ALC272
5630 */
5631static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005632{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005633 struct alc_spec *spec = codec->spec;
5634 int i;
5635
5636 for (i = 0; i < spec->num_adc_nids; i++) {
5637 hda_nid_t cap = spec->capsrc_nids ?
5638 spec->capsrc_nids[i] : spec->adc_nids[i];
5639 int iidx, eidx;
5640
5641 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5642 if (iidx < 0)
5643 continue;
5644 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5645 if (eidx < 0)
5646 continue;
5647 spec->int_mic.mux_idx = iidx;
5648 spec->ext_mic.mux_idx = eidx;
5649 if (spec->capsrc_nids)
5650 spec->capsrc_nids += i;
5651 spec->adc_nids += i;
5652 spec->num_adc_nids = 1;
Takashi Iwai8ed99d92011-05-17 12:05:02 +02005653 /* optional dock-mic */
5654 eidx = get_connection_index(codec, cap, spec->dock_mic.pin);
5655 if (eidx < 0)
5656 spec->dock_mic.pin = 0;
5657 else
5658 spec->dock_mic.mux_idx = eidx;
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005659 return;
5660 }
5661 snd_printd(KERN_INFO "hda_codec: %s: "
5662 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5663 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5664 spec->auto_mic = 0; /* disable auto-mic to be sure */
5665}
5666
Takashi Iwai748cce42010-08-04 07:37:39 +02005667/* select or unmute the given capsrc route */
5668static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
5669 int idx)
5670{
5671 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5672 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5673 HDA_AMP_MUTE, 0);
5674 } else {
5675 snd_hda_codec_write_cache(codec, cap, 0,
5676 AC_VERB_SET_CONNECT_SEL, idx);
5677 }
5678}
5679
Takashi Iwai840b64c2010-07-13 22:49:01 +02005680/* set the default connection to that pin */
5681static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
5682{
5683 struct alc_spec *spec = codec->spec;
5684 int i;
5685
Takashi Iwai8ed99d92011-05-17 12:05:02 +02005686 if (!pin)
5687 return 0;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005688 for (i = 0; i < spec->num_adc_nids; i++) {
5689 hda_nid_t cap = spec->capsrc_nids ?
5690 spec->capsrc_nids[i] : spec->adc_nids[i];
5691 int idx;
5692
5693 idx = get_connection_index(codec, cap, pin);
5694 if (idx < 0)
5695 continue;
Takashi Iwai748cce42010-08-04 07:37:39 +02005696 select_or_unmute_capsrc(codec, cap, idx);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005697 return i; /* return the found index */
5698 }
5699 return -1; /* not found */
5700}
5701
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005702/* choose the ADC/MUX containing the input pin and initialize the setup */
5703static void fixup_single_adc(struct hda_codec *codec)
5704{
5705 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005706 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005707 int i;
5708
5709 /* search for the input pin; there must be only one */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005710 if (cfg->num_inputs != 1)
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005711 return;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005712 i = init_capsrc_for_pin(codec, cfg->inputs[0].pin);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005713 if (i >= 0) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005714 /* use only this ADC */
5715 if (spec->capsrc_nids)
5716 spec->capsrc_nids += i;
5717 spec->adc_nids += i;
5718 spec->num_adc_nids = 1;
Takashi Iwai584c0c42011-03-10 12:51:11 +01005719 spec->single_input_src = 1;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005720 }
5721}
5722
Takashi Iwai840b64c2010-07-13 22:49:01 +02005723/* initialize dual adcs */
5724static void fixup_dual_adc_switch(struct hda_codec *codec)
5725{
5726 struct alc_spec *spec = codec->spec;
5727 init_capsrc_for_pin(codec, spec->ext_mic.pin);
Takashi Iwai8ed99d92011-05-17 12:05:02 +02005728 init_capsrc_for_pin(codec, spec->dock_mic.pin);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005729 init_capsrc_for_pin(codec, spec->int_mic.pin);
5730}
5731
Takashi Iwai584c0c42011-03-10 12:51:11 +01005732/* initialize some special cases for input sources */
5733static void alc_init_special_input_src(struct hda_codec *codec)
5734{
5735 struct alc_spec *spec = codec->spec;
5736 if (spec->dual_adc_switch)
5737 fixup_dual_adc_switch(codec);
5738 else if (spec->single_input_src)
5739 init_capsrc_for_pin(codec, spec->autocfg.inputs[0].pin);
5740}
5741
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005742static void set_capture_mixer(struct hda_codec *codec)
5743{
5744 struct alc_spec *spec = codec->spec;
Takashi Iwaia9111322011-05-02 11:30:18 +02005745 static const struct snd_kcontrol_new *caps[2][3] = {
Takashi Iwaia23b6882009-03-23 15:21:36 +01005746 { alc_capture_mixer_nosrc1,
5747 alc_capture_mixer_nosrc2,
5748 alc_capture_mixer_nosrc3 },
5749 { alc_capture_mixer1,
5750 alc_capture_mixer2,
5751 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005752 };
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +02005753
5754 /* check whether either of ADC or MUX has a volume control */
5755 if (!(query_amp_caps(codec, spec->adc_nids[0], HDA_INPUT) &
5756 AC_AMPCAP_NUM_STEPS)) {
5757 if (!spec->capsrc_nids)
5758 return; /* no volume */
5759 if (!(query_amp_caps(codec, spec->capsrc_nids[0], HDA_OUTPUT) &
5760 AC_AMPCAP_NUM_STEPS))
5761 return; /* no volume in capsrc, too */
5762 spec->vol_in_capsrc = 1;
5763 }
5764
5765 if (spec->num_adc_nids > 0) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005766 int mux = 0;
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +02005767 int num_adcs = 0;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005768 if (spec->dual_adc_switch)
Takashi Iwai584c0c42011-03-10 12:51:11 +01005769 num_adcs = 1;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005770 else if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005771 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005772 else if (spec->input_mux) {
5773 if (spec->input_mux->num_items > 1)
5774 mux = 1;
5775 else if (spec->input_mux->num_items == 1)
5776 fixup_single_adc(codec);
5777 }
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +02005778 if (!num_adcs) {
5779 if (spec->num_adc_nids > 3)
5780 spec->num_adc_nids = 3;
5781 else if (!spec->num_adc_nids)
5782 return;
5783 num_adcs = spec->num_adc_nids;
5784 }
Takashi Iwai840b64c2010-07-13 22:49:01 +02005785 spec->cap_mixer = caps[mux][num_adcs - 1];
Takashi Iwaia23b6882009-03-23 15:21:36 +01005786 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005787}
5788
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +02005789/* filter out invalid adc_nids (and capsrc_nids) that don't give all
5790 * active input pins
5791 */
5792static void alc_remove_invalid_adc_nids(struct hda_codec *codec)
Takashi Iwai66946352010-03-29 17:21:45 +02005793{
5794 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005795 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +02005796 hda_nid_t adc_nids[ARRAY_SIZE(spec->private_adc_nids)];
5797 hda_nid_t capsrc_nids[ARRAY_SIZE(spec->private_adc_nids)];
5798 int i, n, nums;
Takashi Iwai66946352010-03-29 17:21:45 +02005799
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +02005800 nums = 0;
5801 for (n = 0; n < spec->num_adc_nids; n++) {
5802 hda_nid_t cap = spec->private_capsrc_nids[n];
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005803 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +02005804 hda_nid_t pin = cfg->inputs[i].pin;
5805 if (get_connection_index(codec, cap, pin) < 0)
Takashi Iwai66946352010-03-29 17:21:45 +02005806 break;
5807 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005808 if (i >= cfg->num_inputs) {
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +02005809 adc_nids[nums] = spec->private_adc_nids[n];
5810 capsrc_nids[nums++] = cap;
Takashi Iwai66946352010-03-29 17:21:45 +02005811 }
5812 }
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +02005813 if (!nums) {
Takashi Iwai66946352010-03-29 17:21:45 +02005814 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005815 " using fallback 0x%x\n",
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +02005816 codec->chip_name, spec->private_adc_nids[0]);
5817 spec->num_adc_nids = 1;
5818 } else if (nums != spec->num_adc_nids) {
5819 memcpy(spec->private_adc_nids, adc_nids,
5820 nums * sizeof(hda_nid_t));
5821 memcpy(spec->private_capsrc_nids, capsrc_nids,
5822 nums * sizeof(hda_nid_t));
5823 spec->num_adc_nids = nums;
Takashi Iwai66946352010-03-29 17:21:45 +02005824 }
5825}
5826
Takashi Iwai67d634c2009-11-16 15:35:59 +01005827#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005828#define set_beep_amp(spec, nid, idx, dir) \
5829 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005830
Takashi Iwaia9111322011-05-02 11:30:18 +02005831static const struct snd_pci_quirk beep_white_list[] = {
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005832 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai080dc7b2010-09-08 08:38:41 +02005833 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
Daniel Corderoa7e985e2011-04-29 08:18:06 +02005834 SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
Madis Janson39dfe132011-05-19 18:32:41 +02005835 SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
Takashi Iwaie096c8e2010-08-03 17:20:35 +02005836 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005837 {}
5838};
5839
5840static inline int has_cdefine_beep(struct hda_codec *codec)
5841{
5842 struct alc_spec *spec = codec->spec;
5843 const struct snd_pci_quirk *q;
5844 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5845 if (q)
5846 return q->value;
5847 return spec->cdefine.enable_pcbeep;
5848}
Takashi Iwai67d634c2009-11-16 15:35:59 +01005849#else
5850#define set_beep_amp(spec, nid, idx, dir) /* NOP */
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005851#define has_cdefine_beep(codec) 0
Takashi Iwai67d634c2009-11-16 15:35:59 +01005852#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005853
5854/*
5855 * OK, here we have finally the patch for ALC880
5856 */
5857
Linus Torvalds1da177e2005-04-16 15:20:36 -07005858static int patch_alc880(struct hda_codec *codec)
5859{
5860 struct alc_spec *spec;
5861 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005862 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005863
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005864 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005865 if (spec == NULL)
5866 return -ENOMEM;
5867
5868 codec->spec = spec;
5869
Takashi Iwai1f0f4b82011-06-27 10:52:59 +02005870 spec->mixer_nid = 0x0b;
5871
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005872 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5873 alc880_models,
5874 alc880_cfg_tbl);
5875 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005876 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5877 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005878 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005879 }
5880
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005881 if (board_config == ALC880_AUTO) {
5882 /* automatic parse from the BIOS config */
5883 err = alc880_parse_auto_config(codec);
5884 if (err < 0) {
5885 alc_free(codec);
5886 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005887 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005888 printk(KERN_INFO
5889 "hda_codec: Cannot set up configuration "
5890 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005891 board_config = ALC880_3ST;
5892 }
5893 }
5894
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005895 err = snd_hda_attach_beep_device(codec, 0x1);
5896 if (err < 0) {
5897 alc_free(codec);
5898 return err;
5899 }
5900
Kailang Yangdf694da2005-12-05 19:42:22 +01005901 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005902 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005903
Linus Torvalds1da177e2005-04-16 15:20:36 -07005904 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5905 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005906 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005907
Linus Torvalds1da177e2005-04-16 15:20:36 -07005908 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5909 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5910
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005911 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +02005912 alc_auto_fill_adc_caps(codec);
5913 alc_remove_invalid_adc_nids(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005914 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005915 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005916 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005917
Takashi Iwai2134ea42008-01-10 16:53:55 +01005918 spec->vmaster_nid = 0x0c;
5919
Linus Torvalds1da177e2005-04-16 15:20:36 -07005920 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005921 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005922 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005923#ifdef CONFIG_SND_HDA_POWER_SAVE
5924 if (!spec->loopback.amplist)
5925 spec->loopback.amplist = alc880_loopbacks;
5926#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005927
5928 return 0;
5929}
5930
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005931
Linus Torvalds1da177e2005-04-16 15:20:36 -07005932/*
5933 * ALC260 support
5934 */
5935
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02005936static const hda_nid_t alc260_dac_nids[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005937 /* front */
5938 0x02,
5939};
5940
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02005941static const hda_nid_t alc260_adc_nids[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005942 /* ADC0 */
5943 0x04,
5944};
5945
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02005946static const hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005947 /* ADC1 */
5948 0x05,
5949};
5950
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005951/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5952 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5953 */
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02005954static const hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005955 /* ADC0, ADC1 */
5956 0x04, 0x05
5957};
5958
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005959#define ALC260_DIGOUT_NID 0x03
5960#define ALC260_DIGIN_NID 0x06
5961
Takashi Iwaia9111322011-05-02 11:30:18 +02005962static const struct hda_input_mux alc260_capture_source = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005963 .num_items = 4,
5964 .items = {
5965 { "Mic", 0x0 },
5966 { "Front Mic", 0x1 },
5967 { "Line", 0x2 },
5968 { "CD", 0x4 },
5969 },
5970};
5971
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005972/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005973 * headphone jack and the internal CD lines since these are the only pins at
5974 * which audio can appear. For flexibility, also allow the option of
5975 * recording the mixer output on the second ADC (ADC0 doesn't have a
5976 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005977 */
Takashi Iwaia9111322011-05-02 11:30:18 +02005978static const struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005979 {
5980 .num_items = 3,
5981 .items = {
5982 { "Mic/Line", 0x0 },
5983 { "CD", 0x4 },
5984 { "Headphone", 0x2 },
5985 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005986 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005987 {
5988 .num_items = 4,
5989 .items = {
5990 { "Mic/Line", 0x0 },
5991 { "CD", 0x4 },
5992 { "Headphone", 0x2 },
5993 { "Mixer", 0x5 },
5994 },
5995 },
5996
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005997};
5998
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005999/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
6000 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006001 */
Takashi Iwaia9111322011-05-02 11:30:18 +02006002static const struct hda_input_mux alc260_acer_capture_sources[2] = {
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006003 {
6004 .num_items = 4,
6005 .items = {
6006 { "Mic", 0x0 },
6007 { "Line", 0x2 },
6008 { "CD", 0x4 },
6009 { "Headphone", 0x5 },
6010 },
6011 },
6012 {
6013 .num_items = 5,
6014 .items = {
6015 { "Mic", 0x0 },
6016 { "Line", 0x2 },
6017 { "CD", 0x4 },
6018 { "Headphone", 0x6 },
6019 { "Mixer", 0x5 },
6020 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006021 },
6022};
Michael Schwingencc959482009-02-22 18:58:45 +01006023
6024/* Maxdata Favorit 100XS */
Takashi Iwaia9111322011-05-02 11:30:18 +02006025static const struct hda_input_mux alc260_favorit100_capture_sources[2] = {
Michael Schwingencc959482009-02-22 18:58:45 +01006026 {
6027 .num_items = 2,
6028 .items = {
6029 { "Line/Mic", 0x0 },
6030 { "CD", 0x4 },
6031 },
6032 },
6033 {
6034 .num_items = 3,
6035 .items = {
6036 { "Line/Mic", 0x0 },
6037 { "CD", 0x4 },
6038 { "Mixer", 0x5 },
6039 },
6040 },
6041};
6042
Linus Torvalds1da177e2005-04-16 15:20:36 -07006043/*
6044 * This is just place-holder, so there's something for alc_build_pcms to look
6045 * at when it calculates the maximum number of channels. ALC260 has no mixer
6046 * element which allows changing the channel mode, so the verb list is
6047 * never used.
6048 */
Takashi Iwaia9111322011-05-02 11:30:18 +02006049static const struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006050 { 2, NULL },
6051};
6052
Kailang Yangdf694da2005-12-05 19:42:22 +01006053
6054/* Mixer combinations
6055 *
6056 * basic: base_output + input + pc_beep + capture
6057 * HP: base_output + input + capture_alt
6058 * HP_3013: hp_3013 + input + capture
6059 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006060 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01006061 */
6062
Takashi Iwaia9111322011-05-02 11:30:18 +02006063static const struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006064 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006065 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006066 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6067 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
6068 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6069 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6070 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006071};
Kailang Yangdf694da2005-12-05 19:42:22 +01006072
Takashi Iwaia9111322011-05-02 11:30:18 +02006073static const struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006074 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6075 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6076 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6077 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6078 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6079 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6080 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
6081 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006082 { } /* end */
6083};
6084
Takashi Iwaibec15c32008-01-28 18:16:30 +01006085/* update HP, line and mono out pins according to the master switch */
Takashi Iwaie9427962011-04-28 15:46:07 +02006086static void alc260_hp_master_update(struct hda_codec *codec)
Takashi Iwaibec15c32008-01-28 18:16:30 +01006087{
Takashi Iwaie9427962011-04-28 15:46:07 +02006088 update_speakers(codec);
Takashi Iwaibec15c32008-01-28 18:16:30 +01006089}
6090
6091static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
6092 struct snd_ctl_elem_value *ucontrol)
6093{
6094 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6095 struct alc_spec *spec = codec->spec;
Takashi Iwaie9427962011-04-28 15:46:07 +02006096 *ucontrol->value.integer.value = !spec->master_mute;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006097 return 0;
6098}
6099
6100static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
6101 struct snd_ctl_elem_value *ucontrol)
6102{
6103 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6104 struct alc_spec *spec = codec->spec;
Takashi Iwaie9427962011-04-28 15:46:07 +02006105 int val = !*ucontrol->value.integer.value;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006106
Takashi Iwaie9427962011-04-28 15:46:07 +02006107 if (val == spec->master_mute)
Takashi Iwaibec15c32008-01-28 18:16:30 +01006108 return 0;
Takashi Iwaie9427962011-04-28 15:46:07 +02006109 spec->master_mute = val;
6110 alc260_hp_master_update(codec);
Takashi Iwaibec15c32008-01-28 18:16:30 +01006111 return 1;
6112}
6113
Takashi Iwaia9111322011-05-02 11:30:18 +02006114static const struct snd_kcontrol_new alc260_hp_output_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006115 {
6116 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6117 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01006118 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006119 .info = snd_ctl_boolean_mono_info,
6120 .get = alc260_hp_master_sw_get,
6121 .put = alc260_hp_master_sw_put,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006122 },
6123 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6124 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
6125 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6126 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
6127 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
6128 HDA_OUTPUT),
6129 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6130 { } /* end */
6131};
6132
Takashi Iwaia9111322011-05-02 11:30:18 +02006133static const struct hda_verb alc260_hp_unsol_verbs[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006134 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6135 {},
6136};
6137
Takashi Iwaie9427962011-04-28 15:46:07 +02006138static void alc260_hp_setup(struct hda_codec *codec)
Takashi Iwaibec15c32008-01-28 18:16:30 +01006139{
6140 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006141
Takashi Iwaie9427962011-04-28 15:46:07 +02006142 spec->autocfg.hp_pins[0] = 0x0f;
6143 spec->autocfg.speaker_pins[0] = 0x10;
6144 spec->autocfg.speaker_pins[1] = 0x11;
6145 spec->automute = 1;
6146 spec->automute_mode = ALC_AUTOMUTE_PIN;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006147}
6148
Takashi Iwaia9111322011-05-02 11:30:18 +02006149static const struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006150 {
6151 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6152 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01006153 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006154 .info = snd_ctl_boolean_mono_info,
6155 .get = alc260_hp_master_sw_get,
6156 .put = alc260_hp_master_sw_put,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006157 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006158 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6159 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
6160 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
6161 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
6162 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6163 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01006164 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6165 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02006166 { } /* end */
6167};
6168
Takashi Iwaie9427962011-04-28 15:46:07 +02006169static void alc260_hp_3013_setup(struct hda_codec *codec)
6170{
6171 struct alc_spec *spec = codec->spec;
6172
6173 spec->autocfg.hp_pins[0] = 0x15;
6174 spec->autocfg.speaker_pins[0] = 0x10;
6175 spec->autocfg.speaker_pins[1] = 0x11;
6176 spec->automute = 1;
6177 spec->automute_mode = ALC_AUTOMUTE_PIN;
6178}
6179
Takashi Iwaia9111322011-05-02 11:30:18 +02006180static const struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
Kailang Yang3f878302008-08-26 13:02:23 +02006181 .ops = &snd_hda_bind_vol,
6182 .values = {
6183 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
6184 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
6185 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
6186 0
6187 },
6188};
6189
Takashi Iwaia9111322011-05-02 11:30:18 +02006190static const struct hda_bind_ctls alc260_dc7600_bind_switch = {
Kailang Yang3f878302008-08-26 13:02:23 +02006191 .ops = &snd_hda_bind_sw,
6192 .values = {
6193 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
6194 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
6195 0
6196 },
6197};
6198
Takashi Iwaia9111322011-05-02 11:30:18 +02006199static const struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
Kailang Yang3f878302008-08-26 13:02:23 +02006200 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
6201 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
6202 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
6203 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
6204 { } /* end */
6205};
6206
Takashi Iwaia9111322011-05-02 11:30:18 +02006207static const struct hda_verb alc260_hp_3013_unsol_verbs[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006208 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6209 {},
6210};
6211
Takashi Iwaie9427962011-04-28 15:46:07 +02006212static void alc260_hp_3012_setup(struct hda_codec *codec)
Takashi Iwaibec15c32008-01-28 18:16:30 +01006213{
6214 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006215
Takashi Iwaie9427962011-04-28 15:46:07 +02006216 spec->autocfg.hp_pins[0] = 0x10;
6217 spec->autocfg.speaker_pins[0] = 0x0f;
6218 spec->autocfg.speaker_pins[1] = 0x11;
6219 spec->autocfg.speaker_pins[2] = 0x15;
6220 spec->automute = 1;
6221 spec->automute_mode = ALC_AUTOMUTE_PIN;
Kailang Yang3f878302008-08-26 13:02:23 +02006222}
6223
6224/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006225 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
6226 */
Takashi Iwaia9111322011-05-02 11:30:18 +02006227static const struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006228 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006229 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006230 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006231 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6232 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6233 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
6234 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006235 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006236 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6237 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006238 { } /* end */
6239};
6240
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006241/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
6242 * versions of the ALC260 don't act on requests to enable mic bias from NID
6243 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
6244 * datasheet doesn't mention this restriction. At this stage it's not clear
6245 * whether this behaviour is intentional or is a hardware bug in chip
6246 * revisions available in early 2006. Therefore for now allow the
6247 * "Headphone Jack Mode" control to span all choices, but if it turns out
6248 * that the lack of mic bias for this NID is intentional we could change the
6249 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6250 *
6251 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
6252 * don't appear to make the mic bias available from the "line" jack, even
6253 * though the NID used for this jack (0x14) can supply it. The theory is
6254 * that perhaps Acer have included blocking capacitors between the ALC260
6255 * and the output jack. If this turns out to be the case for all such
6256 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
6257 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01006258 *
6259 * The C20x Tablet series have a mono internal speaker which is controlled
6260 * via the chip's Mono sum widget and pin complex, so include the necessary
6261 * controls for such models. On models without a "mono speaker" the control
6262 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006263 */
Takashi Iwaia9111322011-05-02 11:30:18 +02006264static const struct snd_kcontrol_new alc260_acer_mixer[] = {
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006265 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6266 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006267 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006268 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01006269 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006270 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01006271 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006272 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6273 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6274 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6275 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6276 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6277 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6278 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6279 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006280 { } /* end */
6281};
6282
Michael Schwingencc959482009-02-22 18:58:45 +01006283/* Maxdata Favorit 100XS: one output and one input (0x12) jack
6284 */
Takashi Iwaia9111322011-05-02 11:30:18 +02006285static const struct snd_kcontrol_new alc260_favorit100_mixer[] = {
Michael Schwingencc959482009-02-22 18:58:45 +01006286 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6287 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
6288 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
6289 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6290 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6291 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6292 { } /* end */
6293};
6294
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006295/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
6296 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
6297 */
Takashi Iwaia9111322011-05-02 11:30:18 +02006298static const struct snd_kcontrol_new alc260_will_mixer[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006299 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6300 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6301 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6302 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6303 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6304 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6305 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6306 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6307 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6308 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006309 { } /* end */
6310};
6311
6312/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
6313 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
6314 */
Takashi Iwaia9111322011-05-02 11:30:18 +02006315static const struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006316 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6317 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6318 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6319 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6320 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6321 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
6322 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
6323 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6324 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6325 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6326 { } /* end */
6327};
6328
Kailang Yangdf694da2005-12-05 19:42:22 +01006329/*
6330 * initialization verbs
6331 */
Takashi Iwaia9111322011-05-02 11:30:18 +02006332static const struct hda_verb alc260_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006333 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006334 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006335 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006336 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006337 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006338 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006339 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006340 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006341 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02006342 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006343 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01006344 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006345 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02006346 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006347 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02006348 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006349 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02006350 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6351 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02006352 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006353 /* set connection select to line in (default select for this ADC) */
6354 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02006355 /* mute capture amp left and right */
6356 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6357 /* set connection select to line in (default select for this ADC) */
6358 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02006359 /* set vol=0 Line-Out mixer amp left and right */
6360 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6361 /* unmute pin widget amp left and right (no gain on this amp) */
6362 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6363 /* set vol=0 HP mixer amp left and right */
6364 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6365 /* unmute pin widget amp left and right (no gain on this amp) */
6366 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6367 /* set vol=0 Mono mixer amp left and right */
6368 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6369 /* unmute pin widget amp left and right (no gain on this amp) */
6370 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6371 /* unmute LINE-2 out pin */
6372 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006373 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6374 * Line In 2 = 0x03
6375 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006376 /* mute analog inputs */
6377 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6378 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6379 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6380 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6381 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006382 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006383 /* mute Front out path */
6384 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6385 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6386 /* mute Headphone out path */
6387 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6388 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6389 /* mute Mono out path */
6390 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6391 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006392 { }
6393};
6394
Takashi Iwai474167d2006-05-17 17:17:43 +02006395#if 0 /* should be identical with alc260_init_verbs? */
Takashi Iwaia9111322011-05-02 11:30:18 +02006396static const struct hda_verb alc260_hp_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01006397 /* Headphone and output */
6398 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6399 /* mono output */
6400 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6401 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6402 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6403 /* Mic2 (front panel) pin widget for input and vref at 80% */
6404 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6405 /* Line In pin widget for input */
6406 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6407 /* Line-2 pin widget for output */
6408 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6409 /* CD pin widget for input */
6410 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6411 /* unmute amp left and right */
6412 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6413 /* set connection select to line in (default select for this ADC) */
6414 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6415 /* unmute Line-Out mixer amp left and right (volume = 0) */
6416 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6417 /* mute pin widget amp left and right (no gain on this amp) */
6418 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6419 /* unmute HP mixer amp left and right (volume = 0) */
6420 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6421 /* mute pin widget amp left and right (no gain on this amp) */
6422 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006423 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6424 * Line In 2 = 0x03
6425 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006426 /* mute analog inputs */
6427 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6428 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6429 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6430 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6431 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006432 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6433 /* Unmute Front out path */
6434 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6435 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6436 /* Unmute Headphone out path */
6437 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6438 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6439 /* Unmute Mono out path */
6440 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6441 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6442 { }
6443};
Takashi Iwai474167d2006-05-17 17:17:43 +02006444#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006445
Takashi Iwaia9111322011-05-02 11:30:18 +02006446static const struct hda_verb alc260_hp_3013_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01006447 /* Line out and output */
6448 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6449 /* mono output */
6450 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6451 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6452 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6453 /* Mic2 (front panel) pin widget for input and vref at 80% */
6454 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6455 /* Line In pin widget for input */
6456 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6457 /* Headphone pin widget for output */
6458 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6459 /* CD pin widget for input */
6460 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6461 /* unmute amp left and right */
6462 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6463 /* set connection select to line in (default select for this ADC) */
6464 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6465 /* unmute Line-Out mixer amp left and right (volume = 0) */
6466 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6467 /* mute pin widget amp left and right (no gain on this amp) */
6468 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6469 /* unmute HP mixer amp left and right (volume = 0) */
6470 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6471 /* mute pin widget amp left and right (no gain on this amp) */
6472 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006473 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6474 * Line In 2 = 0x03
6475 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006476 /* mute analog inputs */
6477 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6478 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6479 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6480 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6481 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006482 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6483 /* Unmute Front out path */
6484 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6485 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6486 /* Unmute Headphone out path */
6487 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6488 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6489 /* Unmute Mono out path */
6490 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6491 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6492 { }
6493};
6494
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006495/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006496 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
6497 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006498 */
Takashi Iwaia9111322011-05-02 11:30:18 +02006499static const struct hda_verb alc260_fujitsu_init_verbs[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006500 /* Disable all GPIOs */
6501 {0x01, AC_VERB_SET_GPIO_MASK, 0},
6502 /* Internal speaker is connected to headphone pin */
6503 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6504 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
6505 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006506 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
6507 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6508 /* Ensure all other unused pins are disabled and muted. */
6509 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6510 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006511 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006512 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006513 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006514 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6515 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6516 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006517
Jonathan Woithef7ace402006-02-28 11:46:14 +01006518 /* Disable digital (SPDIF) pins */
6519 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6520 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006521
Kailang Yangea1fb292008-08-26 12:58:38 +02006522 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01006523 * when acting as an output.
6524 */
6525 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6526
6527 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01006528 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6529 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6530 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6531 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6532 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6533 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6534 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6535 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6536 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006537
Jonathan Woithef7ace402006-02-28 11:46:14 +01006538 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
6539 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6540 /* Unmute Line1 pin widget output buffer since it starts as an output.
6541 * If the pin mode is changed by the user the pin mode control will
6542 * take care of enabling the pin's input/output buffers as needed.
6543 * Therefore there's no need to enable the input buffer at this
6544 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006545 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006546 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02006547 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006548 * mixer ctrl)
6549 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006550 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006551
Jonathan Woithef7ace402006-02-28 11:46:14 +01006552 /* Mute capture amp left and right */
6553 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006554 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01006555 * in (on mic1 pin)
6556 */
6557 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006558
Jonathan Woithef7ace402006-02-28 11:46:14 +01006559 /* Do the same for the second ADC: mute capture input amp and
6560 * set ADC connection to line in (on mic1 pin)
6561 */
6562 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6563 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006564
Jonathan Woithef7ace402006-02-28 11:46:14 +01006565 /* Mute all inputs to mixer widget (even unconnected ones) */
6566 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6567 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6568 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6569 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6570 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6571 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6572 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6573 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006574
6575 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006576};
6577
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006578/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
6579 * similar laptops (adapted from Fujitsu init verbs).
6580 */
Takashi Iwaia9111322011-05-02 11:30:18 +02006581static const struct hda_verb alc260_acer_init_verbs[] = {
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006582 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
6583 * the headphone jack. Turn this on and rely on the standard mute
6584 * methods whenever the user wants to turn these outputs off.
6585 */
6586 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6587 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6588 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6589 /* Internal speaker/Headphone jack is connected to Line-out pin */
6590 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6591 /* Internal microphone/Mic jack is connected to Mic1 pin */
6592 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6593 /* Line In jack is connected to Line1 pin */
6594 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01006595 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
6596 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006597 /* Ensure all other unused pins are disabled and muted. */
6598 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6599 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006600 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6601 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6602 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6603 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6604 /* Disable digital (SPDIF) pins */
6605 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6606 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6607
Kailang Yangea1fb292008-08-26 12:58:38 +02006608 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006609 * bus when acting as outputs.
6610 */
6611 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6612 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6613
6614 /* Start with output sum widgets muted and their output gains at min */
6615 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6616 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6617 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6618 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6619 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6620 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6621 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6622 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6623 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6624
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006625 /* Unmute Line-out pin widget amp left and right
6626 * (no equiv mixer ctrl)
6627 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006628 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01006629 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6630 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006631 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6632 * inputs. If the pin mode is changed by the user the pin mode control
6633 * will take care of enabling the pin's input/output buffers as needed.
6634 * Therefore there's no need to enable the input buffer at this
6635 * stage.
6636 */
6637 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6638 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6639
6640 /* Mute capture amp left and right */
6641 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6642 /* Set ADC connection select to match default mixer setting - mic
6643 * (on mic1 pin)
6644 */
6645 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6646
6647 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006648 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006649 */
6650 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006651 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006652
6653 /* Mute all inputs to mixer widget (even unconnected ones) */
6654 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6655 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6656 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6657 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6658 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6659 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6660 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6661 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6662
6663 { }
6664};
6665
Michael Schwingencc959482009-02-22 18:58:45 +01006666/* Initialisation sequence for Maxdata Favorit 100XS
6667 * (adapted from Acer init verbs).
6668 */
Takashi Iwaia9111322011-05-02 11:30:18 +02006669static const struct hda_verb alc260_favorit100_init_verbs[] = {
Michael Schwingencc959482009-02-22 18:58:45 +01006670 /* GPIO 0 enables the output jack.
6671 * Turn this on and rely on the standard mute
6672 * methods whenever the user wants to turn these outputs off.
6673 */
6674 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6675 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6676 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6677 /* Line/Mic input jack is connected to Mic1 pin */
6678 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6679 /* Ensure all other unused pins are disabled and muted. */
6680 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6681 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6682 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6683 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6684 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6685 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6686 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6687 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6688 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6689 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6690 /* Disable digital (SPDIF) pins */
6691 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6692 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6693
6694 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6695 * bus when acting as outputs.
6696 */
6697 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6698 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6699
6700 /* Start with output sum widgets muted and their output gains at min */
6701 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6702 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6703 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6704 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6705 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6706 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6707 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6708 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6709 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6710
6711 /* Unmute Line-out pin widget amp left and right
6712 * (no equiv mixer ctrl)
6713 */
6714 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6715 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6716 * inputs. If the pin mode is changed by the user the pin mode control
6717 * will take care of enabling the pin's input/output buffers as needed.
6718 * Therefore there's no need to enable the input buffer at this
6719 * stage.
6720 */
6721 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6722
6723 /* Mute capture amp left and right */
6724 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6725 /* Set ADC connection select to match default mixer setting - mic
6726 * (on mic1 pin)
6727 */
6728 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6729
6730 /* Do similar with the second ADC: mute capture input amp and
6731 * set ADC connection to mic to match ALSA's default state.
6732 */
6733 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6734 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6735
6736 /* Mute all inputs to mixer widget (even unconnected ones) */
6737 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6738 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6739 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6740 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6741 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6742 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6743 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6744 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6745
6746 { }
6747};
6748
Takashi Iwaia9111322011-05-02 11:30:18 +02006749static const struct hda_verb alc260_will_verbs[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006750 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6751 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6752 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6753 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6754 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6755 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6756 {}
6757};
6758
Takashi Iwaia9111322011-05-02 11:30:18 +02006759static const struct hda_verb alc260_replacer_672v_verbs[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006760 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6761 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6762 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6763
6764 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6765 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6766 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6767
6768 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6769 {}
6770};
6771
6772/* toggle speaker-output according to the hp-jack state */
6773static void alc260_replacer_672v_automute(struct hda_codec *codec)
6774{
6775 unsigned int present;
6776
6777 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006778 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006779 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006780 snd_hda_codec_write_cache(codec, 0x01, 0,
6781 AC_VERB_SET_GPIO_DATA, 1);
6782 snd_hda_codec_write_cache(codec, 0x0f, 0,
6783 AC_VERB_SET_PIN_WIDGET_CONTROL,
6784 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006785 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006786 snd_hda_codec_write_cache(codec, 0x01, 0,
6787 AC_VERB_SET_GPIO_DATA, 0);
6788 snd_hda_codec_write_cache(codec, 0x0f, 0,
6789 AC_VERB_SET_PIN_WIDGET_CONTROL,
6790 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006791 }
6792}
6793
6794static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6795 unsigned int res)
6796{
6797 if ((res >> 26) == ALC880_HP_EVENT)
6798 alc260_replacer_672v_automute(codec);
6799}
6800
Takashi Iwaia9111322011-05-02 11:30:18 +02006801static const struct hda_verb alc260_hp_dc7600_verbs[] = {
Kailang Yang3f878302008-08-26 13:02:23 +02006802 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6803 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6804 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6805 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6806 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6807 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6808 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6809 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6810 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6811 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6812 {}
6813};
6814
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006815/* Test configuration for debugging, modelled after the ALC880 test
6816 * configuration.
6817 */
6818#ifdef CONFIG_SND_DEBUG
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02006819static const hda_nid_t alc260_test_dac_nids[1] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006820 0x02,
6821};
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02006822static const hda_nid_t alc260_test_adc_nids[2] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006823 0x04, 0x05,
6824};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006825/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006826 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006827 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006828 */
Takashi Iwaia9111322011-05-02 11:30:18 +02006829static const struct hda_input_mux alc260_test_capture_sources[2] = {
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006830 {
6831 .num_items = 7,
6832 .items = {
6833 { "MIC1 pin", 0x0 },
6834 { "MIC2 pin", 0x1 },
6835 { "LINE1 pin", 0x2 },
6836 { "LINE2 pin", 0x3 },
6837 { "CD pin", 0x4 },
6838 { "LINE-OUT pin", 0x5 },
6839 { "HP-OUT pin", 0x6 },
6840 },
6841 },
6842 {
6843 .num_items = 8,
6844 .items = {
6845 { "MIC1 pin", 0x0 },
6846 { "MIC2 pin", 0x1 },
6847 { "LINE1 pin", 0x2 },
6848 { "LINE2 pin", 0x3 },
6849 { "CD pin", 0x4 },
6850 { "Mixer", 0x5 },
6851 { "LINE-OUT pin", 0x6 },
6852 { "HP-OUT pin", 0x7 },
6853 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006854 },
6855};
Takashi Iwaia9111322011-05-02 11:30:18 +02006856static const struct snd_kcontrol_new alc260_test_mixer[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006857 /* Output driver widgets */
6858 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6859 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6860 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6861 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6862 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6863 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6864
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006865 /* Modes for retasking pin widgets
6866 * Note: the ALC260 doesn't seem to act on requests to enable mic
6867 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6868 * mention this restriction. At this stage it's not clear whether
6869 * this behaviour is intentional or is a hardware bug in chip
6870 * revisions available at least up until early 2006. Therefore for
6871 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6872 * choices, but if it turns out that the lack of mic bias for these
6873 * NIDs is intentional we could change their modes from
6874 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6875 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006876 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6877 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6878 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6879 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6880 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6881 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6882
6883 /* Loopback mixer controls */
6884 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6885 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6886 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6887 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6888 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6889 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6890 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6891 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6892 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6893 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006894 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6895 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6896 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6897 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006898
6899 /* Controls for GPIO pins, assuming they are configured as outputs */
6900 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6901 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6902 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6903 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6904
Jonathan Woithe92621f12006-02-28 11:47:47 +01006905 /* Switches to allow the digital IO pins to be enabled. The datasheet
6906 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006907 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006908 */
6909 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6910 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6911
Jonathan Woithef8225f62008-01-08 12:16:54 +01006912 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6913 * this output to turn on an external amplifier.
6914 */
6915 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6916 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6917
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006918 { } /* end */
6919};
Takashi Iwaia9111322011-05-02 11:30:18 +02006920static const struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006921 /* Enable all GPIOs as outputs with an initial value of 0 */
6922 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6923 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6924 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6925
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006926 /* Enable retasking pins as output, initially without power amp */
6927 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6928 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6929 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6930 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6931 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6932 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6933
Jonathan Woithe92621f12006-02-28 11:47:47 +01006934 /* Disable digital (SPDIF) pins initially, but users can enable
6935 * them via a mixer switch. In the case of SPDIF-out, this initverb
6936 * payload also sets the generation to 0, output to be in "consumer"
6937 * PCM format, copyright asserted, no pre-emphasis and no validity
6938 * control.
6939 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006940 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6941 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6942
Kailang Yangea1fb292008-08-26 12:58:38 +02006943 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006944 * OUT1 sum bus when acting as an output.
6945 */
6946 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6947 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6948 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6949 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6950
6951 /* Start with output sum widgets muted and their output gains at min */
6952 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6953 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6954 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6955 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6956 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6957 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6958 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6959 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6960 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6961
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006962 /* Unmute retasking pin widget output buffers since the default
6963 * state appears to be output. As the pin mode is changed by the
6964 * user the pin mode control will take care of enabling the pin's
6965 * input/output buffers as needed.
6966 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006967 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6968 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6969 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6970 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6971 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6972 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6973 /* Also unmute the mono-out pin widget */
6974 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6975
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006976 /* Mute capture amp left and right */
6977 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006978 /* Set ADC connection select to match default mixer setting (mic1
6979 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006980 */
6981 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6982
6983 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006984 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006985 */
6986 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6987 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6988
6989 /* Mute all inputs to mixer widget (even unconnected ones) */
6990 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6991 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6992 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6993 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6994 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6995 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6996 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6997 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6998
6999 { }
7000};
7001#endif
7002
Takashi Iwai63300792008-01-24 15:31:36 +01007003#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
7004#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07007005
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007006#define alc260_pcm_digital_playback alc880_pcm_digital_playback
7007#define alc260_pcm_digital_capture alc880_pcm_digital_capture
7008
Kailang Yangdf694da2005-12-05 19:42:22 +01007009/*
7010 * for BIOS auto-configuration
7011 */
7012
Takashi Iwai6d86b4f2011-06-27 15:00:48 +02007013/* convert from pin to volume-mixer widget */
7014static hda_nid_t alc260_pin_to_vol_mix(hda_nid_t nid)
7015{
7016 if (nid >= 0x0f && nid <= 0x11)
7017 return nid - 0x7;
7018 else if (nid >= 0x12 && nid <= 0x15)
7019 return 0x08;
7020 else
7021 return 0;
7022}
7023
Kailang Yangdf694da2005-12-05 19:42:22 +01007024static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02007025 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01007026{
7027 hda_nid_t nid_vol;
7028 unsigned long vol_val, sw_val;
Takashi Iwai6d86b4f2011-06-27 15:00:48 +02007029 int chs, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01007030
Takashi Iwai6d86b4f2011-06-27 15:00:48 +02007031 nid_vol = alc260_pin_to_vol_mix(nid);
7032 if (!nid_vol)
Kailang Yangdf694da2005-12-05 19:42:22 +01007033 return 0; /* N/A */
Takashi Iwai6d86b4f2011-06-27 15:00:48 +02007034 if (nid == 0x11)
7035 chs = 2;
7036 else
7037 chs = 3;
7038 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, chs, 0, HDA_OUTPUT);
7039 sw_val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT);
Kailang Yangea1fb292008-08-26 12:58:38 +02007040
Takashi Iwai863b4512008-10-21 17:01:47 +02007041 if (!(*vol_bits & (1 << nid_vol))) {
7042 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02007043 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02007044 if (err < 0)
7045 return err;
7046 *vol_bits |= (1 << nid_vol);
7047 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02007048 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007049 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007050 return err;
7051 return 1;
7052}
7053
7054/* add playback controls from the parsed DAC table */
7055static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
7056 const struct auto_pin_cfg *cfg)
7057{
7058 hda_nid_t nid;
7059 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02007060 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01007061
7062 spec->multiout.num_dacs = 1;
7063 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaidda14412011-05-02 11:29:30 +02007064 spec->private_dac_nids[0] = 0x02;
Kailang Yangdf694da2005-12-05 19:42:22 +01007065
7066 nid = cfg->line_out_pins[0];
7067 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02007068 const char *pfx;
Takashi Iwai2e925dd2011-06-24 11:27:22 +02007069 int index;
7070 pfx = alc_get_line_out_pfx(spec, 0, true, &index);
Takashi Iwai23112d62009-08-25 16:07:08 +02007071 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01007072 if (err < 0)
7073 return err;
7074 }
7075
Takashi Iwai82bc9552006-03-21 11:24:42 +01007076 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007077 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02007078 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01007079 if (err < 0)
7080 return err;
7081 }
7082
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007083 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007084 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02007085 err = alc260_add_playback_controls(spec, nid, "Headphone",
7086 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01007087 if (err < 0)
7088 return err;
7089 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007090 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01007091}
7092
Kailang Yangdf694da2005-12-05 19:42:22 +01007093static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
7094 hda_nid_t nid, int pin_type,
7095 int sel_idx)
7096{
Takashi Iwai6d86b4f2011-06-27 15:00:48 +02007097 hda_nid_t mix;
7098
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007099 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007100 /* need the manual connection? */
7101 if (nid >= 0x12) {
7102 int idx = nid - 0x12;
7103 snd_hda_codec_write(codec, idx + 0x0b, 0,
7104 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01007105 }
Kailang Yangdf694da2005-12-05 19:42:22 +01007106
Takashi Iwai6d86b4f2011-06-27 15:00:48 +02007107 mix = alc260_pin_to_vol_mix(nid);
7108 if (!mix)
Takashi Iwai1f0f4b82011-06-27 10:52:59 +02007109 return;
Takashi Iwai6d86b4f2011-06-27 15:00:48 +02007110 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai1f0f4b82011-06-27 10:52:59 +02007111 AMP_OUT_ZERO);
Takashi Iwai6d86b4f2011-06-27 15:00:48 +02007112 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
7113 AMP_IN_UNMUTE(0));
7114 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
7115 AMP_IN_UNMUTE(1));
Takashi Iwai1f0f4b82011-06-27 10:52:59 +02007116}
7117
Kailang Yangdf694da2005-12-05 19:42:22 +01007118static void alc260_auto_init_multi_out(struct hda_codec *codec)
7119{
7120 struct alc_spec *spec = codec->spec;
7121 hda_nid_t nid;
7122
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007123 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007124 if (nid) {
7125 int pin_type = get_pin_type(spec->autocfg.line_out_type);
7126 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
7127 }
Kailang Yangea1fb292008-08-26 12:58:38 +02007128
Takashi Iwai82bc9552006-03-21 11:24:42 +01007129 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007130 if (nid)
7131 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
7132
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007133 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007134 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007135 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007136}
Kailang Yangdf694da2005-12-05 19:42:22 +01007137
Kailang Yangdf694da2005-12-05 19:42:22 +01007138static int alc260_parse_auto_config(struct hda_codec *codec)
7139{
7140 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007141 int err;
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02007142 static const hda_nid_t alc260_ignore[] = { 0x17, 0 };
Kailang Yangdf694da2005-12-05 19:42:22 +01007143
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007144 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7145 alc260_ignore);
7146 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007147 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007148 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
7149 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01007150 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02007151 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01007152 return 0; /* can't find valid BIOS pin config */
Takashi Iwaib7821702011-07-06 15:12:46 +02007153 err = alc_auto_create_input_ctls(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007154 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007155 return err;
7156
7157 spec->multiout.max_channels = 2;
7158
Takashi Iwai0852d7a2009-02-11 11:35:15 +01007159 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007160 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02007161 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01007162 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01007163
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007164 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007165 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007166
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +02007167 if (!spec->dual_adc_switch)
7168 alc_remove_invalid_adc_nids(codec);
7169
Kailang Yang6227cdc2010-02-25 08:36:52 +01007170 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02007171
Kailang Yangdf694da2005-12-05 19:42:22 +01007172 return 1;
7173}
7174
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007175/* additional initialization for auto-configuration model */
7176static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007177{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007178 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007179 alc260_auto_init_multi_out(codec);
Takashi Iwai0a7f5322011-07-06 15:15:12 +02007180 alc_auto_init_analog_input(codec);
Takashi Iwaif970de22011-07-06 17:39:59 +02007181 alc_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02007182 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007183 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007184 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007185}
7186
Takashi Iwaicb53c622007-08-10 17:21:45 +02007187#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaia9111322011-05-02 11:30:18 +02007188static const struct hda_amp_list alc260_loopbacks[] = {
Takashi Iwaicb53c622007-08-10 17:21:45 +02007189 { 0x07, HDA_INPUT, 0 },
7190 { 0x07, HDA_INPUT, 1 },
7191 { 0x07, HDA_INPUT, 2 },
7192 { 0x07, HDA_INPUT, 3 },
7193 { 0x07, HDA_INPUT, 4 },
7194 { } /* end */
7195};
7196#endif
7197
Kailang Yangdf694da2005-12-05 19:42:22 +01007198/*
Takashi Iwaifc091762010-08-04 23:53:36 +02007199 * Pin config fixes
7200 */
7201enum {
7202 PINFIX_HP_DC5750,
7203};
7204
Takashi Iwaifc091762010-08-04 23:53:36 +02007205static const struct alc_fixup alc260_fixups[] = {
7206 [PINFIX_HP_DC5750] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007207 .type = ALC_FIXUP_PINS,
7208 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +02007209 { 0x11, 0x90130110 }, /* speaker */
7210 { }
7211 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007212 },
7213};
7214
Takashi Iwaia9111322011-05-02 11:30:18 +02007215static const struct snd_pci_quirk alc260_fixup_tbl[] = {
Takashi Iwaifc091762010-08-04 23:53:36 +02007216 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
7217 {}
7218};
7219
7220/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007221 * ALC260 configurations
7222 */
Takashi Iwaiea734962011-01-17 11:29:34 +01007223static const char * const alc260_models[ALC260_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007224 [ALC260_BASIC] = "basic",
7225 [ALC260_HP] = "hp",
7226 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02007227 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007228 [ALC260_FUJITSU_S702X] = "fujitsu",
7229 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007230 [ALC260_WILL] = "will",
7231 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01007232 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007233#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007234 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007235#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007236 [ALC260_AUTO] = "auto",
7237};
7238
Takashi Iwaia9111322011-05-02 11:30:18 +02007239static const struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01007240 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05007241 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007242 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01007243 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01007244 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01007245 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007246 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02007247 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02007248 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007249 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
7250 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
7251 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
7252 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
7253 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
7254 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
7255 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
7256 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
7257 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007258 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007259 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02007260 {}
7261};
7262
Takashi Iwaia9111322011-05-02 11:30:18 +02007263static const struct alc_config_preset alc260_presets[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007264 [ALC260_BASIC] = {
7265 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007266 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007267 .init_verbs = { alc260_init_verbs },
7268 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7269 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007270 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01007271 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007272 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7273 .channel_mode = alc260_modes,
7274 .input_mux = &alc260_capture_source,
7275 },
7276 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01007277 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007278 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007279 .init_verbs = { alc260_init_verbs,
7280 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007281 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7282 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007283 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7284 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007285 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7286 .channel_mode = alc260_modes,
7287 .input_mux = &alc260_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +02007288 .unsol_event = alc_sku_unsol_event,
7289 .setup = alc260_hp_setup,
7290 .init_hook = alc_inithook,
Kailang Yangdf694da2005-12-05 19:42:22 +01007291 },
Kailang Yang3f878302008-08-26 13:02:23 +02007292 [ALC260_HP_DC7600] = {
7293 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007294 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02007295 .init_verbs = { alc260_init_verbs,
7296 alc260_hp_dc7600_verbs },
7297 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7298 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007299 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7300 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02007301 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7302 .channel_mode = alc260_modes,
7303 .input_mux = &alc260_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +02007304 .unsol_event = alc_sku_unsol_event,
7305 .setup = alc260_hp_3012_setup,
7306 .init_hook = alc_inithook,
Kailang Yang3f878302008-08-26 13:02:23 +02007307 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007308 [ALC260_HP_3013] = {
7309 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007310 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007311 .init_verbs = { alc260_hp_3013_init_verbs,
7312 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007313 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7314 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007315 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7316 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007317 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7318 .channel_mode = alc260_modes,
7319 .input_mux = &alc260_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +02007320 .unsol_event = alc_sku_unsol_event,
7321 .setup = alc260_hp_3013_setup,
7322 .init_hook = alc_inithook,
Kailang Yangdf694da2005-12-05 19:42:22 +01007323 },
7324 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007325 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007326 .init_verbs = { alc260_fujitsu_init_verbs },
7327 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7328 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01007329 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7330 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007331 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7332 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007333 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
7334 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01007335 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007336 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007337 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007338 .init_verbs = { alc260_acer_init_verbs },
7339 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7340 .dac_nids = alc260_dac_nids,
7341 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7342 .adc_nids = alc260_dual_adc_nids,
7343 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7344 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007345 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
7346 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007347 },
Michael Schwingencc959482009-02-22 18:58:45 +01007348 [ALC260_FAVORIT100] = {
7349 .mixers = { alc260_favorit100_mixer },
7350 .init_verbs = { alc260_favorit100_init_verbs },
7351 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7352 .dac_nids = alc260_dac_nids,
7353 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7354 .adc_nids = alc260_dual_adc_nids,
7355 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7356 .channel_mode = alc260_modes,
7357 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
7358 .input_mux = alc260_favorit100_capture_sources,
7359 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007360 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007361 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007362 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
7363 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7364 .dac_nids = alc260_dac_nids,
7365 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7366 .adc_nids = alc260_adc_nids,
7367 .dig_out_nid = ALC260_DIGOUT_NID,
7368 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7369 .channel_mode = alc260_modes,
7370 .input_mux = &alc260_capture_source,
7371 },
7372 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007373 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007374 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
7375 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7376 .dac_nids = alc260_dac_nids,
7377 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7378 .adc_nids = alc260_adc_nids,
7379 .dig_out_nid = ALC260_DIGOUT_NID,
7380 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7381 .channel_mode = alc260_modes,
7382 .input_mux = &alc260_capture_source,
7383 .unsol_event = alc260_replacer_672v_unsol_event,
7384 .init_hook = alc260_replacer_672v_automute,
7385 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007386#ifdef CONFIG_SND_DEBUG
7387 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007388 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007389 .init_verbs = { alc260_test_init_verbs },
7390 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
7391 .dac_nids = alc260_test_dac_nids,
7392 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
7393 .adc_nids = alc260_test_adc_nids,
7394 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7395 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007396 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
7397 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007398 },
7399#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01007400};
7401
Linus Torvalds1da177e2005-04-16 15:20:36 -07007402static int patch_alc260(struct hda_codec *codec)
7403{
7404 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007405 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007406
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007407 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007408 if (spec == NULL)
7409 return -ENOMEM;
7410
7411 codec->spec = spec;
7412
Takashi Iwai1f0f4b82011-06-27 10:52:59 +02007413 spec->mixer_nid = 0x07;
7414
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007415 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
7416 alc260_models,
7417 alc260_cfg_tbl);
7418 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02007419 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02007420 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01007421 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02007422 }
7423
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007424 if (board_config == ALC260_AUTO) {
7425 alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups);
7426 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
7427 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007428
Kailang Yangdf694da2005-12-05 19:42:22 +01007429 if (board_config == ALC260_AUTO) {
7430 /* automatic parse from the BIOS config */
7431 err = alc260_parse_auto_config(codec);
7432 if (err < 0) {
7433 alc_free(codec);
7434 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007435 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007436 printk(KERN_INFO
7437 "hda_codec: Cannot set up configuration "
7438 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007439 board_config = ALC260_BASIC;
7440 }
Takashi Iwai16ded522005-06-10 19:58:24 +02007441 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007442
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007443 err = snd_hda_attach_beep_device(codec, 0x1);
7444 if (err < 0) {
7445 alc_free(codec);
7446 return err;
7447 }
7448
Kailang Yangdf694da2005-12-05 19:42:22 +01007449 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02007450 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007451
Linus Torvalds1da177e2005-04-16 15:20:36 -07007452 spec->stream_analog_playback = &alc260_pcm_analog_playback;
7453 spec->stream_analog_capture = &alc260_pcm_analog_capture;
Jonathan Woithe53bacfb2010-08-08 00:17:05 +09307454 spec->stream_analog_alt_capture = &alc260_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007455
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007456 spec->stream_digital_playback = &alc260_pcm_digital_playback;
7457 spec->stream_digital_capture = &alc260_pcm_digital_capture;
7458
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007459 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +02007460 alc_auto_fill_adc_caps(codec);
7461 alc_remove_invalid_adc_nids(codec);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007462 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02007463 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007464 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007465
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007466 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwaifc091762010-08-04 23:53:36 +02007467
Takashi Iwai2134ea42008-01-10 16:53:55 +01007468 spec->vmaster_nid = 0x08;
7469
Linus Torvalds1da177e2005-04-16 15:20:36 -07007470 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007471 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007472 spec->init_hook = alc260_auto_init;
Takashi Iwai1c7161532011-04-07 10:37:16 +02007473 spec->shutup = alc_eapd_shutup;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007474#ifdef CONFIG_SND_HDA_POWER_SAVE
7475 if (!spec->loopback.amplist)
7476 spec->loopback.amplist = alc260_loopbacks;
7477#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07007478
7479 return 0;
7480}
7481
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007482
Linus Torvalds1da177e2005-04-16 15:20:36 -07007483/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007484 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07007485 *
7486 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
7487 * configuration. Each pin widget can choose any input DACs and a mixer.
7488 * Each ADC is connected from a mixer of all inputs. This makes possible
7489 * 6-channel independent captures.
7490 *
7491 * In addition, an independent DAC for the multi-playback (not used in this
7492 * driver yet).
7493 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007494#define ALC882_DIGOUT_NID 0x06
7495#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02007496#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
7497#define ALC883_DIGIN_NID ALC882_DIGIN_NID
7498#define ALC1200_DIGOUT_NID 0x10
7499
Linus Torvalds1da177e2005-04-16 15:20:36 -07007500
Takashi Iwaia9111322011-05-02 11:30:18 +02007501static const struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007502 { 8, NULL }
7503};
7504
Takashi Iwai4953550a2009-06-30 15:28:30 +02007505/* DACs */
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02007506static const hda_nid_t alc882_dac_nids[4] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007507 /* front, rear, clfe, rear_surr */
7508 0x02, 0x03, 0x04, 0x05
7509};
Takashi Iwai4953550a2009-06-30 15:28:30 +02007510#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007511
Takashi Iwai4953550a2009-06-30 15:28:30 +02007512/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01007513#define alc882_adc_nids alc880_adc_nids
7514#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02007515#define alc883_adc_nids alc882_adc_nids_alt
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02007516static const hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
7517static const hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007518#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007519
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02007520static const hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
7521static const hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007522#define alc883_capsrc_nids alc882_capsrc_nids_alt
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02007523static const hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007524#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01007525
Linus Torvalds1da177e2005-04-16 15:20:36 -07007526/* input MUX */
7527/* FIXME: should be a matrix-type input source selection */
7528
Takashi Iwaia9111322011-05-02 11:30:18 +02007529static const struct hda_input_mux alc882_capture_source = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007530 .num_items = 4,
7531 .items = {
7532 { "Mic", 0x0 },
7533 { "Front Mic", 0x1 },
7534 { "Line", 0x2 },
7535 { "CD", 0x4 },
7536 },
7537};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007538
Takashi Iwai4953550a2009-06-30 15:28:30 +02007539#define alc883_capture_source alc882_capture_source
7540
Takashi Iwaia9111322011-05-02 11:30:18 +02007541static const struct hda_input_mux alc889_capture_source = {
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007542 .num_items = 3,
7543 .items = {
7544 { "Front Mic", 0x0 },
7545 { "Mic", 0x3 },
7546 { "Line", 0x2 },
7547 },
7548};
7549
Takashi Iwaia9111322011-05-02 11:30:18 +02007550static const struct hda_input_mux mb5_capture_source = {
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007551 .num_items = 3,
7552 .items = {
7553 { "Mic", 0x1 },
Alex Murrayb8f171e2010-06-14 12:08:43 +09307554 { "Line", 0x7 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007555 { "CD", 0x4 },
7556 },
7557};
7558
Takashi Iwaia9111322011-05-02 11:30:18 +02007559static const struct hda_input_mux macmini3_capture_source = {
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007560 .num_items = 2,
7561 .items = {
7562 { "Line", 0x2 },
7563 { "CD", 0x4 },
7564 },
7565};
7566
Takashi Iwaia9111322011-05-02 11:30:18 +02007567static const struct hda_input_mux alc883_3stack_6ch_intel = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02007568 .num_items = 4,
7569 .items = {
7570 { "Mic", 0x1 },
7571 { "Front Mic", 0x0 },
7572 { "Line", 0x2 },
7573 { "CD", 0x4 },
7574 },
7575};
7576
Takashi Iwaia9111322011-05-02 11:30:18 +02007577static const struct hda_input_mux alc883_lenovo_101e_capture_source = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02007578 .num_items = 2,
7579 .items = {
7580 { "Mic", 0x1 },
7581 { "Line", 0x2 },
7582 },
7583};
7584
Takashi Iwaia9111322011-05-02 11:30:18 +02007585static const struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02007586 .num_items = 4,
7587 .items = {
7588 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +01007589 { "Internal Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007590 { "Line", 0x2 },
7591 { "CD", 0x4 },
7592 },
7593};
7594
Takashi Iwaia9111322011-05-02 11:30:18 +02007595static const struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02007596 .num_items = 2,
7597 .items = {
7598 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +01007599 { "Internal Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007600 },
7601};
7602
Takashi Iwaia9111322011-05-02 11:30:18 +02007603static const struct hda_input_mux alc883_lenovo_sky_capture_source = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02007604 .num_items = 3,
7605 .items = {
7606 { "Mic", 0x0 },
7607 { "Front Mic", 0x1 },
7608 { "Line", 0x4 },
7609 },
7610};
7611
Takashi Iwaia9111322011-05-02 11:30:18 +02007612static const struct hda_input_mux alc883_asus_eee1601_capture_source = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02007613 .num_items = 2,
7614 .items = {
7615 { "Mic", 0x0 },
7616 { "Line", 0x2 },
7617 },
7618};
7619
Takashi Iwaia9111322011-05-02 11:30:18 +02007620static const struct hda_input_mux alc889A_mb31_capture_source = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02007621 .num_items = 2,
7622 .items = {
7623 { "Mic", 0x0 },
7624 /* Front Mic (0x01) unused */
7625 { "Line", 0x2 },
7626 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007627 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007628 },
7629};
7630
Takashi Iwaia9111322011-05-02 11:30:18 +02007631static const struct hda_input_mux alc889A_imac91_capture_source = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007632 .num_items = 2,
7633 .items = {
7634 { "Mic", 0x01 },
7635 { "Line", 0x2 }, /* Not sure! */
7636 },
7637};
7638
Takashi Iwai4953550a2009-06-30 15:28:30 +02007639/*
7640 * 2ch mode
7641 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007642static const struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02007643 { 2, NULL }
7644};
7645
Kailang Yangdf694da2005-12-05 19:42:22 +01007646/*
Kailang Yang272a5272007-05-14 11:00:38 +02007647 * 2ch mode
7648 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007649static const struct hda_verb alc882_3ST_ch2_init[] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007650 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7651 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7652 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7653 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7654 { } /* end */
7655};
7656
7657/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007658 * 4ch mode
7659 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007660static const struct hda_verb alc882_3ST_ch4_init[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02007661 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7662 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7663 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7664 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7665 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7666 { } /* end */
7667};
7668
7669/*
Kailang Yang272a5272007-05-14 11:00:38 +02007670 * 6ch mode
7671 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007672static const struct hda_verb alc882_3ST_ch6_init[] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007673 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7674 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7675 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7676 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7677 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7678 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7679 { } /* end */
7680};
7681
Takashi Iwaia9111322011-05-02 11:30:18 +02007682static const struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007683 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007684 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007685 { 6, alc882_3ST_ch6_init },
7686};
7687
Takashi Iwai4953550a2009-06-30 15:28:30 +02007688#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7689
Kailang Yang272a5272007-05-14 11:00:38 +02007690/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307691 * 2ch mode
7692 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007693static const struct hda_verb alc883_3ST_ch2_clevo_init[] = {
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307694 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7695 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7696 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7697 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7698 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7699 { } /* end */
7700};
7701
7702/*
7703 * 4ch mode
7704 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007705static const struct hda_verb alc883_3ST_ch4_clevo_init[] = {
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307706 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7707 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7708 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7709 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7710 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7711 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7712 { } /* end */
7713};
7714
7715/*
7716 * 6ch mode
7717 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007718static const struct hda_verb alc883_3ST_ch6_clevo_init[] = {
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307719 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7720 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7721 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7722 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7723 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7724 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7725 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7726 { } /* end */
7727};
7728
Takashi Iwaia9111322011-05-02 11:30:18 +02007729static const struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307730 { 2, alc883_3ST_ch2_clevo_init },
7731 { 4, alc883_3ST_ch4_clevo_init },
7732 { 6, alc883_3ST_ch6_clevo_init },
7733};
7734
7735
7736/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007737 * 6ch mode
7738 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007739static const struct hda_verb alc882_sixstack_ch6_init[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007740 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7741 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7742 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7743 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7744 { } /* end */
7745};
7746
7747/*
7748 * 8ch mode
7749 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007750static const struct hda_verb alc882_sixstack_ch8_init[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007751 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7752 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7753 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7754 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7755 { } /* end */
7756};
7757
Takashi Iwaia9111322011-05-02 11:30:18 +02007758static const struct hda_channel_mode alc882_sixstack_modes[2] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007759 { 6, alc882_sixstack_ch6_init },
7760 { 8, alc882_sixstack_ch8_init },
7761};
7762
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007763
7764/* Macbook Air 2,1 */
7765
Takashi Iwaia9111322011-05-02 11:30:18 +02007766static const struct hda_channel_mode alc885_mba21_ch_modes[1] = {
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007767 { 2, NULL },
7768};
7769
Takashi Iwai87350ad2007-08-16 18:19:38 +02007770/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007771 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007772 */
7773
7774/*
7775 * 2ch mode
7776 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007777static const struct hda_verb alc885_mbp_ch2_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007778 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7779 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7780 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7781 { } /* end */
7782};
7783
7784/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007785 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007786 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007787static const struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007788 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7789 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7790 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7791 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7792 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7793 { } /* end */
7794};
7795
Takashi Iwaia9111322011-05-02 11:30:18 +02007796static const struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007797 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007798 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007799};
7800
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007801/*
7802 * 2ch
7803 * Speakers/Woofer/HP = Front
7804 * LineIn = Input
7805 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007806static const struct hda_verb alc885_mb5_ch2_init[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007807 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7808 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7809 { } /* end */
7810};
7811
7812/*
7813 * 6ch mode
7814 * Speakers/HP = Front
7815 * Woofer = LFE
7816 * LineIn = Surround
7817 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007818static const struct hda_verb alc885_mb5_ch6_init[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007819 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7820 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7821 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7822 { } /* end */
7823};
7824
Takashi Iwaia9111322011-05-02 11:30:18 +02007825static const struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007826 { 2, alc885_mb5_ch2_init },
7827 { 6, alc885_mb5_ch6_init },
7828};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007829
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007830#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007831
7832/*
7833 * 2ch mode
7834 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007835static const struct hda_verb alc883_4ST_ch2_init[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02007836 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7837 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7838 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7839 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7840 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7841 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7842 { } /* end */
7843};
7844
7845/*
7846 * 4ch mode
7847 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007848static const struct hda_verb alc883_4ST_ch4_init[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02007849 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7850 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7851 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7852 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7853 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7854 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7855 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7856 { } /* end */
7857};
7858
7859/*
7860 * 6ch mode
7861 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007862static const struct hda_verb alc883_4ST_ch6_init[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02007863 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7864 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7865 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7866 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7867 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7868 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7869 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7870 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7871 { } /* end */
7872};
7873
7874/*
7875 * 8ch mode
7876 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007877static const struct hda_verb alc883_4ST_ch8_init[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02007878 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7879 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7880 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7881 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7882 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7883 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7884 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7885 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7886 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7887 { } /* end */
7888};
7889
Takashi Iwaia9111322011-05-02 11:30:18 +02007890static const struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02007891 { 2, alc883_4ST_ch2_init },
7892 { 4, alc883_4ST_ch4_init },
7893 { 6, alc883_4ST_ch6_init },
7894 { 8, alc883_4ST_ch8_init },
7895};
7896
7897
7898/*
7899 * 2ch mode
7900 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007901static const struct hda_verb alc883_3ST_ch2_intel_init[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02007902 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7903 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7904 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7905 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7906 { } /* end */
7907};
7908
7909/*
7910 * 4ch mode
7911 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007912static const struct hda_verb alc883_3ST_ch4_intel_init[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02007913 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7914 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7915 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7916 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7917 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7918 { } /* end */
7919};
7920
7921/*
7922 * 6ch mode
7923 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007924static const struct hda_verb alc883_3ST_ch6_intel_init[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02007925 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7926 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7927 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7928 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7929 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7930 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7931 { } /* end */
7932};
7933
Takashi Iwaia9111322011-05-02 11:30:18 +02007934static const struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02007935 { 2, alc883_3ST_ch2_intel_init },
7936 { 4, alc883_3ST_ch4_intel_init },
7937 { 6, alc883_3ST_ch6_intel_init },
7938};
7939
7940/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007941 * 2ch mode
7942 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007943static const struct hda_verb alc889_ch2_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007944 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7945 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7946 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7947 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7948 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7949 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7950 { } /* end */
7951};
7952
7953/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007954 * 6ch mode
7955 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007956static const struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007957 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7958 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7959 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7960 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7961 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007962 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7963 { } /* end */
7964};
7965
7966/*
7967 * 8ch mode
7968 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007969static const struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007970 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7971 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7972 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7973 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7974 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007975 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7976 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007977 { } /* end */
7978};
7979
Takashi Iwaia9111322011-05-02 11:30:18 +02007980static const struct hda_channel_mode alc889_8ch_intel_modes[3] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007981 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007982 { 6, alc889_ch6_intel_init },
7983 { 8, alc889_ch8_intel_init },
7984};
7985
7986/*
7987 * 6ch mode
7988 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007989static const struct hda_verb alc883_sixstack_ch6_init[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02007990 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7991 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7992 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7993 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7994 { } /* end */
7995};
7996
7997/*
7998 * 8ch mode
7999 */
Takashi Iwaia9111322011-05-02 11:30:18 +02008000static const struct hda_verb alc883_sixstack_ch8_init[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02008001 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8002 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8003 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8004 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8005 { } /* end */
8006};
8007
Takashi Iwaia9111322011-05-02 11:30:18 +02008008static const struct hda_channel_mode alc883_sixstack_modes[2] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02008009 { 6, alc883_sixstack_ch6_init },
8010 { 8, alc883_sixstack_ch8_init },
8011};
8012
8013
Linus Torvalds1da177e2005-04-16 15:20:36 -07008014/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
8015 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
8016 */
Takashi Iwaia9111322011-05-02 11:30:18 +02008017static const struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02008018 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01008019 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02008020 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01008021 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02008022 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8023 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01008024 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8025 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02008026 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01008027 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07008028 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8029 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8030 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8031 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8032 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8033 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008034 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07008035 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8036 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008037 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07008038 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07008039 { } /* end */
8040};
8041
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008042/* Macbook Air 2,1 same control for HP and internal Speaker */
8043
Takashi Iwaia9111322011-05-02 11:30:18 +02008044static const struct snd_kcontrol_new alc885_mba21_mixer[] = {
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008045 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8046 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
8047 { }
8048};
8049
8050
Takashi Iwaia9111322011-05-02 11:30:18 +02008051static const struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008052 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8053 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
8054 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
8055 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
8056 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01008057 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8058 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02008059 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8060 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008061 HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
8062 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02008063 { } /* end */
8064};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008065
Takashi Iwaia9111322011-05-02 11:30:18 +02008066static const struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008067 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8068 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8069 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8070 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8071 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
8072 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10308073 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
8074 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Alex Murrayb8f171e2010-06-14 12:08:43 +09308075 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
8076 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008077 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8078 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008079 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
8080 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0x00, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008081 { } /* end */
8082};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008083
Takashi Iwaia9111322011-05-02 11:30:18 +02008084static const struct snd_kcontrol_new alc885_macmini3_mixer[] = {
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008085 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8086 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8087 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8088 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8089 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
8090 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
8091 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
8092 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
8093 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
8094 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008095 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008096 { } /* end */
8097};
8098
Takashi Iwaia9111322011-05-02 11:30:18 +02008099static const struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008100 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8101 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008102 { } /* end */
8103};
8104
8105
Takashi Iwaia9111322011-05-02 11:30:18 +02008106static const struct snd_kcontrol_new alc882_w2jc_mixer[] = {
Kailang Yangbdd148a2007-05-08 15:19:08 +02008107 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8108 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8109 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8110 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8111 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8112 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8113 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008114 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02008115 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02008116 { } /* end */
8117};
8118
Takashi Iwaia9111322011-05-02 11:30:18 +02008119static const struct snd_kcontrol_new alc882_targa_mixer[] = {
Kailang Yang272a5272007-05-14 11:00:38 +02008120 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8121 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8122 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8123 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8124 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8125 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8126 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8127 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8128 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008129 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008130 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8131 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008132 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008133 { } /* end */
8134};
8135
8136/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
8137 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
8138 */
Takashi Iwaia9111322011-05-02 11:30:18 +02008139static const struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
Kailang Yang272a5272007-05-14 11:00:38 +02008140 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8141 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8142 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8143 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
8144 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8145 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8146 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8147 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8148 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
8149 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
8150 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8151 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008152 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008153 { } /* end */
8154};
8155
Takashi Iwaia9111322011-05-02 11:30:18 +02008156static const struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
Takashi Iwai914759b2007-09-06 14:52:04 +02008157 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8158 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8159 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8160 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8161 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8162 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8163 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8164 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008165 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008166 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008167 { } /* end */
8168};
8169
Takashi Iwaia9111322011-05-02 11:30:18 +02008170static const struct snd_kcontrol_new alc882_chmode_mixer[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008171 {
8172 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8173 .name = "Channel Mode",
8174 .info = alc_ch_mode_info,
8175 .get = alc_ch_mode_get,
8176 .put = alc_ch_mode_put,
8177 },
8178 { } /* end */
8179};
8180
Takashi Iwaia9111322011-05-02 11:30:18 +02008181static const struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07008182 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008183 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8184 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008185 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008186 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8187 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008188 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008189 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8190 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008191 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008192 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8193 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008194
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008195 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008196 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008197 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008198 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008199 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008200 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008201 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008202 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008203 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008204 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008205 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008206 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008207 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008208 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008209 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008210 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008211 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008212 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008213 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8214 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008215 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008216 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8217 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008218 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008219 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8220 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8221 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8222 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8223 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008224 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008225 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008226
8227 /* FIXME: use matrix-type input source selection */
8228 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008229 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008230 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008231 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008232 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02008233 /* ADC2: mute amp left and right */
8234 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008235 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02008236 /* ADC3: mute amp left and right */
8237 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008238 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008239
8240 { }
8241};
8242
Takashi Iwaia9111322011-05-02 11:30:18 +02008243static const struct hda_verb alc882_adc1_init_verbs[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02008244 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8245 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8246 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8247 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8248 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8249 /* ADC1: mute amp left and right */
8250 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8251 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8252 { }
8253};
8254
Takashi Iwaia9111322011-05-02 11:30:18 +02008255static const struct hda_verb alc882_eapd_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008256 /* change to EAPD mode */
8257 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008258 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008259 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008260};
8261
Takashi Iwaia9111322011-05-02 11:30:18 +02008262static const struct hda_verb alc889_eapd_verbs[] = {
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008263 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8264 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8265 { }
8266};
8267
Takashi Iwaia9111322011-05-02 11:30:18 +02008268static const struct hda_verb alc_hp15_unsol_verbs[] = {
Wu Fengguang6732bd02009-07-30 09:19:14 +02008269 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8270 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8271 {}
8272};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008273
Takashi Iwaia9111322011-05-02 11:30:18 +02008274static const struct hda_verb alc885_init_verbs[] = {
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008275 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01008276 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8277 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008278 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008279 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8280 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008281 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008282 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8283 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008284 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008285 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8286 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008287
8288 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02008289 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008290 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8291 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8292 /* Front Pin: output 0 (0x0c) */
8293 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8294 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8295 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8296 /* Rear Pin: output 1 (0x0d) */
8297 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8298 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8299 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
8300 /* CLFE Pin: output 2 (0x0e) */
8301 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8302 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8303 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8304 /* Side Pin: output 3 (0x0f) */
8305 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8306 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8307 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8308 /* Mic (rear) pin: input vref at 80% */
8309 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8310 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8311 /* Front Mic pin: input vref at 80% */
8312 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8313 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8314 /* Line In pin: input */
8315 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8316 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8317
8318 /* Mixer elements: 0x18, , 0x1a, 0x1b */
8319 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01008320 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008321 /* Input mixer2 */
8322 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008323 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008324 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008325 /* ADC2: mute amp left and right */
8326 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8327 /* ADC3: mute amp left and right */
8328 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8329
8330 { }
8331};
8332
Takashi Iwaia9111322011-05-02 11:30:18 +02008333static const struct hda_verb alc885_init_input_verbs[] = {
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008334 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8335 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8336 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8337 { }
8338};
8339
8340
8341/* Unmute Selector 24h and set the default input to front mic */
Takashi Iwaia9111322011-05-02 11:30:18 +02008342static const struct hda_verb alc889_init_input_verbs[] = {
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008343 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
8344 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8345 { }
8346};
8347
8348
Takashi Iwai4953550a2009-06-30 15:28:30 +02008349#define alc883_init_verbs alc882_base_init_verbs
8350
Tobin Davis9102cd12006-12-15 10:02:12 +01008351/* Mac Pro test */
Takashi Iwaia9111322011-05-02 11:30:18 +02008352static const struct snd_kcontrol_new alc882_macpro_mixer[] = {
Tobin Davis9102cd12006-12-15 10:02:12 +01008353 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8354 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8355 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
8356 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8357 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008358 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01008359 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
8360 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008361 */
Tobin Davis9102cd12006-12-15 10:02:12 +01008362 { } /* end */
8363};
8364
Takashi Iwaia9111322011-05-02 11:30:18 +02008365static const struct hda_verb alc882_macpro_init_verbs[] = {
Tobin Davis9102cd12006-12-15 10:02:12 +01008366 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8367 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8368 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8369 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8370 /* Front Pin: output 0 (0x0c) */
8371 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8372 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8373 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8374 /* Front Mic pin: input vref at 80% */
8375 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8376 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8377 /* Speaker: output */
8378 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8379 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8380 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
8381 /* Headphone output (output 0 - 0x0c) */
8382 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8383 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8384 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8385
8386 /* FIXME: use matrix-type input source selection */
8387 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8388 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8389 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8390 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8391 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8392 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8393 /* Input mixer2 */
8394 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8395 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8396 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8397 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8398 /* Input mixer3 */
8399 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8400 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8401 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8402 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8403 /* ADC1: mute amp left and right */
8404 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8405 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8406 /* ADC2: mute amp left and right */
8407 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8408 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8409 /* ADC3: mute amp left and right */
8410 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8411 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8412
8413 { }
8414};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008415
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008416/* Macbook 5,1 */
Takashi Iwaia9111322011-05-02 11:30:18 +02008417static const struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008418 /* DACs */
8419 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8420 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8421 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8422 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008423 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008424 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8425 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8426 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008427 /* Surround mixer */
8428 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8429 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8430 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8431 /* LFE mixer */
8432 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8433 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8434 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8435 /* HP mixer */
8436 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8437 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8438 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8439 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008440 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8441 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008442 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8443 /* LFE Pin (0x0e) */
8444 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8445 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8446 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8447 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008448 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8449 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008450 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10308451 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008452 /* Front Mic pin: input vref at 80% */
8453 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8454 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8455 /* Line In pin */
8456 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8457 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8458
Alex Murrayb8f171e2010-06-14 12:08:43 +09308459 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
8460 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
8461 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008462 { }
8463};
8464
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008465/* Macmini 3,1 */
Takashi Iwaia9111322011-05-02 11:30:18 +02008466static const struct hda_verb alc885_macmini3_init_verbs[] = {
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008467 /* DACs */
8468 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8469 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8470 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8471 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8472 /* Front mixer */
8473 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8474 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8475 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8476 /* Surround mixer */
8477 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8478 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8479 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8480 /* LFE mixer */
8481 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8482 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8483 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8484 /* HP mixer */
8485 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8486 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8487 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8488 /* Front Pin (0x0c) */
8489 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8490 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8491 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8492 /* LFE Pin (0x0e) */
8493 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8494 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8495 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8496 /* HP Pin (0x0f) */
8497 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8498 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8499 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
8500 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8501 /* Line In pin */
8502 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8503 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8504
8505 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8506 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8507 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8508 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8509 { }
8510};
8511
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008512
Takashi Iwaia9111322011-05-02 11:30:18 +02008513static const struct hda_verb alc885_mba21_init_verbs[] = {
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008514 /*Internal and HP Speaker Mixer*/
8515 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8516 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8517 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8518 /*Internal Speaker Pin (0x0c)*/
8519 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8520 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8521 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8522 /* HP Pin: output 0 (0x0e) */
8523 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
8524 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8525 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8526 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8527 /* Line in (is hp when jack connected)*/
8528 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8529 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8530
8531 { }
8532 };
8533
8534
Takashi Iwai87350ad2007-08-16 18:19:38 +02008535/* Macbook Pro rev3 */
Takashi Iwaia9111322011-05-02 11:30:18 +02008536static const struct hda_verb alc885_mbp3_init_verbs[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02008537 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8538 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8539 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8540 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8541 /* Rear mixer */
8542 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8543 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8544 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008545 /* HP mixer */
8546 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8547 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8548 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008549 /* Front Pin: output 0 (0x0c) */
8550 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8551 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8552 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008553 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02008554 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008555 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8556 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008557 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8558 /* Mic (rear) pin: input vref at 80% */
8559 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8560 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8561 /* Front Mic pin: input vref at 80% */
8562 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8563 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8564 /* Line In pin: use output 1 when in LineOut mode */
8565 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8566 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8567 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8568
8569 /* FIXME: use matrix-type input source selection */
8570 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8571 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8572 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8573 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8574 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8575 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8576 /* Input mixer2 */
8577 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8578 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8579 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8580 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8581 /* Input mixer3 */
8582 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8583 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8584 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8585 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8586 /* ADC1: mute amp left and right */
8587 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8588 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8589 /* ADC2: mute amp left and right */
8590 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8591 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8592 /* ADC3: mute amp left and right */
8593 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8594 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8595
8596 { }
8597};
8598
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008599/* iMac 9,1 */
Takashi Iwaia9111322011-05-02 11:30:18 +02008600static const struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008601 /* Internal Speaker Pin (0x0c) */
8602 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8603 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8604 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8605 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8606 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8607 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8608 /* HP Pin: Rear */
8609 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8610 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8611 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8612 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8613 /* Line in Rear */
8614 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8615 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8616 /* Front Mic pin: input vref at 80% */
8617 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8618 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008619 /* Rear mixer */
8620 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8621 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8622 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008623 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8624 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8625 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8626 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8627 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008628 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8629 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8630 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8631 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008632 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008633 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8634 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8635 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8636 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008637 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008638 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8639 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8640 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8641 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008642 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008643 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8644 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008645 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008646 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8647 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008648 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008649 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8650 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008651 { }
8652};
8653
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008654/* iMac 24 mixer. */
Takashi Iwaia9111322011-05-02 11:30:18 +02008655static const struct snd_kcontrol_new alc885_imac24_mixer[] = {
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008656 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8657 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8658 { } /* end */
8659};
8660
8661/* iMac 24 init verbs. */
Takashi Iwaia9111322011-05-02 11:30:18 +02008662static const struct hda_verb alc885_imac24_init_verbs[] = {
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008663 /* Internal speakers: output 0 (0x0c) */
8664 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8665 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8666 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8667 /* Internal speakers: output 0 (0x0c) */
8668 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8669 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8670 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8671 /* Headphone: output 0 (0x0c) */
8672 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8673 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8674 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8675 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8676 /* Front Mic: input vref at 80% */
8677 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8678 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8679 { }
8680};
8681
8682/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008683static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008684{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008685 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008686
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008687 spec->autocfg.hp_pins[0] = 0x14;
8688 spec->autocfg.speaker_pins[0] = 0x18;
8689 spec->autocfg.speaker_pins[1] = 0x1a;
Takashi Iwaid922b512011-04-28 12:18:53 +02008690 spec->automute = 1;
8691 spec->automute_mode = ALC_AUTOMUTE_AMP;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008692}
8693
Takashi Iwai9d54f082010-02-22 08:34:40 +01008694#define alc885_mb5_setup alc885_imac24_setup
8695#define alc885_macmini3_setup alc885_imac24_setup
8696
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008697/* Macbook Air 2,1 */
8698static void alc885_mba21_setup(struct hda_codec *codec)
8699{
8700 struct alc_spec *spec = codec->spec;
8701
8702 spec->autocfg.hp_pins[0] = 0x14;
8703 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwaid922b512011-04-28 12:18:53 +02008704 spec->automute = 1;
8705 spec->automute_mode = ALC_AUTOMUTE_AMP;
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008706}
8707
8708
8709
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008710static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008711{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008712 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008713
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008714 spec->autocfg.hp_pins[0] = 0x15;
8715 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +02008716 spec->automute = 1;
8717 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008718}
8719
Takashi Iwai9d54f082010-02-22 08:34:40 +01008720static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308721{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008722 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308723
Takashi Iwai9d54f082010-02-22 08:34:40 +01008724 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008725 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008726 spec->autocfg.speaker_pins[1] = 0x1a;
Takashi Iwaid922b512011-04-28 12:18:53 +02008727 spec->automute = 1;
8728 spec->automute_mode = ALC_AUTOMUTE_AMP;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008729}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008730
Takashi Iwaia9111322011-05-02 11:30:18 +02008731static const struct hda_verb alc882_targa_verbs[] = {
Kailang Yang272a5272007-05-14 11:00:38 +02008732 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8733 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8734
8735 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8736 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008737
Kailang Yang272a5272007-05-14 11:00:38 +02008738 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8739 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8740 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8741
8742 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008743 { } /* end */
8744};
8745
8746/* toggle speaker-output according to the hp-jack state */
8747static void alc882_targa_automute(struct hda_codec *codec)
8748{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008749 struct alc_spec *spec = codec->spec;
Takashi Iwaid922b512011-04-28 12:18:53 +02008750 alc_hp_automute(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008751 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008752 spec->jack_present ? 1 : 3);
8753}
8754
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008755static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008756{
8757 struct alc_spec *spec = codec->spec;
8758
8759 spec->autocfg.hp_pins[0] = 0x14;
8760 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaid922b512011-04-28 12:18:53 +02008761 spec->automute = 1;
8762 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yang272a5272007-05-14 11:00:38 +02008763}
8764
8765static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8766{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008767 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008768 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008769}
8770
Takashi Iwaia9111322011-05-02 11:30:18 +02008771static const struct hda_verb alc882_asus_a7j_verbs[] = {
Kailang Yang272a5272007-05-14 11:00:38 +02008772 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8773 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8774
8775 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8776 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8777 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008778
Kailang Yang272a5272007-05-14 11:00:38 +02008779 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8780 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8781 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8782
8783 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8784 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8785 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8786 { } /* end */
8787};
8788
Takashi Iwaia9111322011-05-02 11:30:18 +02008789static const struct hda_verb alc882_asus_a7m_verbs[] = {
Takashi Iwai914759b2007-09-06 14:52:04 +02008790 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8791 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8792
8793 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8794 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8795 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008796
Takashi Iwai914759b2007-09-06 14:52:04 +02008797 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8798 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8799 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8800
8801 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8802 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8803 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8804 { } /* end */
8805};
8806
Tobin Davis9102cd12006-12-15 10:02:12 +01008807static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8808{
8809 unsigned int gpiostate, gpiomask, gpiodir;
8810
8811 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8812 AC_VERB_GET_GPIO_DATA, 0);
8813
8814 if (!muted)
8815 gpiostate |= (1 << pin);
8816 else
8817 gpiostate &= ~(1 << pin);
8818
8819 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8820 AC_VERB_GET_GPIO_MASK, 0);
8821 gpiomask |= (1 << pin);
8822
8823 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8824 AC_VERB_GET_GPIO_DIRECTION, 0);
8825 gpiodir |= (1 << pin);
8826
8827
8828 snd_hda_codec_write(codec, codec->afg, 0,
8829 AC_VERB_SET_GPIO_MASK, gpiomask);
8830 snd_hda_codec_write(codec, codec->afg, 0,
8831 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8832
8833 msleep(1);
8834
8835 snd_hda_codec_write(codec, codec->afg, 0,
8836 AC_VERB_SET_GPIO_DATA, gpiostate);
8837}
8838
Takashi Iwai7debbe52007-08-16 15:01:03 +02008839/* set up GPIO at initialization */
8840static void alc885_macpro_init_hook(struct hda_codec *codec)
8841{
8842 alc882_gpio_mute(codec, 0, 0);
8843 alc882_gpio_mute(codec, 1, 0);
8844}
8845
8846/* set up GPIO and update auto-muting at initialization */
8847static void alc885_imac24_init_hook(struct hda_codec *codec)
8848{
8849 alc885_macpro_init_hook(codec);
Takashi Iwaid922b512011-04-28 12:18:53 +02008850 alc_hp_automute(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008851}
8852
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008853/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
Takashi Iwaia9111322011-05-02 11:30:18 +02008854static const struct hda_verb alc889A_mb31_ch2_init[] = {
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008855 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8856 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8857 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8858 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8859 { } /* end */
8860};
8861
8862/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
Takashi Iwaia9111322011-05-02 11:30:18 +02008863static const struct hda_verb alc889A_mb31_ch4_init[] = {
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008864 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8865 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8866 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8867 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8868 { } /* end */
8869};
8870
8871/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
Takashi Iwaia9111322011-05-02 11:30:18 +02008872static const struct hda_verb alc889A_mb31_ch5_init[] = {
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008873 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8874 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8875 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8876 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8877 { } /* end */
8878};
8879
8880/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
Takashi Iwaia9111322011-05-02 11:30:18 +02008881static const struct hda_verb alc889A_mb31_ch6_init[] = {
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008882 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8883 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8884 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8885 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8886 { } /* end */
8887};
8888
Takashi Iwaia9111322011-05-02 11:30:18 +02008889static const struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008890 { 2, alc889A_mb31_ch2_init },
8891 { 4, alc889A_mb31_ch4_init },
8892 { 5, alc889A_mb31_ch5_init },
8893 { 6, alc889A_mb31_ch6_init },
8894};
8895
Takashi Iwaia9111322011-05-02 11:30:18 +02008896static const struct hda_verb alc883_medion_eapd_verbs[] = {
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008897 /* eanable EAPD on medion laptop */
8898 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8899 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8900 { }
8901};
8902
Takashi Iwai4953550a2009-06-30 15:28:30 +02008903#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008904
Takashi Iwaia9111322011-05-02 11:30:18 +02008905static const struct snd_kcontrol_new alc883_mitac_mixer[] = {
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008906 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8907 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8908 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8909 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8910 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8911 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8912 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8913 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008914 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008915 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8916 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008917 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008918 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008919 { } /* end */
8920};
8921
Takashi Iwaia9111322011-05-02 11:30:18 +02008922static const struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008923 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8924 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8925 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8926 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8927 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008928 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008929 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008930 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008931 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008932 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008933 { } /* end */
8934};
8935
Takashi Iwaia9111322011-05-02 11:30:18 +02008936static const struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
Jiang zhefb97dc62008-03-06 11:07:11 +01008937 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8938 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8939 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8940 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8941 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008942 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008943 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008944 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008945 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008946 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008947 { } /* end */
8948};
8949
Takashi Iwaia9111322011-05-02 11:30:18 +02008950static const struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008951 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8952 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8953 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8954 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8955 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8956 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8957 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8958 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008959 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008960 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8961 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008962 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008963 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008964 { } /* end */
8965};
8966
Takashi Iwaia9111322011-05-02 11:30:18 +02008967static const struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008968 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8969 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8970 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8971 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8972 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8973 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8974 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8975 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8976 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8977 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8978 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8979 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8980 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, 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),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008983 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8984 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008985 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008986 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008987 { } /* end */
8988};
8989
Takashi Iwaia9111322011-05-02 11:30:18 +02008990static const struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
Jiang zhe17bba1b2008-06-04 12:11:07 +02008991 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8992 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8993 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8994 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8995 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8996 HDA_OUTPUT),
8997 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8998 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8999 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9000 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9001 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9002 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9003 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9004 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9005 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009006 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02009007 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9008 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009009 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02009010 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02009011 { } /* end */
9012};
9013
Takashi Iwaia9111322011-05-02 11:30:18 +02009014static const struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009015 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9016 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9017 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9018 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9019 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
9020 HDA_OUTPUT),
9021 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9022 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9023 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9024 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9025 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
9026 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9027 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9028 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9029 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009030 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1b, 0, HDA_INPUT),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009031 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
9032 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009033 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009034 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9035 { } /* end */
9036};
9037
Takashi Iwaia9111322011-05-02 11:30:18 +02009038static const struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02009039 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02009040 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009041 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02009042 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009043 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9044 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02009045 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9046 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009047 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9048 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9049 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9050 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9051 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9052 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009053 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009054 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9055 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009056 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009057 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009058 { } /* end */
9059};
9060
Takashi Iwaia9111322011-05-02 11:30:18 +02009061static const struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009062 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009063 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009064 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009065 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009066 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9067 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9068 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9069 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9070 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9071 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9072 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9073 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9074 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9075 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9076 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009077 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009078 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009079 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009080};
Kailang Yangccc656c2006-10-17 12:32:26 +02009081
Takashi Iwaia9111322011-05-02 11:30:18 +02009082static const struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009083 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009084 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009085 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009086 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009087 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9088 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9089 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009090 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009091 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009092 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009093 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009094 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009095 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009096};
Kailang Yangccc656c2006-10-17 12:32:26 +02009097
Takashi Iwaia9111322011-05-02 11:30:18 +02009098static const struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +02009099 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9100 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009101 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009102 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009103 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009104 { } /* end */
9105};
9106
Takashi Iwaia9111322011-05-02 11:30:18 +02009107static const struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009108 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9109 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009110 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9111 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009112 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9113 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009114 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009115 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009116 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009117};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009118
Takashi Iwaia9111322011-05-02 11:30:18 +02009119static const struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
Kailang Yang272a5272007-05-14 11:00:38 +02009120 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9121 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
9122 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9123 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9124 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9125 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9126 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009127 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9128 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02009129 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02009130};
Kailang Yang272a5272007-05-14 11:00:38 +02009131
Takashi Iwaia9111322011-05-02 11:30:18 +02009132static const struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009133 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9134 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9135 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9136 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
9137 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
9138 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
9139 { } /* end */
9140};
9141
Takashi Iwaia9111322011-05-02 11:30:18 +02009142static const struct hda_verb alc883_medion_wim2160_verbs[] = {
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009143 /* Unmute front mixer */
9144 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9145 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9146
9147 /* Set speaker pin to front mixer */
9148 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9149
9150 /* Init headphone pin */
9151 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9152 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9153 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9154 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9155
9156 { } /* end */
9157};
9158
9159/* toggle speaker-output according to the hp-jack state */
9160static void alc883_medion_wim2160_setup(struct hda_codec *codec)
9161{
9162 struct alc_spec *spec = codec->spec;
9163
9164 spec->autocfg.hp_pins[0] = 0x1a;
9165 spec->autocfg.speaker_pins[0] = 0x15;
Takashi Iwaid922b512011-04-28 12:18:53 +02009166 spec->automute = 1;
9167 spec->automute_mode = ALC_AUTOMUTE_AMP;
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009168}
9169
Takashi Iwaia9111322011-05-02 11:30:18 +02009170static const struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02009171 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9172 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009173 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009174 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9175 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009176 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009177 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009178 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009179 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02009180};
Tobin Davis2880a862007-08-07 11:50:26 +02009181
Takashi Iwaia9111322011-05-02 11:30:18 +02009182static const struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
Tony Vroond2fd4b02009-06-21 00:40:10 +01009183 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009184 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01009185 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9186 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009187 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9188 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9189 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009190 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009191 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9192 { } /* end */
9193};
9194
Takashi Iwaia9111322011-05-02 11:30:18 +02009195static const struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009196 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9197 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9198 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9199 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
9200 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
9201 0x0d, 1, 0x0, HDA_OUTPUT),
9202 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
9203 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
9204 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
9205 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9206 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009207 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9208 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9209 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9210 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9211 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009212 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009213 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9214 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009215 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009216 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009217 { } /* end */
9218};
9219
Takashi Iwaia9111322011-05-02 11:30:18 +02009220static const struct snd_kcontrol_new alc889A_mb31_mixer[] = {
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009221 /* Output mixers */
9222 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
9223 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
9224 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
9225 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
9226 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
9227 HDA_OUTPUT),
9228 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
9229 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
9230 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
9231 /* Output switches */
9232 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
9233 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
9234 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
9235 /* Boost mixers */
David Henningsson5f99f862011-01-04 15:24:24 +01009236 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
9237 HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009238 /* Input mixers */
9239 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
9240 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
9241 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9242 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9243 { } /* end */
9244};
9245
Takashi Iwaia9111322011-05-02 11:30:18 +02009246static const struct snd_kcontrol_new alc883_vaiott_mixer[] = {
Guido Günther3e1647c2009-06-05 00:47:26 +02009247 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9248 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9249 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9250 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009251 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
Guido Günther3e1647c2009-06-05 00:47:26 +02009252 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9253 { } /* end */
9254};
9255
Takashi Iwaia9111322011-05-02 11:30:18 +02009256static const struct hda_bind_ctls alc883_bind_cap_vol = {
Kailang Yange2757d52008-08-26 13:17:46 +02009257 .ops = &snd_hda_bind_vol,
9258 .values = {
9259 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9260 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9261 0
9262 },
9263};
9264
Takashi Iwaia9111322011-05-02 11:30:18 +02009265static const struct hda_bind_ctls alc883_bind_cap_switch = {
Kailang Yange2757d52008-08-26 13:17:46 +02009266 .ops = &snd_hda_bind_sw,
9267 .values = {
9268 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9269 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9270 0
9271 },
9272};
9273
Takashi Iwaia9111322011-05-02 11:30:18 +02009274static const struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009275 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9276 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9277 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9278 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9279 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9280 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009281 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009282 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009283 { } /* end */
9284};
9285
Takashi Iwaia9111322011-05-02 11:30:18 +02009286static const struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009287 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
9288 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
9289 {
9290 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9291 /* .name = "Capture Source", */
9292 .name = "Input Source",
9293 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009294 .info = alc_mux_enum_info,
9295 .get = alc_mux_enum_get,
9296 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02009297 },
9298 { } /* end */
9299};
9300
Takashi Iwaia9111322011-05-02 11:30:18 +02009301static const struct snd_kcontrol_new alc883_chmode_mixer[] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009302 {
9303 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9304 .name = "Channel Mode",
9305 .info = alc_ch_mode_info,
9306 .get = alc_ch_mode_get,
9307 .put = alc_ch_mode_put,
9308 },
9309 { } /* end */
9310};
9311
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009312/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009313static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009314{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009315 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009316
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009317 spec->autocfg.hp_pins[0] = 0x15;
9318 spec->autocfg.speaker_pins[0] = 0x14;
9319 spec->autocfg.speaker_pins[1] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02009320 spec->automute = 1;
9321 spec->automute_mode = ALC_AUTOMUTE_AMP;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009322}
9323
Takashi Iwaia9111322011-05-02 11:30:18 +02009324static const struct hda_verb alc883_mitac_verbs[] = {
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009325 /* HP */
9326 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9327 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9328 /* Subwoofer */
9329 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9330 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9331
9332 /* enable unsolicited event */
9333 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9334 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
9335
9336 { } /* end */
9337};
9338
Takashi Iwaia9111322011-05-02 11:30:18 +02009339static const struct hda_verb alc883_clevo_m540r_verbs[] = {
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309340 /* HP */
9341 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9342 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9343 /* Int speaker */
9344 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
9345
9346 /* enable unsolicited event */
9347 /*
9348 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9349 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9350 */
9351
9352 { } /* end */
9353};
9354
Takashi Iwaia9111322011-05-02 11:30:18 +02009355static const struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009356 /* HP */
9357 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9358 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9359 /* Int speaker */
9360 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
9361 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9362
9363 /* enable unsolicited event */
9364 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009365 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01009366
9367 { } /* end */
9368};
9369
Takashi Iwaia9111322011-05-02 11:30:18 +02009370static const struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
Jiang zhefb97dc62008-03-06 11:07:11 +01009371 /* HP */
9372 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9373 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9374 /* Subwoofer */
9375 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9376 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9377
9378 /* enable unsolicited event */
9379 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9380
9381 { } /* end */
9382};
9383
Takashi Iwaia9111322011-05-02 11:30:18 +02009384static const struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009385 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9386 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9387
9388 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9389 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02009390
David Heidelberger64a8be72009-06-08 16:15:18 +02009391/* Connect Line-Out side jack (SPDIF) to Side */
9392 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9393 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9394 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9395/* Connect Mic jack to CLFE */
9396 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9397 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9398 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
9399/* Connect Line-in jack to Surround */
9400 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9401 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9402 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
9403/* Connect HP out jack to Front */
9404 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9405 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9406 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02009407
9408 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02009409
9410 { } /* end */
9411};
9412
Takashi Iwaia9111322011-05-02 11:30:18 +02009413static const struct hda_verb alc883_lenovo_101e_verbs[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009414 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9415 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
9416 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
9417 { } /* end */
9418};
9419
Takashi Iwaia9111322011-05-02 11:30:18 +02009420static const struct hda_verb alc883_lenovo_nb0763_verbs[] = {
Kailang Yang272a5272007-05-14 11:00:38 +02009421 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9422 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9423 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9424 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9425 { } /* end */
9426};
9427
Takashi Iwaia9111322011-05-02 11:30:18 +02009428static const struct hda_verb alc888_lenovo_ms7195_verbs[] = {
Kailang Yang272a5272007-05-14 11:00:38 +02009429 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9430 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9431 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9432 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
9433 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9434 { } /* end */
9435};
9436
Takashi Iwaia9111322011-05-02 11:30:18 +02009437static const struct hda_verb alc883_haier_w66_verbs[] = {
Kailang Yang189609a2007-08-20 11:31:23 +02009438 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9439 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9440
9441 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9442
9443 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9444 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9445 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9446 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9447 { } /* end */
9448};
9449
Takashi Iwaia9111322011-05-02 11:30:18 +02009450static const struct hda_verb alc888_lenovo_sky_verbs[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009451 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9452 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9453 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9454 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9455 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9456 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9457 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9458 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9459 { } /* end */
9460};
9461
Takashi Iwaia9111322011-05-02 11:30:18 +02009462static const struct hda_verb alc888_6st_dell_verbs[] = {
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009463 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9464 { }
9465};
9466
Takashi Iwaia9111322011-05-02 11:30:18 +02009467static const struct hda_verb alc883_vaiott_verbs[] = {
Guido Günther3e1647c2009-06-05 00:47:26 +02009468 /* HP */
9469 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9470 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9471
9472 /* enable unsolicited event */
9473 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9474
9475 { } /* end */
9476};
9477
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009478static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009479{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009480 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009481
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009482 spec->autocfg.hp_pins[0] = 0x1b;
9483 spec->autocfg.speaker_pins[0] = 0x14;
9484 spec->autocfg.speaker_pins[1] = 0x16;
9485 spec->autocfg.speaker_pins[2] = 0x18;
Takashi Iwaid922b512011-04-28 12:18:53 +02009486 spec->automute = 1;
9487 spec->automute_mode = ALC_AUTOMUTE_AMP;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009488}
9489
Takashi Iwaia9111322011-05-02 11:30:18 +02009490static const struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009491 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01009492 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
9493 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009494 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009495 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009496};
9497
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009498/*
9499 * 2ch mode
9500 */
Takashi Iwaia9111322011-05-02 11:30:18 +02009501static const struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009502 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9503 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9504 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9505 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009506 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009507};
9508
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009509/*
9510 * 4ch mode
9511 */
Takashi Iwaia9111322011-05-02 11:30:18 +02009512static const struct hda_verb alc888_3st_hp_4ch_init[] = {
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009513 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9514 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9515 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9516 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9517 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9518 { } /* end */
9519};
9520
9521/*
9522 * 6ch mode
9523 */
Takashi Iwaia9111322011-05-02 11:30:18 +02009524static const struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009525 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9526 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009527 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009528 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9529 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009530 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9531 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009532};
9533
Takashi Iwaia9111322011-05-02 11:30:18 +02009534static const struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009535 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009536 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009537 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009538};
9539
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02009540static void alc888_lenovo_ms7195_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009541{
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02009542 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009543
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02009544 spec->autocfg.hp_pins[0] = 0x1b;
9545 spec->autocfg.line_out_pins[0] = 0x14;
9546 spec->autocfg.speaker_pins[0] = 0x15;
9547 spec->automute = 1;
9548 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yang272a5272007-05-14 11:00:38 +02009549}
9550
Kailang Yang272a5272007-05-14 11:00:38 +02009551/* toggle speaker-output according to the hp-jack state */
Takashi Iwaidc4271702010-11-29 07:42:59 +01009552static void alc883_lenovo_nb0763_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009553{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009554 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009555
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009556 spec->autocfg.hp_pins[0] = 0x14;
9557 spec->autocfg.speaker_pins[0] = 0x15;
Takashi Iwaid922b512011-04-28 12:18:53 +02009558 spec->automute = 1;
9559 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yang272a5272007-05-14 11:00:38 +02009560}
9561
Kailang Yangccc656c2006-10-17 12:32:26 +02009562/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009563#define alc883_targa_init_hook alc882_targa_init_hook
9564#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009565
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009566static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009567{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009568 struct alc_spec *spec = codec->spec;
9569
9570 spec->autocfg.hp_pins[0] = 0x15;
9571 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +02009572 spec->automute = 1;
9573 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009574}
9575
9576static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9577{
Takashi Iwaid922b512011-04-28 12:18:53 +02009578 alc_hp_automute(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +01009579 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009580}
9581
9582static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009583 unsigned int res)
9584{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009585 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009586 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +01009587 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009588 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009589 default:
Takashi Iwaid922b512011-04-28 12:18:53 +02009590 alc_sku_unsol_event(codec, res);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009591 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009592 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009593}
9594
Jiang zhefb97dc62008-03-06 11:07:11 +01009595/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009596static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009597{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009598 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009599
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009600 spec->autocfg.hp_pins[0] = 0x14;
9601 spec->autocfg.speaker_pins[0] = 0x15;
Takashi Iwaid922b512011-04-28 12:18:53 +02009602 spec->automute = 1;
9603 spec->automute_mode = ALC_AUTOMUTE_AMP;
Jiang zhefb97dc62008-03-06 11:07:11 +01009604}
9605
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009606static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009607{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009608 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009609
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009610 spec->autocfg.hp_pins[0] = 0x1b;
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;
Kailang Yang189609a2007-08-20 11:31:23 +02009614}
9615
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02009616static void alc883_lenovo_101e_setup(struct hda_codec *codec)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009617{
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02009618 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009619
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02009620 spec->autocfg.hp_pins[0] = 0x1b;
9621 spec->autocfg.line_out_pins[0] = 0x14;
9622 spec->autocfg.speaker_pins[0] = 0x15;
9623 spec->automute = 1;
9624 spec->detect_line = 1;
9625 spec->automute_lines = 1;
9626 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009627}
9628
Takashi Iwai676a9b52007-08-16 15:23:35 +02009629/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009630static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009631{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009632 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009633
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009634 spec->autocfg.hp_pins[0] = 0x14;
9635 spec->autocfg.speaker_pins[0] = 0x15;
9636 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwaid922b512011-04-28 12:18:53 +02009637 spec->automute = 1;
9638 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009639}
9640
Takashi Iwaia9111322011-05-02 11:30:18 +02009641static const struct hda_verb alc883_acer_eapd_verbs[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02009642 /* HP Pin: output 0 (0x0c) */
9643 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9644 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9645 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9646 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009647 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9648 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009649 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009650 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9651 /* eanable EAPD on medion laptop */
9652 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9653 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009654 /* enable unsolicited event */
9655 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009656 { }
9657};
9658
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009659static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009660{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009661 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009662
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009663 spec->autocfg.hp_pins[0] = 0x1b;
9664 spec->autocfg.speaker_pins[0] = 0x14;
9665 spec->autocfg.speaker_pins[1] = 0x15;
9666 spec->autocfg.speaker_pins[2] = 0x16;
9667 spec->autocfg.speaker_pins[3] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02009668 spec->automute = 1;
9669 spec->automute_mode = ALC_AUTOMUTE_AMP;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009670}
9671
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009672static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009673{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009674 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009675
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009676 spec->autocfg.hp_pins[0] = 0x1b;
9677 spec->autocfg.speaker_pins[0] = 0x14;
9678 spec->autocfg.speaker_pins[1] = 0x15;
9679 spec->autocfg.speaker_pins[2] = 0x16;
9680 spec->autocfg.speaker_pins[3] = 0x17;
9681 spec->autocfg.speaker_pins[4] = 0x1a;
Takashi Iwaid922b512011-04-28 12:18:53 +02009682 spec->automute = 1;
9683 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yange2757d52008-08-26 13:17:46 +02009684}
9685
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009686static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02009687{
9688 struct alc_spec *spec = codec->spec;
9689
9690 spec->autocfg.hp_pins[0] = 0x15;
9691 spec->autocfg.speaker_pins[0] = 0x14;
9692 spec->autocfg.speaker_pins[1] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02009693 spec->automute = 1;
9694 spec->automute_mode = ALC_AUTOMUTE_AMP;
Guido Günther3e1647c2009-06-05 00:47:26 +02009695}
9696
Takashi Iwaia9111322011-05-02 11:30:18 +02009697static const struct hda_verb alc888_asus_m90v_verbs[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009698 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9699 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9700 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9701 /* enable unsolicited event */
9702 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9703 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9704 { } /* end */
9705};
9706
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009707static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009708{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009709 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009710
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009711 spec->autocfg.hp_pins[0] = 0x1b;
9712 spec->autocfg.speaker_pins[0] = 0x14;
9713 spec->autocfg.speaker_pins[1] = 0x15;
9714 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009715 spec->ext_mic.pin = 0x18;
9716 spec->int_mic.pin = 0x19;
9717 spec->ext_mic.mux_idx = 0;
9718 spec->int_mic.mux_idx = 1;
9719 spec->auto_mic = 1;
Takashi Iwaid922b512011-04-28 12:18:53 +02009720 spec->automute = 1;
9721 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yange2757d52008-08-26 13:17:46 +02009722}
9723
Takashi Iwaia9111322011-05-02 11:30:18 +02009724static const struct hda_verb alc888_asus_eee1601_verbs[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009725 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9726 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9727 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9728 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9729 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9730 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9731 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9732 /* enable unsolicited event */
9733 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9734 { } /* end */
9735};
9736
Kailang Yange2757d52008-08-26 13:17:46 +02009737static void alc883_eee1601_inithook(struct hda_codec *codec)
9738{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009739 struct alc_spec *spec = codec->spec;
9740
9741 spec->autocfg.hp_pins[0] = 0x14;
9742 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaid922b512011-04-28 12:18:53 +02009743 alc_hp_automute(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009744}
9745
Takashi Iwaia9111322011-05-02 11:30:18 +02009746static const struct hda_verb alc889A_mb31_verbs[] = {
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009747 /* Init rear pin (used as headphone output) */
9748 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9749 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9750 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9751 /* Init line pin (used as output in 4ch and 6ch mode) */
9752 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9753 /* Init line 2 pin (used as headphone out by default) */
9754 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9755 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9756 { } /* end */
9757};
9758
9759/* Mute speakers according to the headphone jack state */
9760static void alc889A_mb31_automute(struct hda_codec *codec)
9761{
9762 unsigned int present;
9763
9764 /* Mute only in 2ch or 4ch mode */
9765 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9766 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009767 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009768 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9769 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9770 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9771 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9772 }
9773}
9774
9775static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9776{
9777 if ((res >> 26) == ALC880_HP_EVENT)
9778 alc889A_mb31_automute(codec);
9779}
9780
Takashi Iwai4953550a2009-06-30 15:28:30 +02009781
Takashi Iwaicb53c622007-08-10 17:21:45 +02009782#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009783#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009784#endif
9785
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009786/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009787#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9788#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9789#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9790#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9791
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02009792static const hda_nid_t alc883_slave_dig_outs[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02009793 ALC1200_DIGOUT_NID, 0,
9794};
9795
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02009796static const hda_nid_t alc1200_slave_dig_outs[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02009797 ALC883_DIGOUT_NID, 0,
9798};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009799
9800/*
9801 * configuration and preset
9802 */
Takashi Iwaiea734962011-01-17 11:29:34 +01009803static const char * const alc882_models[ALC882_MODEL_LAST] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02009804 [ALC882_3ST_DIG] = "3stack-dig",
9805 [ALC882_6ST_DIG] = "6stack-dig",
9806 [ALC882_ARIMA] = "arima",
9807 [ALC882_W2JC] = "w2jc",
9808 [ALC882_TARGA] = "targa",
9809 [ALC882_ASUS_A7J] = "asus-a7j",
9810 [ALC882_ASUS_A7M] = "asus-a7m",
9811 [ALC885_MACPRO] = "macpro",
9812 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009813 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009814 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009815 [ALC885_MBP3] = "mbp3",
9816 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009817 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009818 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009819 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9820 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009821 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009822 [ALC883_TARGA_DIG] = "targa-dig",
9823 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009824 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009825 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009826 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009827 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009828 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009829 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009830 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009831 [ALC883_MEDION] = "medion",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009832 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009833 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009834 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009835 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9836 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009837 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009838 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009839 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009840 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009841 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309842 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009843 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009844 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009845 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009846 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009847 [ALC889A_INTEL] = "intel-alc889a",
9848 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009849 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009850 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009851 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009852 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009853};
9854
Takashi Iwaia9111322011-05-02 11:30:18 +02009855static const struct snd_pci_quirk alc882_cfg_tbl[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02009856 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9857
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009858 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009859 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009860 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009861 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9862 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009863 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009864 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9865 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009866 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009867 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009868 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9869 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009870 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9871 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009872 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9873 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009874 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009875 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009876 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009877 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009878 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9879 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009880 /* default Acer -- disabled as it causes more problems.
9881 * model=auto should work fine now
9882 */
9883 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009884
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009885 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009886
Lucas De Marchi25985ed2011-03-30 22:57:33 -03009887 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavilion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009888 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9889 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009890 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009891 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009892 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009893
9894 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9895 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9896 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009897 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009898 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9899 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9900 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009901 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009902 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009903 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009904 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009905
9906 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009907 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009908 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009909 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009910 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9911 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009912 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009913 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwaiebb47242011-05-02 10:37:29 +02009914 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009915
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009916 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9917 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9918 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009919 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009920 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009921 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009922 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009923 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009924 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9925 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9926 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9927 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9928 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9929 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009930 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009931 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9932 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9933 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009934 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009935 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009936 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9937 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009938 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009939 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009940 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009941 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009942 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009943 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009944 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009945 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009946 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009947
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009948 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +02009949 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009950 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9951 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309952 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009953 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009954 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009955 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009956 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009957 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009958 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009959 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009960 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009961 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009962 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009963 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9964 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009965 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Takashi Iwai959973b2008-11-05 11:30:56 +01009966 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009967 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009968 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009969
Jiang zhe17bba1b2008-06-04 12:11:07 +02009970 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9971 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009972 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009973 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9974 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9975 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009976 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009977
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009978 {}
9979};
9980
Takashi Iwai4953550a2009-06-30 15:28:30 +02009981/* codec SSID table for Intel Mac */
Takashi Iwaia9111322011-05-02 11:30:18 +02009982static const struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02009983 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9984 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9985 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9986 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9987 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9988 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9989 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -04009990 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -07009991 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -07009992 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -07009993 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009994 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9995 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9996 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009997 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009998 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Luke Yelavich3bfea982010-06-22 11:04:19 +10009999 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -050010000 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
10001 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +020010002 */
10003 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -050010004 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010005 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010006 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010007};
10008
Takashi Iwaia9111322011-05-02 11:30:18 +020010009static const struct alc_config_preset alc882_presets[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +020010010 [ALC882_3ST_DIG] = {
10011 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010012 .init_verbs = { alc882_base_init_verbs,
10013 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010014 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10015 .dac_nids = alc882_dac_nids,
10016 .dig_out_nid = ALC882_DIGOUT_NID,
10017 .dig_in_nid = ALC882_DIGIN_NID,
10018 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10019 .channel_mode = alc882_ch_modes,
10020 .need_dac_fix = 1,
10021 .input_mux = &alc882_capture_source,
10022 },
10023 [ALC882_6ST_DIG] = {
10024 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010025 .init_verbs = { alc882_base_init_verbs,
10026 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010027 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10028 .dac_nids = alc882_dac_nids,
10029 .dig_out_nid = ALC882_DIGOUT_NID,
10030 .dig_in_nid = ALC882_DIGIN_NID,
10031 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
10032 .channel_mode = alc882_sixstack_modes,
10033 .input_mux = &alc882_capture_source,
10034 },
10035 [ALC882_ARIMA] = {
10036 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010037 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10038 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010039 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10040 .dac_nids = alc882_dac_nids,
10041 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
10042 .channel_mode = alc882_sixstack_modes,
10043 .input_mux = &alc882_capture_source,
10044 },
10045 [ALC882_W2JC] = {
10046 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010047 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10048 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010049 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10050 .dac_nids = alc882_dac_nids,
10051 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10052 .channel_mode = alc880_threestack_modes,
10053 .need_dac_fix = 1,
10054 .input_mux = &alc882_capture_source,
10055 .dig_out_nid = ALC882_DIGOUT_NID,
10056 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -080010057 [ALC885_MBA21] = {
10058 .mixers = { alc885_mba21_mixer },
10059 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
10060 .num_dacs = 2,
10061 .dac_nids = alc882_dac_nids,
10062 .channel_mode = alc885_mba21_ch_modes,
10063 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10064 .input_mux = &alc882_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010065 .unsol_event = alc_sku_unsol_event,
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -080010066 .setup = alc885_mba21_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010067 .init_hook = alc_hp_automute,
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -080010068 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010069 [ALC885_MBP3] = {
10070 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
10071 .init_verbs = { alc885_mbp3_init_verbs,
10072 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +020010073 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010074 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +020010075 .hp_nid = 0x04,
10076 .channel_mode = alc885_mbp_4ch_modes,
10077 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010078 .input_mux = &alc882_capture_source,
10079 .dig_out_nid = ALC882_DIGOUT_NID,
10080 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaid922b512011-04-28 12:18:53 +020010081 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010082 .setup = alc885_mbp3_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010083 .init_hook = alc_hp_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010084 },
10085 [ALC885_MB5] = {
10086 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
10087 .init_verbs = { alc885_mb5_init_verbs,
10088 alc880_gpio1_init_verbs },
10089 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10090 .dac_nids = alc882_dac_nids,
10091 .channel_mode = alc885_mb5_6ch_modes,
10092 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
10093 .input_mux = &mb5_capture_source,
10094 .dig_out_nid = ALC882_DIGOUT_NID,
10095 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaid922b512011-04-28 12:18:53 +020010096 .unsol_event = alc_sku_unsol_event,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010097 .setup = alc885_mb5_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010098 .init_hook = alc_hp_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010099 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010100 [ALC885_MACMINI3] = {
10101 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
10102 .init_verbs = { alc885_macmini3_init_verbs,
10103 alc880_gpio1_init_verbs },
10104 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10105 .dac_nids = alc882_dac_nids,
10106 .channel_mode = alc885_macmini3_6ch_modes,
10107 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
10108 .input_mux = &macmini3_capture_source,
10109 .dig_out_nid = ALC882_DIGOUT_NID,
10110 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaid922b512011-04-28 12:18:53 +020010111 .unsol_event = alc_sku_unsol_event,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010112 .setup = alc885_macmini3_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010113 .init_hook = alc_hp_automute,
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010114 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010115 [ALC885_MACPRO] = {
10116 .mixers = { alc882_macpro_mixer },
10117 .init_verbs = { alc882_macpro_init_verbs },
10118 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10119 .dac_nids = alc882_dac_nids,
10120 .dig_out_nid = ALC882_DIGOUT_NID,
10121 .dig_in_nid = ALC882_DIGIN_NID,
10122 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10123 .channel_mode = alc882_ch_modes,
10124 .input_mux = &alc882_capture_source,
10125 .init_hook = alc885_macpro_init_hook,
10126 },
10127 [ALC885_IMAC24] = {
10128 .mixers = { alc885_imac24_mixer },
10129 .init_verbs = { alc885_imac24_init_verbs },
10130 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10131 .dac_nids = alc882_dac_nids,
10132 .dig_out_nid = ALC882_DIGOUT_NID,
10133 .dig_in_nid = ALC882_DIGIN_NID,
10134 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10135 .channel_mode = alc882_ch_modes,
10136 .input_mux = &alc882_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010137 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010138 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010139 .init_hook = alc885_imac24_init_hook,
10140 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010141 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010142 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010143 .init_verbs = { alc885_imac91_init_verbs,
10144 alc880_gpio1_init_verbs },
10145 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10146 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010147 .channel_mode = alc885_mba21_ch_modes,
10148 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10149 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010150 .dig_out_nid = ALC882_DIGOUT_NID,
10151 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaid922b512011-04-28 12:18:53 +020010152 .unsol_event = alc_sku_unsol_event,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010153 .setup = alc885_imac91_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010154 .init_hook = alc_hp_automute,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010155 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010156 [ALC882_TARGA] = {
10157 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010158 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +020010159 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010160 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10161 .dac_nids = alc882_dac_nids,
10162 .dig_out_nid = ALC882_DIGOUT_NID,
10163 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10164 .adc_nids = alc882_adc_nids,
10165 .capsrc_nids = alc882_capsrc_nids,
10166 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10167 .channel_mode = alc882_3ST_6ch_modes,
10168 .need_dac_fix = 1,
10169 .input_mux = &alc882_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010170 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010171 .setup = alc882_targa_setup,
10172 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010173 },
10174 [ALC882_ASUS_A7J] = {
10175 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010176 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10177 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010178 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10179 .dac_nids = alc882_dac_nids,
10180 .dig_out_nid = ALC882_DIGOUT_NID,
10181 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10182 .adc_nids = alc882_adc_nids,
10183 .capsrc_nids = alc882_capsrc_nids,
10184 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10185 .channel_mode = alc882_3ST_6ch_modes,
10186 .need_dac_fix = 1,
10187 .input_mux = &alc882_capture_source,
10188 },
10189 [ALC882_ASUS_A7M] = {
10190 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010191 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10192 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010193 alc882_asus_a7m_verbs },
10194 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10195 .dac_nids = alc882_dac_nids,
10196 .dig_out_nid = ALC882_DIGOUT_NID,
10197 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10198 .channel_mode = alc880_threestack_modes,
10199 .need_dac_fix = 1,
10200 .input_mux = &alc882_capture_source,
10201 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010202 [ALC883_3ST_2ch_DIG] = {
10203 .mixers = { alc883_3ST_2ch_mixer },
10204 .init_verbs = { alc883_init_verbs },
10205 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10206 .dac_nids = alc883_dac_nids,
10207 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010208 .dig_in_nid = ALC883_DIGIN_NID,
10209 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10210 .channel_mode = alc883_3ST_2ch_modes,
10211 .input_mux = &alc883_capture_source,
10212 },
10213 [ALC883_3ST_6ch_DIG] = {
10214 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10215 .init_verbs = { alc883_init_verbs },
10216 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10217 .dac_nids = alc883_dac_nids,
10218 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010219 .dig_in_nid = ALC883_DIGIN_NID,
10220 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10221 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010222 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010223 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010224 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010225 [ALC883_3ST_6ch] = {
10226 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10227 .init_verbs = { alc883_init_verbs },
10228 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10229 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010230 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10231 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010232 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010233 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010234 },
Jiang zhe17bba1b2008-06-04 12:11:07 +020010235 [ALC883_3ST_6ch_INTEL] = {
10236 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
10237 .init_verbs = { alc883_init_verbs },
10238 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10239 .dac_nids = alc883_dac_nids,
10240 .dig_out_nid = ALC883_DIGOUT_NID,
10241 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010242 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +020010243 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
10244 .channel_mode = alc883_3ST_6ch_intel_modes,
10245 .need_dac_fix = 1,
10246 .input_mux = &alc883_3stack_6ch_intel,
10247 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010248 [ALC889A_INTEL] = {
10249 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020010250 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
10251 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010252 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10253 .dac_nids = alc883_dac_nids,
10254 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10255 .adc_nids = alc889_adc_nids,
10256 .dig_out_nid = ALC883_DIGOUT_NID,
10257 .dig_in_nid = ALC883_DIGIN_NID,
10258 .slave_dig_outs = alc883_slave_dig_outs,
10259 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10260 .channel_mode = alc889_8ch_intel_modes,
10261 .capsrc_nids = alc889_capsrc_nids,
10262 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010263 .setup = alc889_automute_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010264 .init_hook = alc_hp_automute,
10265 .unsol_event = alc_sku_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010266 .need_dac_fix = 1,
10267 },
10268 [ALC889_INTEL] = {
10269 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
10270 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010271 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010272 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10273 .dac_nids = alc883_dac_nids,
10274 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10275 .adc_nids = alc889_adc_nids,
10276 .dig_out_nid = ALC883_DIGOUT_NID,
10277 .dig_in_nid = ALC883_DIGIN_NID,
10278 .slave_dig_outs = alc883_slave_dig_outs,
10279 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10280 .channel_mode = alc889_8ch_intel_modes,
10281 .capsrc_nids = alc889_capsrc_nids,
10282 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010283 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010284 .init_hook = alc889_intel_init_hook,
Takashi Iwaid922b512011-04-28 12:18:53 +020010285 .unsol_event = alc_sku_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010286 .need_dac_fix = 1,
10287 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010288 [ALC883_6ST_DIG] = {
10289 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10290 .init_verbs = { alc883_init_verbs },
10291 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10292 .dac_nids = alc883_dac_nids,
10293 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010294 .dig_in_nid = ALC883_DIGIN_NID,
10295 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10296 .channel_mode = alc883_sixstack_modes,
10297 .input_mux = &alc883_capture_source,
10298 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010299 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010300 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +020010301 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10302 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010303 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10304 .dac_nids = alc883_dac_nids,
10305 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010306 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10307 .channel_mode = alc883_3ST_6ch_modes,
10308 .need_dac_fix = 1,
10309 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010310 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010311 .setup = alc882_targa_setup,
10312 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010313 },
10314 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010315 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +020010316 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10317 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010318 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10319 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010320 .adc_nids = alc883_adc_nids_alt,
10321 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010322 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +020010323 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010324 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10325 .channel_mode = alc883_3ST_2ch_modes,
10326 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010327 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010328 .setup = alc882_targa_setup,
10329 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010330 },
David Heidelberger64a8be72009-06-08 16:15:18 +020010331 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +020010332 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
10333 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +020010334 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010335 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +020010336 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10337 .dac_nids = alc883_dac_nids,
10338 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10339 .adc_nids = alc883_adc_nids_rev,
10340 .capsrc_nids = alc883_capsrc_nids_rev,
10341 .dig_out_nid = ALC883_DIGOUT_NID,
10342 .dig_in_nid = ALC883_DIGIN_NID,
10343 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
10344 .channel_mode = alc883_4ST_8ch_modes,
10345 .need_dac_fix = 1,
10346 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010347 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010348 .setup = alc882_targa_setup,
10349 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +020010350 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010351 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010352 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010353 /* On TravelMate laptops, GPIO 0 enables the internal speaker
10354 * and the headphone jack. Turn this on and rely on the
10355 * standard mute methods whenever the user wants to turn
10356 * these outputs off.
10357 */
10358 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
10359 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10360 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010361 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10362 .channel_mode = alc883_3ST_2ch_modes,
10363 .input_mux = &alc883_capture_source,
10364 },
Tobin Davis2880a862007-08-07 11:50:26 +020010365 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010366 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010367 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +020010368 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10369 .dac_nids = alc883_dac_nids,
10370 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +020010371 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10372 .channel_mode = alc883_3ST_2ch_modes,
10373 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010374 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010375 .setup = alc883_acer_aspire_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010376 .init_hook = alc_hp_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010377 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010378 [ALC888_ACER_ASPIRE_4930G] = {
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +010010379 .mixers = { alc888_acer_aspire_4930g_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010380 alc883_chmode_mixer },
10381 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10382 alc888_acer_aspire_4930g_verbs },
10383 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10384 .dac_nids = alc883_dac_nids,
10385 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10386 .adc_nids = alc883_adc_nids_rev,
10387 .capsrc_nids = alc883_capsrc_nids_rev,
10388 .dig_out_nid = ALC883_DIGOUT_NID,
10389 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10390 .channel_mode = alc883_3ST_6ch_modes,
10391 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +010010392 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010393 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010394 ARRAY_SIZE(alc888_2_capture_sources),
10395 .input_mux = alc888_2_capture_sources,
Takashi Iwaid922b512011-04-28 12:18:53 +020010396 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010397 .setup = alc888_acer_aspire_4930g_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010398 .init_hook = alc_hp_automute,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010399 },
Tony Vroond2fd4b02009-06-21 00:40:10 +010010400 [ALC888_ACER_ASPIRE_6530G] = {
10401 .mixers = { alc888_acer_aspire_6530_mixer },
10402 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10403 alc888_acer_aspire_6530g_verbs },
10404 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10405 .dac_nids = alc883_dac_nids,
10406 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10407 .adc_nids = alc883_adc_nids_rev,
10408 .capsrc_nids = alc883_capsrc_nids_rev,
10409 .dig_out_nid = ALC883_DIGOUT_NID,
10410 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10411 .channel_mode = alc883_3ST_2ch_modes,
10412 .num_mux_defs =
10413 ARRAY_SIZE(alc888_2_capture_sources),
10414 .input_mux = alc888_acer_aspire_6530_sources,
Takashi Iwaid922b512011-04-28 12:18:53 +020010415 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010416 .setup = alc888_acer_aspire_6530g_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010417 .init_hook = alc_hp_automute,
Tony Vroond2fd4b02009-06-21 00:40:10 +010010418 },
Hector Martin3b315d72009-06-02 10:54:19 +020010419 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +010010420 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +020010421 alc883_chmode_mixer },
10422 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +010010423 alc889_acer_aspire_8930g_verbs,
10424 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +020010425 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10426 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +020010427 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10428 .adc_nids = alc889_adc_nids,
10429 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +020010430 .dig_out_nid = ALC883_DIGOUT_NID,
10431 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10432 .channel_mode = alc883_3ST_6ch_modes,
10433 .need_dac_fix = 1,
10434 .const_channel_count = 6,
10435 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +020010436 ARRAY_SIZE(alc889_capture_sources),
10437 .input_mux = alc889_capture_sources,
Takashi Iwaid922b512011-04-28 12:18:53 +020010438 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010439 .setup = alc889_acer_aspire_8930g_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010440 .init_hook = alc_hp_automute,
Hector Martinf5de24b2009-12-20 22:51:31 +010010441#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050010442 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +010010443#endif
Hector Martin3b315d72009-06-02 10:54:19 +020010444 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010445 [ALC888_ACER_ASPIRE_7730G] = {
10446 .mixers = { alc883_3ST_6ch_mixer,
10447 alc883_chmode_mixer },
10448 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10449 alc888_acer_aspire_7730G_verbs },
10450 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10451 .dac_nids = alc883_dac_nids,
10452 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10453 .adc_nids = alc883_adc_nids_rev,
10454 .capsrc_nids = alc883_capsrc_nids_rev,
10455 .dig_out_nid = ALC883_DIGOUT_NID,
10456 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10457 .channel_mode = alc883_3ST_6ch_modes,
10458 .need_dac_fix = 1,
10459 .const_channel_count = 6,
10460 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010461 .unsol_event = alc_sku_unsol_event,
Denis Kuplyakovd9477202010-11-24 06:01:09 +010010462 .setup = alc888_acer_aspire_7730g_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010463 .init_hook = alc_hp_automute,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010464 },
Tobin Davisc07584c2006-10-13 12:32:16 +020010465 [ALC883_MEDION] = {
10466 .mixers = { alc883_fivestack_mixer,
10467 alc883_chmode_mixer },
10468 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010469 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +020010470 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10471 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010472 .adc_nids = alc883_adc_nids_alt,
10473 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010474 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +020010475 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10476 .channel_mode = alc883_sixstack_modes,
10477 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010478 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010479 [ALC883_MEDION_WIM2160] = {
10480 .mixers = { alc883_medion_wim2160_mixer },
10481 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
10482 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10483 .dac_nids = alc883_dac_nids,
10484 .dig_out_nid = ALC883_DIGOUT_NID,
10485 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
10486 .adc_nids = alc883_adc_nids,
10487 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10488 .channel_mode = alc883_3ST_2ch_modes,
10489 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010490 .unsol_event = alc_sku_unsol_event,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010491 .setup = alc883_medion_wim2160_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010492 .init_hook = alc_hp_automute,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010493 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010494 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010495 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010496 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10497 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10498 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010499 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10500 .channel_mode = alc883_3ST_2ch_modes,
10501 .input_mux = &alc883_capture_source,
10502 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010503 [ALC883_CLEVO_M540R] = {
10504 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10505 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10506 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10507 .dac_nids = alc883_dac_nids,
10508 .dig_out_nid = ALC883_DIGOUT_NID,
10509 .dig_in_nid = ALC883_DIGIN_NID,
10510 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10511 .channel_mode = alc883_3ST_6ch_clevo_modes,
10512 .need_dac_fix = 1,
10513 .input_mux = &alc883_capture_source,
10514 /* This machine has the hardware HP auto-muting, thus
10515 * we need no software mute via unsol event
10516 */
10517 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010518 [ALC883_CLEVO_M720] = {
10519 .mixers = { alc883_clevo_m720_mixer },
10520 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010521 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10522 .dac_nids = alc883_dac_nids,
10523 .dig_out_nid = ALC883_DIGOUT_NID,
10524 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10525 .channel_mode = alc883_3ST_2ch_modes,
10526 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010527 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010528 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010529 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010530 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010531 [ALC883_LENOVO_101E_2ch] = {
10532 .mixers = { alc883_lenovo_101e_2ch_mixer},
10533 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10534 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10535 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010536 .adc_nids = alc883_adc_nids_alt,
10537 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010538 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010539 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10540 .channel_mode = alc883_3ST_2ch_modes,
10541 .input_mux = &alc883_lenovo_101e_capture_source,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020010542 .setup = alc883_lenovo_101e_setup,
10543 .unsol_event = alc_sku_unsol_event,
10544 .init_hook = alc_inithook,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010545 },
Kailang Yang272a5272007-05-14 11:00:38 +020010546 [ALC883_LENOVO_NB0763] = {
10547 .mixers = { alc883_lenovo_nb0763_mixer },
10548 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10549 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10550 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010551 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10552 .channel_mode = alc883_3ST_2ch_modes,
10553 .need_dac_fix = 1,
10554 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010555 .unsol_event = alc_sku_unsol_event,
Takashi Iwaidc4271702010-11-29 07:42:59 +010010556 .setup = alc883_lenovo_nb0763_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010557 .init_hook = alc_hp_automute,
Kailang Yang272a5272007-05-14 11:00:38 +020010558 },
10559 [ALC888_LENOVO_MS7195_DIG] = {
10560 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10561 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10562 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10563 .dac_nids = alc883_dac_nids,
10564 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010565 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10566 .channel_mode = alc883_3ST_6ch_modes,
10567 .need_dac_fix = 1,
10568 .input_mux = &alc883_capture_source,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020010569 .unsol_event = alc_sku_unsol_event,
10570 .setup = alc888_lenovo_ms7195_setup,
10571 .init_hook = alc_inithook,
Kailang Yang189609a2007-08-20 11:31:23 +020010572 },
10573 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010574 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010575 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10576 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10577 .dac_nids = alc883_dac_nids,
10578 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010579 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10580 .channel_mode = alc883_3ST_2ch_modes,
10581 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010582 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010583 .setup = alc883_haier_w66_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010584 .init_hook = alc_hp_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010585 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010586 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010587 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010588 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010589 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10590 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010591 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10592 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010593 .need_dac_fix = 1,
10594 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010595 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010596 .setup = alc888_3st_hp_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010597 .init_hook = alc_hp_automute,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010598 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010599 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010600 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010601 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10602 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10603 .dac_nids = alc883_dac_nids,
10604 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010605 .dig_in_nid = ALC883_DIGIN_NID,
10606 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10607 .channel_mode = alc883_sixstack_modes,
10608 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010609 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010610 .setup = alc888_6st_dell_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010611 .init_hook = alc_hp_automute,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010612 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010613 [ALC883_MITAC] = {
10614 .mixers = { alc883_mitac_mixer },
10615 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10616 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10617 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010618 .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_mitac_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010623 .init_hook = alc_hp_automute,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010624 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010625 [ALC883_FUJITSU_PI2515] = {
10626 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10627 .init_verbs = { alc883_init_verbs,
10628 alc883_2ch_fujitsu_pi2515_verbs},
10629 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10630 .dac_nids = alc883_dac_nids,
10631 .dig_out_nid = ALC883_DIGOUT_NID,
10632 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10633 .channel_mode = alc883_3ST_2ch_modes,
10634 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010635 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010636 .setup = alc883_2ch_fujitsu_pi2515_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010637 .init_hook = alc_hp_automute,
Jiang zhefb97dc62008-03-06 11:07:11 +010010638 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010639 [ALC888_FUJITSU_XA3530] = {
10640 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10641 .init_verbs = { alc883_init_verbs,
10642 alc888_fujitsu_xa3530_verbs },
10643 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10644 .dac_nids = alc883_dac_nids,
10645 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10646 .adc_nids = alc883_adc_nids_rev,
10647 .capsrc_nids = alc883_capsrc_nids_rev,
10648 .dig_out_nid = ALC883_DIGOUT_NID,
10649 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10650 .channel_mode = alc888_4ST_8ch_intel_modes,
10651 .num_mux_defs =
10652 ARRAY_SIZE(alc888_2_capture_sources),
10653 .input_mux = alc888_2_capture_sources,
Takashi Iwaid922b512011-04-28 12:18:53 +020010654 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010655 .setup = alc888_fujitsu_xa3530_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010656 .init_hook = alc_hp_automute,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010657 },
Kailang Yange2757d52008-08-26 13:17:46 +020010658 [ALC888_LENOVO_SKY] = {
10659 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10660 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10661 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10662 .dac_nids = alc883_dac_nids,
10663 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010664 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10665 .channel_mode = alc883_sixstack_modes,
10666 .need_dac_fix = 1,
10667 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010668 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010669 .setup = alc888_lenovo_sky_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010670 .init_hook = alc_hp_automute,
Kailang Yange2757d52008-08-26 13:17:46 +020010671 },
10672 [ALC888_ASUS_M90V] = {
10673 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10674 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10675 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10676 .dac_nids = alc883_dac_nids,
10677 .dig_out_nid = ALC883_DIGOUT_NID,
10678 .dig_in_nid = ALC883_DIGIN_NID,
10679 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10680 .channel_mode = alc883_3ST_6ch_modes,
10681 .need_dac_fix = 1,
10682 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010683 .unsol_event = alc_sku_unsol_event,
10684 .setup = alc883_mode2_setup,
10685 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010686 },
10687 [ALC888_ASUS_EEE1601] = {
10688 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010689 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010690 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10691 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10692 .dac_nids = alc883_dac_nids,
10693 .dig_out_nid = ALC883_DIGOUT_NID,
10694 .dig_in_nid = ALC883_DIGIN_NID,
10695 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10696 .channel_mode = alc883_3ST_2ch_modes,
10697 .need_dac_fix = 1,
10698 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010699 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010700 .init_hook = alc883_eee1601_inithook,
10701 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010702 [ALC1200_ASUS_P5Q] = {
10703 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10704 .init_verbs = { alc883_init_verbs },
10705 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10706 .dac_nids = alc883_dac_nids,
10707 .dig_out_nid = ALC1200_DIGOUT_NID,
10708 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010709 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010710 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10711 .channel_mode = alc883_sixstack_modes,
10712 .input_mux = &alc883_capture_source,
10713 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010714 [ALC889A_MB31] = {
10715 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10716 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10717 alc880_gpio1_init_verbs },
10718 .adc_nids = alc883_adc_nids,
10719 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010720 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010721 .dac_nids = alc883_dac_nids,
10722 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10723 .channel_mode = alc889A_mb31_6ch_modes,
10724 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10725 .input_mux = &alc889A_mb31_capture_source,
10726 .dig_out_nid = ALC883_DIGOUT_NID,
10727 .unsol_event = alc889A_mb31_unsol_event,
10728 .init_hook = alc889A_mb31_automute,
10729 },
Guido Günther3e1647c2009-06-05 00:47:26 +020010730 [ALC883_SONY_VAIO_TT] = {
10731 .mixers = { alc883_vaiott_mixer },
10732 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10733 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10734 .dac_nids = alc883_dac_nids,
10735 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10736 .channel_mode = alc883_3ST_2ch_modes,
10737 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010738 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010739 .setup = alc883_vaiott_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010740 .init_hook = alc_hp_automute,
Guido Günther3e1647c2009-06-05 00:47:26 +020010741 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010742};
10743
10744
10745/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010746 * Pin config fixes
10747 */
10748enum {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010749 PINFIX_ABIT_AW9D_MAX,
David Henningsson32eea382011-03-04 13:37:50 +010010750 PINFIX_LENOVO_Y530,
Takashi Iwai954a29c2010-07-30 10:55:44 +020010751 PINFIX_PB_M5210,
David Henningssonc3d226a2010-10-14 15:42:08 +020010752 PINFIX_ACER_ASPIRE_7736,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010753};
10754
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010755static const struct alc_fixup alc882_fixups[] = {
10756 [PINFIX_ABIT_AW9D_MAX] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010757 .type = ALC_FIXUP_PINS,
10758 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020010759 { 0x15, 0x01080104 }, /* side */
10760 { 0x16, 0x01011012 }, /* rear */
10761 { 0x17, 0x01016011 }, /* clfe */
10762 { }
10763 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010764 },
David Henningsson32eea382011-03-04 13:37:50 +010010765 [PINFIX_LENOVO_Y530] = {
10766 .type = ALC_FIXUP_PINS,
10767 .v.pins = (const struct alc_pincfg[]) {
10768 { 0x15, 0x99130112 }, /* rear int speakers */
10769 { 0x16, 0x99130111 }, /* subwoofer */
10770 { }
10771 }
10772 },
Takashi Iwai954a29c2010-07-30 10:55:44 +020010773 [PINFIX_PB_M5210] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010774 .type = ALC_FIXUP_VERBS,
10775 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020010776 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
10777 {}
10778 }
Takashi Iwai954a29c2010-07-30 10:55:44 +020010779 },
David Henningssonc3d226a2010-10-14 15:42:08 +020010780 [PINFIX_ACER_ASPIRE_7736] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010781 .type = ALC_FIXUP_SKU,
10782 .v.sku = ALC_FIXUP_SKU_IGNORE,
David Henningssonc3d226a2010-10-14 15:42:08 +020010783 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010784};
10785
Takashi Iwaia9111322011-05-02 11:30:18 +020010786static const struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010787 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
David Henningsson32eea382011-03-04 13:37:50 +010010788 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", PINFIX_LENOVO_Y530),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010789 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
David Henningssonc3d226a2010-10-14 15:42:08 +020010790 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010791 {}
10792};
10793
10794/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010795 * BIOS auto configuration
10796 */
Takashi Iwaif970de22011-07-06 17:39:59 +020010797static void alc_auto_init_input_src(struct hda_codec *codec)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010798{
10799 struct alc_spec *spec = codec->spec;
10800 int c;
10801
Takashi Iwaif970de22011-07-06 17:39:59 +020010802 if (spec->dual_adc_switch)
10803 return;
10804
Takashi Iwai4953550a2009-06-30 15:28:30 +020010805 for (c = 0; c < spec->num_adc_nids; c++) {
Takashi Iwaif970de22011-07-06 17:39:59 +020010806 hda_nid_t nid;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010807 unsigned int mux_idx;
10808 const struct hda_input_mux *imux;
10809 int conns, mute, idx, item;
Takashi Iwai7ec9c6c2011-06-27 15:53:38 +020010810 unsigned int wid_type;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010811
Takashi Iwaif970de22011-07-06 17:39:59 +020010812 nid = spec->capsrc_nids ?
10813 spec->capsrc_nids[c] : spec->adc_nids[c];
Takashi Iwai10696aa2011-04-07 12:46:45 +020010814 /* mute ADC */
Takashi Iwai4f574b72011-06-27 16:17:07 +020010815 if (query_amp_caps(codec, spec->adc_nids[c], HDA_INPUT) &
10816 AC_AMPCAP_MUTE)
10817 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
Takashi Iwai10696aa2011-04-07 12:46:45 +020010818 AC_VERB_SET_AMP_GAIN_MUTE,
10819 AMP_IN_MUTE(0));
Takashi Iwai4f574b72011-06-27 16:17:07 +020010820 else if (query_amp_caps(codec, nid, HDA_OUTPUT) &
10821 AC_AMPCAP_MUTE)
10822 snd_hda_codec_write(codec, nid, 0,
10823 AC_VERB_SET_AMP_GAIN_MUTE,
10824 AMP_OUT_MUTE);
Takashi Iwai10696aa2011-04-07 12:46:45 +020010825
Takashi Iwai1f0f4b82011-06-27 10:52:59 +020010826 conns = snd_hda_get_conn_list(codec, nid, NULL);
10827 if (conns <= 0)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010828 continue;
10829 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10830 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010831 if (!imux->num_items && mux_idx > 0)
10832 imux = &spec->input_mux[0];
Takashi Iwai7ec9c6c2011-06-27 15:53:38 +020010833 wid_type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai4953550a2009-06-30 15:28:30 +020010834 for (idx = 0; idx < conns; idx++) {
10835 /* if the current connection is the selected one,
10836 * unmute it as default - otherwise mute it
10837 */
10838 mute = AMP_IN_MUTE(idx);
10839 for (item = 0; item < imux->num_items; item++) {
10840 if (imux->items[item].index == idx) {
10841 if (spec->cur_mux[c] == item)
10842 mute = AMP_IN_UNMUTE(idx);
10843 break;
10844 }
10845 }
Takashi Iwai7ec9c6c2011-06-27 15:53:38 +020010846 /* initialize the mute status if mute-amp is present */
10847 if (query_amp_caps(codec, nid, HDA_INPUT) & AC_AMPCAP_MUTE)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010848 snd_hda_codec_write(codec, nid, 0,
10849 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010850 mute);
Takashi Iwai7ec9c6c2011-06-27 15:53:38 +020010851 if (wid_type == AC_WID_AUD_SEL &&
10852 mute != AMP_IN_MUTE(idx))
Takashi Iwai4953550a2009-06-30 15:28:30 +020010853 snd_hda_codec_write(codec, nid, 0,
10854 AC_VERB_SET_CONNECT_SEL,
10855 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010856 }
10857 }
10858}
10859
Takashi Iwai4953550a2009-06-30 15:28:30 +020010860/* add mic boosts if needed */
10861static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010862{
10863 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010864 struct auto_pin_cfg *cfg = &spec->autocfg;
David Henningsson5322bf22011-01-05 11:03:56 +010010865 int i, err;
Takashi Iwai53e8c322010-12-17 15:23:41 +010010866 int type_idx = 0;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010867 hda_nid_t nid;
David Henningsson5322bf22011-01-05 11:03:56 +010010868 const char *prev_label = NULL;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010869
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010870 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +020010871 if (cfg->inputs[i].type > AUTO_PIN_MIC)
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010872 break;
10873 nid = cfg->inputs[i].pin;
10874 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
David Henningsson5322bf22011-01-05 11:03:56 +010010875 const char *label;
10876 char boost_label[32];
10877
10878 label = hda_get_autocfg_input_label(codec, cfg, i);
10879 if (prev_label && !strcmp(label, prev_label))
Takashi Iwai53e8c322010-12-17 15:23:41 +010010880 type_idx++;
10881 else
10882 type_idx = 0;
David Henningsson5322bf22011-01-05 11:03:56 +010010883 prev_label = label;
10884
10885 snprintf(boost_label, sizeof(boost_label),
10886 "%s Boost Volume", label);
10887 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10888 boost_label, type_idx,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010889 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010890 if (err < 0)
10891 return err;
10892 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010893 }
10894 return 0;
10895}
10896
10897/* almost identical with ALC880 parser... */
10898static int alc882_parse_auto_config(struct hda_codec *codec)
10899{
10900 struct alc_spec *spec = codec->spec;
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020010901 static const hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai757899a2010-07-30 10:48:14 +020010902 int err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010903
Takashi Iwai05f5f472009-08-25 13:10:18 +020010904 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10905 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010906 if (err < 0)
10907 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010908 if (!spec->autocfg.line_outs)
10909 return 0; /* can't find valid BIOS pin config */
10910
Takashi Iwai343a04b2011-07-06 14:28:39 +020010911 err = alc_auto_fill_dac_nids(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010912 if (err < 0)
10913 return err;
Takashi Iwai343a04b2011-07-06 14:28:39 +020010914 err = alc_auto_add_multi_channel_mode(codec, alc_auto_fill_dac_nids);
Takashi Iwaice764ab2011-04-27 16:35:23 +020010915 if (err < 0)
10916 return err;
Takashi Iwai343a04b2011-07-06 14:28:39 +020010917 err = alc_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010918 if (err < 0)
10919 return err;
Takashi Iwai343a04b2011-07-06 14:28:39 +020010920 err = alc_auto_create_hp_out(codec);
Takashi Iwai489008c2010-04-07 09:06:00 +020010921 if (err < 0)
10922 return err;
Takashi Iwai343a04b2011-07-06 14:28:39 +020010923 err = alc_auto_create_speaker_out(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010924 if (err < 0)
10925 return err;
Takashi Iwaib7821702011-07-06 15:12:46 +020010926 err = alc_auto_create_input_ctls(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010927 if (err < 0)
10928 return err;
10929
10930 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10931
Takashi Iwai757899a2010-07-30 10:48:14 +020010932 alc_auto_parse_digital(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010933
10934 if (spec->kctls.list)
10935 add_mixer(spec, spec->kctls.list);
10936
Takashi Iwai05f5f472009-08-25 13:10:18 +020010937 spec->num_mux_defs = 1;
10938 spec->input_mux = &spec->private_imux[0];
10939
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +020010940 if (!spec->dual_adc_switch)
10941 alc_remove_invalid_adc_nids(codec);
10942
Kailang Yang6227cdc2010-02-25 08:36:52 +010010943 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010944
10945 err = alc_auto_add_mic_boost(codec);
10946 if (err < 0)
10947 return err;
10948
Takashi Iwai776e1842007-08-29 15:07:11 +020010949 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010950}
10951
10952/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010953static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010954{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010955 struct alc_spec *spec = codec->spec;
Takashi Iwai343a04b2011-07-06 14:28:39 +020010956 alc_auto_init_multi_out(codec);
10957 alc_auto_init_extra_out(codec);
Takashi Iwai0a7f5322011-07-06 15:15:12 +020010958 alc_auto_init_analog_input(codec);
Takashi Iwaif970de22011-07-06 17:39:59 +020010959 alc_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020010960 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010961 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010962 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010963}
10964
Takashi Iwai4953550a2009-06-30 15:28:30 +020010965static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010966{
10967 struct alc_spec *spec;
10968 int err, board_config;
10969
10970 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10971 if (spec == NULL)
10972 return -ENOMEM;
10973
10974 codec->spec = spec;
10975
Takashi Iwai1f0f4b82011-06-27 10:52:59 +020010976 spec->mixer_nid = 0x0b;
10977
Takashi Iwai4953550a2009-06-30 15:28:30 +020010978 switch (codec->vendor_id) {
10979 case 0x10ec0882:
10980 case 0x10ec0885:
10981 break;
10982 default:
10983 /* ALC883 and variants */
10984 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10985 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010986 }
10987
Takashi Iwai4953550a2009-06-30 15:28:30 +020010988 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10989 alc882_models,
10990 alc882_cfg_tbl);
10991
10992 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10993 board_config = snd_hda_check_board_codec_sid_config(codec,
10994 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10995
10996 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010997 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010998 codec->chip_name);
10999 board_config = ALC882_AUTO;
11000 }
11001
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010011002 if (board_config == ALC882_AUTO) {
11003 alc_pick_fixup(codec, NULL, alc882_fixup_tbl, alc882_fixups);
11004 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
11005 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011006
David Henningsson90622912010-10-14 14:50:18 +020011007 alc_auto_parse_customize_define(codec);
11008
Takashi Iwai4953550a2009-06-30 15:28:30 +020011009 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011010 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020011011 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011012 if (err < 0) {
11013 alc_free(codec);
11014 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011015 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011016 printk(KERN_INFO
11017 "hda_codec: Cannot set up configuration "
11018 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020011019 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011020 }
11021 }
11022
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011023 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020011024 err = snd_hda_attach_beep_device(codec, 0x1);
11025 if (err < 0) {
11026 alc_free(codec);
11027 return err;
11028 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011029 }
11030
Takashi Iwai4953550a2009-06-30 15:28:30 +020011031 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011032 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011033
Takashi Iwai4953550a2009-06-30 15:28:30 +020011034 spec->stream_analog_playback = &alc882_pcm_analog_playback;
11035 spec->stream_analog_capture = &alc882_pcm_analog_capture;
11036 /* FIXME: setup DAC5 */
11037 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
11038 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
11039
11040 spec->stream_digital_playback = &alc882_pcm_digital_playback;
11041 spec->stream_digital_capture = &alc882_pcm_digital_capture;
11042
Takashi Iwai4953550a2009-06-30 15:28:30 +020011043 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +020011044 alc_auto_fill_adc_caps(codec);
11045 alc_remove_invalid_adc_nids(codec);
Kailang Yang2f893282008-05-27 12:14:47 +020011046 }
11047
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011048 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010011049
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011050 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010011051 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011052
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010011053 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020011054
Takashi Iwai2134ea42008-01-10 16:53:55 +010011055 spec->vmaster_nid = 0x0c;
11056
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011057 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011058 if (board_config == ALC882_AUTO)
11059 spec->init_hook = alc882_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020011060
11061 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020011062#ifdef CONFIG_SND_HDA_POWER_SAVE
11063 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020011064 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011065#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011066
11067 return 0;
11068}
11069
Takashi Iwai4953550a2009-06-30 15:28:30 +020011070
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011071/*
Kailang Yangdf694da2005-12-05 19:42:22 +010011072 * ALC262 support
11073 */
11074
11075#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
11076#define ALC262_DIGIN_NID ALC880_DIGIN_NID
11077
11078#define alc262_dac_nids alc260_dac_nids
11079#define alc262_adc_nids alc882_adc_nids
11080#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010011081#define alc262_capsrc_nids alc882_capsrc_nids
11082#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010011083
11084#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010011085#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010011086
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020011087static const hda_nid_t alc262_dmic_adc_nids[1] = {
Kailang Yang4e555fe2008-08-26 13:05:55 +020011088 /* ADC0 */
11089 0x09
11090};
11091
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020011092static const hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
Kailang Yang4e555fe2008-08-26 13:05:55 +020011093
Takashi Iwaia9111322011-05-02 11:30:18 +020011094static const struct snd_kcontrol_new alc262_base_mixer[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010011095 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11096 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11097 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11098 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11099 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11100 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11101 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11102 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011103 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011104 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11105 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011106 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011107 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
11108 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11109 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
11110 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011111 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010011112};
11113
Takashi Iwaice875f02008-01-28 18:17:43 +010011114/* update HP, line and mono-out pins according to the master switch */
Takashi Iwaie9427962011-04-28 15:46:07 +020011115#define alc262_hp_master_update alc260_hp_master_update
Takashi Iwaice875f02008-01-28 18:17:43 +010011116
Takashi Iwaie9427962011-04-28 15:46:07 +020011117static void alc262_hp_bpc_setup(struct hda_codec *codec)
Takashi Iwaice875f02008-01-28 18:17:43 +010011118{
11119 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011120
Takashi Iwaie9427962011-04-28 15:46:07 +020011121 spec->autocfg.hp_pins[0] = 0x1b;
11122 spec->autocfg.speaker_pins[0] = 0x16;
11123 spec->automute = 1;
11124 spec->automute_mode = ALC_AUTOMUTE_PIN;
Takashi Iwaice875f02008-01-28 18:17:43 +010011125}
11126
Takashi Iwaie9427962011-04-28 15:46:07 +020011127static void alc262_hp_wildwest_setup(struct hda_codec *codec)
Takashi Iwaice875f02008-01-28 18:17:43 +010011128{
11129 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011130
Takashi Iwaie9427962011-04-28 15:46:07 +020011131 spec->autocfg.hp_pins[0] = 0x15;
11132 spec->autocfg.speaker_pins[0] = 0x16;
11133 spec->automute = 1;
11134 spec->automute_mode = ALC_AUTOMUTE_PIN;
Takashi Iwaice875f02008-01-28 18:17:43 +010011135}
11136
Takashi Iwaib72519b2009-05-08 14:31:55 +020011137#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaie9427962011-04-28 15:46:07 +020011138#define alc262_hp_master_sw_put alc260_hp_master_sw_put
Takashi Iwaice875f02008-01-28 18:17:43 +010011139
Takashi Iwaib72519b2009-05-08 14:31:55 +020011140#define ALC262_HP_MASTER_SWITCH \
11141 { \
11142 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11143 .name = "Master Playback Switch", \
11144 .info = snd_ctl_boolean_mono_info, \
11145 .get = alc262_hp_master_sw_get, \
11146 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011147 }, \
11148 { \
11149 .iface = NID_MAPPING, \
11150 .name = "Master Playback Switch", \
11151 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020011152 }
11153
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011154
Takashi Iwaia9111322011-05-02 11:30:18 +020011155static const struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011156 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011157 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11158 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11159 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011160 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11161 HDA_OUTPUT),
11162 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11163 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011164 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11165 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011166 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011167 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11168 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011169 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011170 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11171 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11172 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11173 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011174 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
11175 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
11176 { } /* end */
11177};
11178
Takashi Iwaia9111322011-05-02 11:30:18 +020011179static const struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011180 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010011181 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11182 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11183 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11184 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011185 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11186 HDA_OUTPUT),
11187 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11188 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011189 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
11190 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011191 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011192 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11193 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11194 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11195 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011196 { } /* end */
11197};
11198
Takashi Iwaia9111322011-05-02 11:30:18 +020011199static const struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
Kailang Yangcd7509a2007-01-26 18:33:17 +010011200 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11201 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011202 HDA_CODEC_VOLUME("Rear Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011203 { } /* end */
11204};
11205
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011206/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011207static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011208{
11209 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011210
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011211 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010011212 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +020011213 spec->automute = 1;
11214 spec->automute_mode = ALC_AUTOMUTE_PIN;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011215}
11216
Takashi Iwaia9111322011-05-02 11:30:18 +020011217static const struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010011218 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11219 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011220 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11221 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11222 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11223 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011224 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011225 { } /* end */
11226};
11227
Takashi Iwaia9111322011-05-02 11:30:18 +020011228static const struct hda_verb alc262_hp_t5735_verbs[] = {
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011229 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11230 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11231
11232 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11233 { }
11234};
11235
Takashi Iwaia9111322011-05-02 11:30:18 +020011236static const struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010011237 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11238 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010011239 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11240 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010011241 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11242 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11243 { } /* end */
11244};
11245
Takashi Iwaia9111322011-05-02 11:30:18 +020011246static const struct hda_verb alc262_hp_rp5700_verbs[] = {
Kailang Yang8c427222008-01-10 13:03:59 +010011247 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11248 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11249 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11250 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11251 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11252 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11253 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11254 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11255 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11256 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11257 {}
11258};
11259
Takashi Iwaia9111322011-05-02 11:30:18 +020011260static const struct hda_input_mux alc262_hp_rp5700_capture_source = {
Kailang Yang8c427222008-01-10 13:03:59 +010011261 .num_items = 1,
11262 .items = {
11263 { "Line", 0x1 },
11264 },
11265};
11266
Takashi Iwai42171c12009-05-08 14:11:43 +020011267/* bind hp and internal speaker mute (with plug check) as master switch */
Takashi Iwaie9427962011-04-28 15:46:07 +020011268#define alc262_hippo_master_update alc262_hp_master_update
Takashi Iwai42171c12009-05-08 14:11:43 +020011269#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
Takashi Iwaie9427962011-04-28 15:46:07 +020011270#define alc262_hippo_master_sw_put alc262_hp_master_sw_put
Takashi Iwai5b319542007-07-26 11:49:22 +020011271
Takashi Iwai42171c12009-05-08 14:11:43 +020011272#define ALC262_HIPPO_MASTER_SWITCH \
11273 { \
11274 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11275 .name = "Master Playback Switch", \
11276 .info = snd_ctl_boolean_mono_info, \
11277 .get = alc262_hippo_master_sw_get, \
11278 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011279 }, \
11280 { \
11281 .iface = NID_MAPPING, \
11282 .name = "Master Playback Switch", \
11283 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
11284 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020011285 }
11286
Takashi Iwaia9111322011-05-02 11:30:18 +020011287static const struct snd_kcontrol_new alc262_hippo_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011288 ALC262_HIPPO_MASTER_SWITCH,
11289 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11290 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11291 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11292 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11293 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11294 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11295 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011296 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011297 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11298 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011299 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011300 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11301 { } /* end */
11302};
11303
Takashi Iwaia9111322011-05-02 11:30:18 +020011304static const struct snd_kcontrol_new alc262_hippo1_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011305 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11306 ALC262_HIPPO_MASTER_SWITCH,
11307 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11308 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11309 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11310 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11311 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11312 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011313 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011314 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11315 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011316 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011317 { } /* end */
11318};
11319
11320/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011321static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011322{
11323 struct alc_spec *spec = codec->spec;
11324
11325 spec->autocfg.hp_pins[0] = 0x15;
11326 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaie9427962011-04-28 15:46:07 +020011327 spec->automute = 1;
11328 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai42171c12009-05-08 14:11:43 +020011329}
11330
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011331static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011332{
11333 struct alc_spec *spec = codec->spec;
11334
11335 spec->autocfg.hp_pins[0] = 0x1b;
11336 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaie9427962011-04-28 15:46:07 +020011337 spec->automute = 1;
11338 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai42171c12009-05-08 14:11:43 +020011339}
11340
11341
Takashi Iwaia9111322011-05-02 11:30:18 +020011342static const struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011343 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011344 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011345 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11346 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11347 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11348 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11349 { } /* end */
11350};
11351
Takashi Iwaia9111322011-05-02 11:30:18 +020011352static const struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011353 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11354 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011355 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11356 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11357 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11358 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11359 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11360 { } /* end */
11361};
Kailang Yang272a5272007-05-14 11:00:38 +020011362
Takashi Iwaia9111322011-05-02 11:30:18 +020011363static const struct snd_kcontrol_new alc262_tyan_mixer[] = {
Tony Vroonba340e82009-02-02 19:01:30 +000011364 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11365 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11366 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11367 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11368 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11369 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11370 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11371 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011372 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroonba340e82009-02-02 19:01:30 +000011373 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11374 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011375 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tony Vroonba340e82009-02-02 19:01:30 +000011376 { } /* end */
11377};
11378
Takashi Iwaia9111322011-05-02 11:30:18 +020011379static const struct hda_verb alc262_tyan_verbs[] = {
Tony Vroonba340e82009-02-02 19:01:30 +000011380 /* Headphone automute */
11381 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11382 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11383 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11384
11385 /* P11 AUX_IN, white 4-pin connector */
11386 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11387 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11388 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11389 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11390
11391 {}
11392};
11393
11394/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011395static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011396{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011397 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011398
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011399 spec->autocfg.hp_pins[0] = 0x1b;
11400 spec->autocfg.speaker_pins[0] = 0x15;
Takashi Iwaid922b512011-04-28 12:18:53 +020011401 spec->automute = 1;
11402 spec->automute_mode = ALC_AUTOMUTE_AMP;
Tony Vroonba340e82009-02-02 19:01:30 +000011403}
11404
Tony Vroonba340e82009-02-02 19:01:30 +000011405
Kailang Yangdf694da2005-12-05 19:42:22 +010011406#define alc262_capture_mixer alc882_capture_mixer
11407#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11408
11409/*
11410 * generic initialization of ADC, input mixers and output mixers
11411 */
Takashi Iwaia9111322011-05-02 11:30:18 +020011412static const struct hda_verb alc262_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010011413 /*
11414 * Unmute ADC0-2 and set the default input to mic-in
11415 */
11416 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11417 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11418 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11419 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11420 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11421 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11422
Takashi Iwaicb53c622007-08-10 17:21:45 +020011423 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011424 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011425 * Note: PASD motherboards uses the Line In 2 as the input for
11426 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011427 */
11428 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011429 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11430 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11431 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11432 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11433 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011434
11435 /*
11436 * Set up output mixers (0x0c - 0x0e)
11437 */
11438 /* set vol=0 to output mixers */
11439 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11440 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11441 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11442 /* set up input amps for analog loopback */
11443 /* Amp Indices: DAC = 0, mixer = 1 */
11444 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11445 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11446 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11447 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11448 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11449 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11450
11451 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11452 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11453 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11454 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11455 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11456 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11457
11458 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11459 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11460 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11461 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11462 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011463
Kailang Yangdf694da2005-12-05 19:42:22 +010011464 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11465 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011466
Kailang Yangdf694da2005-12-05 19:42:22 +010011467 /* FIXME: use matrix-type input source selection */
11468 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11469 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11470 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11471 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11472 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11473 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11474 /* Input mixer2 */
11475 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11476 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11477 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11478 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11479 /* Input mixer3 */
11480 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11481 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11482 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011483 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011484
11485 { }
11486};
11487
Takashi Iwaia9111322011-05-02 11:30:18 +020011488static const struct hda_verb alc262_eapd_verbs[] = {
Kailang Yang4e555fe2008-08-26 13:05:55 +020011489 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11490 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11491 { }
11492};
11493
Takashi Iwaia9111322011-05-02 11:30:18 +020011494static const struct hda_verb alc262_hippo1_unsol_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +020011495 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11496 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11497 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11498
11499 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11500 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11501 {}
11502};
11503
Takashi Iwaia9111322011-05-02 11:30:18 +020011504static const struct hda_verb alc262_sony_unsol_verbs[] = {
Kailang Yang272a5272007-05-14 11:00:38 +020011505 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11506 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11507 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11508
11509 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11510 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011511 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011512};
11513
Takashi Iwaia9111322011-05-02 11:30:18 +020011514static const struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
Kailang Yang4e555fe2008-08-26 13:05:55 +020011515 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11516 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11517 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11518 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11519 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011520 { } /* end */
11521};
11522
Takashi Iwaia9111322011-05-02 11:30:18 +020011523static const struct hda_verb alc262_toshiba_s06_verbs[] = {
Kailang Yang4e555fe2008-08-26 13:05:55 +020011524 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11525 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11526 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11527 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11528 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11529 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11530 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11531 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11532 {}
11533};
11534
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011535static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011536{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011537 struct alc_spec *spec = codec->spec;
11538
11539 spec->autocfg.hp_pins[0] = 0x15;
11540 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011541 spec->ext_mic.pin = 0x18;
11542 spec->ext_mic.mux_idx = 0;
11543 spec->int_mic.pin = 0x12;
11544 spec->int_mic.mux_idx = 9;
11545 spec->auto_mic = 1;
Takashi Iwaid922b512011-04-28 12:18:53 +020011546 spec->automute = 1;
11547 spec->automute_mode = ALC_AUTOMUTE_PIN;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011548}
11549
Takashi Iwai834be882006-03-01 14:16:17 +010011550/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011551 * nec model
11552 * 0x15 = headphone
11553 * 0x16 = internal speaker
11554 * 0x18 = external mic
11555 */
11556
Takashi Iwaia9111322011-05-02 11:30:18 +020011557static const struct snd_kcontrol_new alc262_nec_mixer[] = {
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011558 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11559 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11560
11561 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11562 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011563 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011564
11565 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11566 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11567 { } /* end */
11568};
11569
Takashi Iwaia9111322011-05-02 11:30:18 +020011570static const struct hda_verb alc262_nec_verbs[] = {
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011571 /* Unmute Speaker */
11572 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11573
11574 /* Headphone */
11575 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11576 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11577
11578 /* External mic to headphone */
11579 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11580 /* External mic to speaker */
11581 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11582 {}
11583};
11584
11585/*
Takashi Iwai834be882006-03-01 14:16:17 +010011586 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011587 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11588 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011589 */
11590
Takashi Iwai20f5e0b2011-06-10 09:31:54 +020011591#define ALC_HP_EVENT ALC880_HP_EVENT
Takashi Iwai834be882006-03-01 14:16:17 +010011592
Takashi Iwaia9111322011-05-02 11:30:18 +020011593static const struct hda_verb alc262_fujitsu_unsol_verbs[] = {
Takashi Iwai834be882006-03-01 14:16:17 +010011594 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11595 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011596 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11597 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011598 {}
11599};
11600
Takashi Iwaia9111322011-05-02 11:30:18 +020011601static const struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
Jiang zhe0e31daf2008-03-20 12:12:39 +010011602 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11603 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11604 {}
11605};
11606
Takashi Iwaia9111322011-05-02 11:30:18 +020011607static const struct hda_verb alc262_lenovo_3000_init_verbs[] = {
Daniel T Chene2595322009-12-19 18:19:02 -050011608 /* Front Mic pin: input vref at 50% */
11609 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11610 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11611 {}
11612};
11613
Takashi Iwaia9111322011-05-02 11:30:18 +020011614static const struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011615 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011616 .items = {
11617 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +010011618 { "Internal Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011619 { "CD", 0x4 },
11620 },
11621};
11622
Takashi Iwaia9111322011-05-02 11:30:18 +020011623static const struct hda_input_mux alc262_HP_capture_source = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011624 .num_items = 5,
11625 .items = {
11626 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011627 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011628 { "Line", 0x2 },
11629 { "CD", 0x4 },
11630 { "AUX IN", 0x6 },
11631 },
11632};
11633
Takashi Iwaia9111322011-05-02 11:30:18 +020011634static const struct hda_input_mux alc262_HP_D7000_capture_source = {
zhejiangaccbe492007-08-31 12:36:05 +020011635 .num_items = 4,
11636 .items = {
11637 { "Mic", 0x0 },
11638 { "Front Mic", 0x2 },
11639 { "Line", 0x1 },
11640 { "CD", 0x4 },
11641 },
11642};
11643
Takashi Iwai0f0f3912011-04-28 16:26:24 +020011644static void alc262_fujitsu_setup(struct hda_codec *codec)
Takashi Iwai834be882006-03-01 14:16:17 +010011645{
11646 struct alc_spec *spec = codec->spec;
Takashi Iwai834be882006-03-01 14:16:17 +010011647
Takashi Iwai0f0f3912011-04-28 16:26:24 +020011648 spec->autocfg.hp_pins[0] = 0x14;
11649 spec->autocfg.hp_pins[1] = 0x1b;
11650 spec->autocfg.speaker_pins[0] = 0x15;
11651 spec->automute = 1;
11652 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011653}
11654
Takashi Iwai834be882006-03-01 14:16:17 +010011655/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaia9111322011-05-02 11:30:18 +020011656static const struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011657 .ops = &snd_hda_bind_vol,
11658 .values = {
11659 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11660 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11661 0
11662 },
11663};
Takashi Iwai834be882006-03-01 14:16:17 +010011664
Takashi Iwaia9111322011-05-02 11:30:18 +020011665static const struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011666 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011667 {
11668 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11669 .name = "Master Playback Switch",
Takashi Iwai0f0f3912011-04-28 16:26:24 +020011670 .subdevice = HDA_SUBDEV_NID_FLAG | 0x14,
11671 .info = snd_ctl_boolean_mono_info,
11672 .get = alc262_hp_master_sw_get,
11673 .put = alc262_hp_master_sw_put,
Takashi Iwai834be882006-03-01 14:16:17 +010011674 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011675 {
11676 .iface = NID_MAPPING,
11677 .name = "Master Playback Switch",
11678 .private_value = 0x1b,
11679 },
Takashi Iwai834be882006-03-01 14:16:17 +010011680 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11681 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011682 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011683 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11684 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011685 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010011686 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11687 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011688 { } /* end */
11689};
11690
Takashi Iwai0f0f3912011-04-28 16:26:24 +020011691static void alc262_lenovo_3000_setup(struct hda_codec *codec)
Jiang zhe0e31daf2008-03-20 12:12:39 +010011692{
Takashi Iwai0f0f3912011-04-28 16:26:24 +020011693 struct alc_spec *spec = codec->spec;
Jiang zhe0e31daf2008-03-20 12:12:39 +010011694
Takashi Iwai0f0f3912011-04-28 16:26:24 +020011695 spec->autocfg.hp_pins[0] = 0x1b;
11696 spec->autocfg.speaker_pins[0] = 0x14;
11697 spec->autocfg.speaker_pins[1] = 0x16;
11698 spec->automute = 1;
11699 spec->automute_mode = ALC_AUTOMUTE_AMP;
Jiang zhe0e31daf2008-03-20 12:12:39 +010011700}
11701
Takashi Iwaia9111322011-05-02 11:30:18 +020011702static const struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
Jiang zhe0e31daf2008-03-20 12:12:39 +010011703 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11704 {
11705 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11706 .name = "Master Playback Switch",
Takashi Iwai0f0f3912011-04-28 16:26:24 +020011707 .subdevice = HDA_SUBDEV_NID_FLAG | 0x1b,
11708 .info = snd_ctl_boolean_mono_info,
11709 .get = alc262_hp_master_sw_get,
11710 .put = alc262_hp_master_sw_put,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011711 },
11712 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11713 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011714 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011715 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11716 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011717 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010011718 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11719 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011720 { } /* end */
11721};
11722
Takashi Iwaia9111322011-05-02 11:30:18 +020011723static const struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011724 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011725 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011726 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11727 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011728 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011729 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11730 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011731 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011732 { } /* end */
11733};
11734
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011735/* additional init verbs for Benq laptops */
Takashi Iwaia9111322011-05-02 11:30:18 +020011736static const struct hda_verb alc262_EAPD_verbs[] = {
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011737 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11738 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11739 {}
11740};
11741
Takashi Iwaia9111322011-05-02 11:30:18 +020011742static const struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
Kailang Yang83c34212007-07-05 11:43:05 +020011743 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11744 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11745
11746 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11747 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11748 {}
11749};
11750
Tobin Davisf651b502007-10-26 12:40:47 +020011751/* Samsung Q1 Ultra Vista model setup */
Takashi Iwaia9111322011-05-02 11:30:18 +020011752static const struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011753 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11754 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011755 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11756 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011757 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
11758 HDA_CODEC_VOLUME("Headphone Mic Boost Volume", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011759 { } /* end */
11760};
11761
Takashi Iwaia9111322011-05-02 11:30:18 +020011762static const struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011763 /* output mixer */
11764 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11765 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11766 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11767 /* speaker */
11768 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11769 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11770 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11771 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11772 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011773 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011774 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11775 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11776 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11777 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11778 /* internal mic */
11779 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11780 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11781 /* ADC, choose mic */
11782 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11783 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11784 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11785 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11786 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11787 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11788 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11789 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11790 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11791 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011792 {}
11793};
11794
Tobin Davisf651b502007-10-26 12:40:47 +020011795/* mute/unmute internal speaker according to the hp jack and mute state */
11796static void alc262_ultra_automute(struct hda_codec *codec)
11797{
11798 struct alc_spec *spec = codec->spec;
11799 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011800
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011801 mute = 0;
11802 /* auto-mute only when HP is used as HP */
11803 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011804 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011805 if (spec->jack_present)
11806 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011807 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011808 /* mute/unmute internal speaker */
11809 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11810 HDA_AMP_MUTE, mute);
11811 /* mute/unmute HP */
11812 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11813 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011814}
11815
11816/* unsolicited event for HP jack sensing */
11817static void alc262_ultra_unsol_event(struct hda_codec *codec,
11818 unsigned int res)
11819{
11820 if ((res >> 26) != ALC880_HP_EVENT)
11821 return;
11822 alc262_ultra_automute(codec);
11823}
11824
Takashi Iwaia9111322011-05-02 11:30:18 +020011825static const struct hda_input_mux alc262_ultra_capture_source = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011826 .num_items = 2,
11827 .items = {
11828 { "Mic", 0x1 },
11829 { "Headphone", 0x7 },
11830 },
11831};
11832
11833static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11834 struct snd_ctl_elem_value *ucontrol)
11835{
11836 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11837 struct alc_spec *spec = codec->spec;
11838 int ret;
11839
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011840 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011841 if (!ret)
11842 return 0;
11843 /* reprogram the HP pin as mic or HP according to the input source */
11844 snd_hda_codec_write_cache(codec, 0x15, 0,
11845 AC_VERB_SET_PIN_WIDGET_CONTROL,
11846 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11847 alc262_ultra_automute(codec); /* mute/unmute HP */
11848 return ret;
11849}
11850
Takashi Iwaia9111322011-05-02 11:30:18 +020011851static const struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011852 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11853 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11854 {
11855 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11856 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011857 .info = alc_mux_enum_info,
11858 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011859 .put = alc262_ultra_mux_enum_put,
11860 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011861 {
11862 .iface = NID_MAPPING,
11863 .name = "Capture Source",
11864 .private_value = 0x15,
11865 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011866 { } /* end */
11867};
11868
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011869/* We use two mixers depending on the output pin; 0x16 is a mono output
11870 * and thus it's bound with a different mixer.
11871 * This function returns which mixer amp should be used.
11872 */
11873static int alc262_check_volbit(hda_nid_t nid)
11874{
11875 if (!nid)
11876 return 0;
11877 else if (nid == 0x16)
11878 return 2;
11879 else
11880 return 1;
11881}
11882
11883static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020011884 const char *pfx, int *vbits, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011885{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011886 unsigned long val;
11887 int vbit;
11888
11889 vbit = alc262_check_volbit(nid);
11890 if (!vbit)
11891 return 0;
11892 if (*vbits & vbit) /* a volume control for this mixer already there */
11893 return 0;
11894 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011895 if (vbit == 2)
11896 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11897 else
11898 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020011899 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011900}
11901
11902static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020011903 const char *pfx, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011904{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011905 unsigned long val;
11906
11907 if (!nid)
11908 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011909 if (nid == 0x16)
11910 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11911 else
11912 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020011913 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011914}
11915
Kailang Yangdf694da2005-12-05 19:42:22 +010011916/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011917static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11918 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011919{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011920 const char *pfx;
11921 int vbits;
Takashi Iwai6843ca12011-06-24 11:03:58 +020011922 int i, index, err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011923
11924 spec->multiout.num_dacs = 1; /* only use one dac */
11925 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaidda14412011-05-02 11:29:30 +020011926 spec->private_dac_nids[0] = 2;
Kailang Yangdf694da2005-12-05 19:42:22 +010011927
Takashi Iwai033688a2010-09-08 15:47:09 +020011928 for (i = 0; i < 2; i++) {
Takashi Iwai6843ca12011-06-24 11:03:58 +020011929 pfx = alc_get_line_out_pfx(spec, i, true, &index);
11930 if (!pfx)
11931 pfx = "PCM";
11932 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx,
11933 index);
Takashi Iwai033688a2010-09-08 15:47:09 +020011934 if (err < 0)
11935 return err;
11936 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
11937 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i],
11938 "Speaker", i);
11939 if (err < 0)
11940 return err;
11941 }
11942 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
11943 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i],
11944 "Headphone", i);
11945 if (err < 0)
11946 return err;
11947 }
11948 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011949
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011950 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11951 alc262_check_volbit(cfg->speaker_pins[0]) |
11952 alc262_check_volbit(cfg->hp_pins[0]);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011953 vbits = 0;
Takashi Iwai033688a2010-09-08 15:47:09 +020011954 for (i = 0; i < 2; i++) {
Takashi Iwai6843ca12011-06-24 11:03:58 +020011955 pfx = alc_get_line_out_pfx(spec, i, true, &index);
11956 if (!pfx)
11957 pfx = "PCM";
Takashi Iwai033688a2010-09-08 15:47:09 +020011958 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx,
11959 &vbits, i);
11960 if (err < 0)
11961 return err;
11962 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
11963 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i],
11964 "Speaker", &vbits, i);
11965 if (err < 0)
11966 return err;
11967 }
11968 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
11969 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i],
11970 "Headphone", &vbits, i);
11971 if (err < 0)
11972 return err;
11973 }
11974 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011975 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011976}
11977
Takashi Iwaia9111322011-05-02 11:30:18 +020011978static const struct hda_verb alc262_HP_BPC_init_verbs[] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011979 /*
11980 * Unmute ADC0-2 and set the default input to mic-in
11981 */
11982 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11983 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11984 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11985 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11986 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11987 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11988
Takashi Iwaicb53c622007-08-10 17:21:45 +020011989 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011990 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011991 * Note: PASD motherboards uses the Line In 2 as the input for
11992 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011993 */
11994 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011995 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11996 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11997 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11998 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11999 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12000 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12001 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012002
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012003 /*
12004 * Set up output mixers (0x0c - 0x0e)
12005 */
12006 /* set vol=0 to output mixers */
12007 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12008 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12009 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12010
12011 /* set up input amps for analog loopback */
12012 /* Amp Indices: DAC = 0, mixer = 1 */
12013 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12014 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12015 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12016 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12017 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12018 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12019
Takashi Iwaice875f02008-01-28 18:17:43 +010012020 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012021 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12022 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12023
12024 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12025 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12026
12027 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12028 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12029
12030 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12031 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12032 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12033 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12034 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12035
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012036 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012037 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12038 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012039 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012040 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12041 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12042
12043
12044 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012045 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
12046 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012047 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012048 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12049 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12050 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12051 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12052 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12053 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12054 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12055 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012056 /* Input mixer2 */
12057 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012058 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12059 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12060 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12061 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12062 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12063 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12064 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12065 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012066 /* Input mixer3 */
12067 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012068 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12069 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12070 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12071 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12072 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12073 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12074 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12075 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012076
Takashi Iwaice875f02008-01-28 18:17:43 +010012077 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12078
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012079 { }
12080};
12081
Takashi Iwaia9111322011-05-02 11:30:18 +020012082static const struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
Kailang Yangcd7509a2007-01-26 18:33:17 +010012083 /*
12084 * Unmute ADC0-2 and set the default input to mic-in
12085 */
12086 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12087 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12088 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12089 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12090 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12091 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12092
Takashi Iwaicb53c622007-08-10 17:21:45 +020012093 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010012094 * mixer widget
12095 * Note: PASD motherboards uses the Line In 2 as the input for front
12096 * panel mic (mic 2)
12097 */
12098 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012099 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12100 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12101 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12102 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12103 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12104 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12105 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12106 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010012107 /*
12108 * Set up output mixers (0x0c - 0x0e)
12109 */
12110 /* set vol=0 to output mixers */
12111 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12112 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12113 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12114
12115 /* set up input amps for analog loopback */
12116 /* Amp Indices: DAC = 0, mixer = 1 */
12117 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12118 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12119 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12120 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12121 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12122 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12123
12124
12125 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
12126 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
12127 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
12128 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
12129 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12130 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
12131 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
12132
12133 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12134 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12135
12136 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12137 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12138
12139 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
12140 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12141 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12142 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
12143 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12144 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12145
12146 /* FIXME: use matrix-type input source selection */
12147 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12148 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12149 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
12150 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
12151 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
12152 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
12153 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
12154 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12155 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
12156 /* Input mixer2 */
12157 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12158 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12159 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12160 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12161 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12162 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12163 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12164 /* Input mixer3 */
12165 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12166 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12167 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12168 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12169 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12170 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12171 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12172
Takashi Iwaice875f02008-01-28 18:17:43 +010012173 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12174
Kailang Yangcd7509a2007-01-26 18:33:17 +010012175 { }
12176};
12177
Takashi Iwaia9111322011-05-02 11:30:18 +020012178static const struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012179
12180 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12181 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12182 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12183
12184 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12185 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12186 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12187 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12188
12189 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12190 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12191 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12192 {}
12193};
12194
Takashi Iwai18675e42010-09-08 15:55:44 +020012195/*
12196 * Pin config fixes
12197 */
12198enum {
12199 PINFIX_FSC_H270,
David Henningssond2a19da2011-06-22 09:58:37 +020012200 PINFIX_HP_Z200,
Takashi Iwai18675e42010-09-08 15:55:44 +020012201};
12202
12203static const struct alc_fixup alc262_fixups[] = {
12204 [PINFIX_FSC_H270] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010012205 .type = ALC_FIXUP_PINS,
12206 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai18675e42010-09-08 15:55:44 +020012207 { 0x14, 0x99130110 }, /* speaker */
12208 { 0x15, 0x0221142f }, /* front HP */
12209 { 0x1b, 0x0121141f }, /* rear HP */
12210 { }
12211 }
12212 },
David Henningssond2a19da2011-06-22 09:58:37 +020012213 [PINFIX_HP_Z200] = {
12214 .type = ALC_FIXUP_PINS,
12215 .v.pins = (const struct alc_pincfg[]) {
12216 { 0x16, 0x99130120 }, /* internal speaker */
12217 { }
12218 }
12219 },
Takashi Iwai18675e42010-09-08 15:55:44 +020012220};
12221
Takashi Iwaia9111322011-05-02 11:30:18 +020012222static const struct snd_pci_quirk alc262_fixup_tbl[] = {
David Henningssond2a19da2011-06-22 09:58:37 +020012223 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", PINFIX_HP_Z200),
Takashi Iwai18675e42010-09-08 15:55:44 +020012224 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270),
12225 {}
12226};
12227
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012228
Takashi Iwaicb53c622007-08-10 17:21:45 +020012229#ifdef CONFIG_SND_HDA_POWER_SAVE
12230#define alc262_loopbacks alc880_loopbacks
12231#endif
12232
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012233/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012234#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12235#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12236#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12237#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12238
12239/*
12240 * BIOS auto configuration
12241 */
12242static int alc262_parse_auto_config(struct hda_codec *codec)
12243{
12244 struct alc_spec *spec = codec->spec;
12245 int err;
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020012246 static const hda_nid_t alc262_ignore[] = { 0x1d, 0 };
Kailang Yangdf694da2005-12-05 19:42:22 +010012247
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012248 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12249 alc262_ignore);
12250 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012251 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012252 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012253 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012254 spec->multiout.max_channels = 2;
12255 spec->no_analog = 1;
12256 goto dig_only;
12257 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012258 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012259 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012260 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12261 if (err < 0)
12262 return err;
Takashi Iwaib7821702011-07-06 15:12:46 +020012263 err = alc_auto_create_input_ctls(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012264 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012265 return err;
12266
12267 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12268
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012269 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012270 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012271
Takashi Iwai603c4012008-07-30 15:01:44 +020012272 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012273 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012274
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012275 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012276 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012277
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +020012278 if (!spec->dual_adc_switch)
12279 alc_remove_invalid_adc_nids(codec);
12280
Takashi Iwai776e1842007-08-29 15:07:11 +020012281 err = alc_auto_add_mic_boost(codec);
12282 if (err < 0)
12283 return err;
12284
Kailang Yang6227cdc2010-02-25 08:36:52 +010012285 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012286
Kailang Yangdf694da2005-12-05 19:42:22 +010012287 return 1;
12288}
12289
Kailang Yangdf694da2005-12-05 19:42:22 +010012290
12291/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012292static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012293{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012294 struct alc_spec *spec = codec->spec;
Takashi Iwai343a04b2011-07-06 14:28:39 +020012295 alc_auto_init_multi_out(codec);
12296 alc_auto_init_extra_out(codec);
Takashi Iwai0a7f5322011-07-06 15:15:12 +020012297 alc_auto_init_analog_input(codec);
Takashi Iwaif970de22011-07-06 17:39:59 +020012298 alc_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012299 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012300 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012301 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012302}
12303
12304/*
12305 * configuration and preset
12306 */
Takashi Iwaiea734962011-01-17 11:29:34 +010012307static const char * const alc262_models[ALC262_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012308 [ALC262_BASIC] = "basic",
12309 [ALC262_HIPPO] = "hippo",
12310 [ALC262_HIPPO_1] = "hippo_1",
12311 [ALC262_FUJITSU] = "fujitsu",
12312 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012313 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012314 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012315 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012316 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012317 [ALC262_BENQ_T31] = "benq-t31",
12318 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012319 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012320 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012321 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012322 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012323 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012324 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012325 [ALC262_AUTO] = "auto",
12326};
12327
Takashi Iwaia9111322011-05-02 11:30:18 +020012328static const struct snd_pci_quirk alc262_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012329 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012330 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012331 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12332 ALC262_HP_BPC),
12333 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12334 ALC262_HP_BPC),
Takashi Iwai5734a072011-01-19 17:07:12 +010012335 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1500, "HP z series",
12336 ALC262_HP_BPC),
David Henningssond2a19da2011-06-22 09:58:37 +020012337 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200",
12338 ALC262_AUTO),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012339 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12340 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012341 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012342 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012343 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012344 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012345 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012346 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012347 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012348 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012349 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12350 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12351 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012352 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12353 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012354 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012355 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012356 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012357 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012358 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012359 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012360 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012361 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012362#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012363 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12364 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012365#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012366 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012367 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012368 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012369 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012370 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012371 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012372 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12373 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012374 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012375 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012376 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012377 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012378 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012379 {}
12380};
12381
Takashi Iwaia9111322011-05-02 11:30:18 +020012382static const struct alc_config_preset alc262_presets[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010012383 [ALC262_BASIC] = {
12384 .mixers = { alc262_base_mixer },
12385 .init_verbs = { alc262_init_verbs },
12386 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12387 .dac_nids = alc262_dac_nids,
12388 .hp_nid = 0x03,
12389 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12390 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012391 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012392 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012393 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012394 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012395 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012396 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12397 .dac_nids = alc262_dac_nids,
12398 .hp_nid = 0x03,
12399 .dig_out_nid = ALC262_DIGOUT_NID,
12400 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12401 .channel_mode = alc262_modes,
12402 .input_mux = &alc262_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012403 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012404 .setup = alc262_hippo_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020012405 .init_hook = alc_inithook,
Kailang Yangccc656c2006-10-17 12:32:26 +020012406 },
12407 [ALC262_HIPPO_1] = {
12408 .mixers = { alc262_hippo1_mixer },
12409 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12410 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12411 .dac_nids = alc262_dac_nids,
12412 .hp_nid = 0x02,
12413 .dig_out_nid = ALC262_DIGOUT_NID,
12414 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12415 .channel_mode = alc262_modes,
12416 .input_mux = &alc262_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012417 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012418 .setup = alc262_hippo1_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020012419 .init_hook = alc_inithook,
Kailang Yangccc656c2006-10-17 12:32:26 +020012420 },
Takashi Iwai834be882006-03-01 14:16:17 +010012421 [ALC262_FUJITSU] = {
12422 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012423 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12424 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012425 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12426 .dac_nids = alc262_dac_nids,
12427 .hp_nid = 0x03,
12428 .dig_out_nid = ALC262_DIGOUT_NID,
12429 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12430 .channel_mode = alc262_modes,
12431 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwai0f0f3912011-04-28 16:26:24 +020012432 .unsol_event = alc_sku_unsol_event,
12433 .setup = alc262_fujitsu_setup,
12434 .init_hook = alc_inithook,
Takashi Iwai834be882006-03-01 14:16:17 +010012435 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012436 [ALC262_HP_BPC] = {
12437 .mixers = { alc262_HP_BPC_mixer },
12438 .init_verbs = { alc262_HP_BPC_init_verbs },
12439 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12440 .dac_nids = alc262_dac_nids,
12441 .hp_nid = 0x03,
12442 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12443 .channel_mode = alc262_modes,
12444 .input_mux = &alc262_HP_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012445 .unsol_event = alc_sku_unsol_event,
12446 .setup = alc262_hp_bpc_setup,
12447 .init_hook = alc_inithook,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012448 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012449 [ALC262_HP_BPC_D7000_WF] = {
12450 .mixers = { alc262_HP_BPC_WildWest_mixer },
12451 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12452 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12453 .dac_nids = alc262_dac_nids,
12454 .hp_nid = 0x03,
12455 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12456 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012457 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012458 .unsol_event = alc_sku_unsol_event,
12459 .setup = alc262_hp_wildwest_setup,
12460 .init_hook = alc_inithook,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012461 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012462 [ALC262_HP_BPC_D7000_WL] = {
12463 .mixers = { alc262_HP_BPC_WildWest_mixer,
12464 alc262_HP_BPC_WildWest_option_mixer },
12465 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12466 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12467 .dac_nids = alc262_dac_nids,
12468 .hp_nid = 0x03,
12469 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12470 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012471 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012472 .unsol_event = alc_sku_unsol_event,
12473 .setup = alc262_hp_wildwest_setup,
12474 .init_hook = alc_inithook,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012475 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012476 [ALC262_HP_TC_T5735] = {
12477 .mixers = { alc262_hp_t5735_mixer },
12478 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12479 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12480 .dac_nids = alc262_dac_nids,
12481 .hp_nid = 0x03,
12482 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12483 .channel_mode = alc262_modes,
12484 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012485 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012486 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012487 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012488 },
12489 [ALC262_HP_RP5700] = {
12490 .mixers = { alc262_hp_rp5700_mixer },
12491 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12492 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12493 .dac_nids = alc262_dac_nids,
12494 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12495 .channel_mode = alc262_modes,
12496 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012497 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012498 [ALC262_BENQ_ED8] = {
12499 .mixers = { alc262_base_mixer },
12500 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12501 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12502 .dac_nids = alc262_dac_nids,
12503 .hp_nid = 0x03,
12504 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12505 .channel_mode = alc262_modes,
12506 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012507 },
Kailang Yang272a5272007-05-14 11:00:38 +020012508 [ALC262_SONY_ASSAMD] = {
12509 .mixers = { alc262_sony_mixer },
12510 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12511 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12512 .dac_nids = alc262_dac_nids,
12513 .hp_nid = 0x02,
12514 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12515 .channel_mode = alc262_modes,
12516 .input_mux = &alc262_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012517 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012518 .setup = alc262_hippo_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020012519 .init_hook = alc_inithook,
Kailang Yang83c34212007-07-05 11:43:05 +020012520 },
12521 [ALC262_BENQ_T31] = {
12522 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012523 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12524 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012525 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12526 .dac_nids = alc262_dac_nids,
12527 .hp_nid = 0x03,
12528 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12529 .channel_mode = alc262_modes,
12530 .input_mux = &alc262_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012531 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012532 .setup = alc262_hippo_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020012533 .init_hook = alc_inithook,
Kailang Yangea1fb292008-08-26 12:58:38 +020012534 },
Tobin Davisf651b502007-10-26 12:40:47 +020012535 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012536 .mixers = { alc262_ultra_mixer },
12537 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012538 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012539 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12540 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012541 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12542 .channel_mode = alc262_modes,
12543 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012544 .adc_nids = alc262_adc_nids, /* ADC0 */
12545 .capsrc_nids = alc262_capsrc_nids,
12546 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012547 .unsol_event = alc262_ultra_unsol_event,
12548 .init_hook = alc262_ultra_automute,
12549 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012550 [ALC262_LENOVO_3000] = {
12551 .mixers = { alc262_lenovo_3000_mixer },
12552 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012553 alc262_lenovo_3000_unsol_verbs,
12554 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012555 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12556 .dac_nids = alc262_dac_nids,
12557 .hp_nid = 0x03,
12558 .dig_out_nid = ALC262_DIGOUT_NID,
12559 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12560 .channel_mode = alc262_modes,
12561 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwai0f0f3912011-04-28 16:26:24 +020012562 .unsol_event = alc_sku_unsol_event,
12563 .setup = alc262_lenovo_3000_setup,
12564 .init_hook = alc_inithook,
Jiang zhe0e31daf2008-03-20 12:12:39 +010012565 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012566 [ALC262_NEC] = {
12567 .mixers = { alc262_nec_mixer },
12568 .init_verbs = { alc262_nec_verbs },
12569 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12570 .dac_nids = alc262_dac_nids,
12571 .hp_nid = 0x03,
12572 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12573 .channel_mode = alc262_modes,
12574 .input_mux = &alc262_capture_source,
12575 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012576 [ALC262_TOSHIBA_S06] = {
12577 .mixers = { alc262_toshiba_s06_mixer },
12578 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12579 alc262_eapd_verbs },
12580 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12581 .capsrc_nids = alc262_dmic_capsrc_nids,
12582 .dac_nids = alc262_dac_nids,
12583 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012584 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012585 .dig_out_nid = ALC262_DIGOUT_NID,
12586 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12587 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012588 .unsol_event = alc_sku_unsol_event,
12589 .setup = alc262_toshiba_s06_setup,
12590 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012591 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012592 [ALC262_TOSHIBA_RX1] = {
12593 .mixers = { alc262_toshiba_rx1_mixer },
12594 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12595 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12596 .dac_nids = alc262_dac_nids,
12597 .hp_nid = 0x03,
12598 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12599 .channel_mode = alc262_modes,
12600 .input_mux = &alc262_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012601 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012602 .setup = alc262_hippo_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020012603 .init_hook = alc_inithook,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012604 },
Tony Vroonba340e82009-02-02 19:01:30 +000012605 [ALC262_TYAN] = {
12606 .mixers = { alc262_tyan_mixer },
12607 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12608 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12609 .dac_nids = alc262_dac_nids,
12610 .hp_nid = 0x02,
12611 .dig_out_nid = ALC262_DIGOUT_NID,
12612 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12613 .channel_mode = alc262_modes,
12614 .input_mux = &alc262_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020012615 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012616 .setup = alc262_tyan_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020012617 .init_hook = alc_hp_automute,
Tony Vroonba340e82009-02-02 19:01:30 +000012618 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012619};
12620
12621static int patch_alc262(struct hda_codec *codec)
12622{
12623 struct alc_spec *spec;
12624 int board_config;
12625 int err;
12626
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012627 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012628 if (spec == NULL)
12629 return -ENOMEM;
12630
12631 codec->spec = spec;
Takashi Iwai1f0f4b82011-06-27 10:52:59 +020012632
12633 spec->mixer_nid = 0x0b;
12634
Kailang Yangdf694da2005-12-05 19:42:22 +010012635#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012636 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12637 * under-run
12638 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012639 {
12640 int tmp;
12641 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12642 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12643 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12644 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12645 }
12646#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012647 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012648
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012649 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12650
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012651 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12652 alc262_models,
12653 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012654
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012655 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012656 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12657 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012658 board_config = ALC262_AUTO;
12659 }
12660
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010012661 if (board_config == ALC262_AUTO) {
12662 alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups);
12663 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
12664 }
Takashi Iwai18675e42010-09-08 15:55:44 +020012665
Kailang Yangdf694da2005-12-05 19:42:22 +010012666 if (board_config == ALC262_AUTO) {
12667 /* automatic parse from the BIOS config */
12668 err = alc262_parse_auto_config(codec);
12669 if (err < 0) {
12670 alc_free(codec);
12671 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012672 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012673 printk(KERN_INFO
12674 "hda_codec: Cannot set up configuration "
12675 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012676 board_config = ALC262_BASIC;
12677 }
12678 }
12679
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012680 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010012681 err = snd_hda_attach_beep_device(codec, 0x1);
12682 if (err < 0) {
12683 alc_free(codec);
12684 return err;
12685 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012686 }
12687
Kailang Yangdf694da2005-12-05 19:42:22 +010012688 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012689 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012690
Kailang Yangdf694da2005-12-05 19:42:22 +010012691 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12692 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012693
Kailang Yangdf694da2005-12-05 19:42:22 +010012694 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12695 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12696
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012697 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +020012698 alc_auto_fill_adc_caps(codec);
12699 alc_remove_invalid_adc_nids(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012700 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012701 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012702 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012703 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010012704 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012705
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010012706 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai18675e42010-09-08 15:55:44 +020012707
Takashi Iwai2134ea42008-01-10 16:53:55 +010012708 spec->vmaster_nid = 0x0c;
12709
Kailang Yangdf694da2005-12-05 19:42:22 +010012710 codec->patch_ops = alc_patch_ops;
12711 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012712 spec->init_hook = alc262_auto_init;
Takashi Iwai1c7161532011-04-07 10:37:16 +020012713 spec->shutup = alc_eapd_shutup;
Kailang Yangbf1b0222010-10-21 08:49:56 +020012714
12715 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020012716#ifdef CONFIG_SND_HDA_POWER_SAVE
12717 if (!spec->loopback.amplist)
12718 spec->loopback.amplist = alc262_loopbacks;
12719#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012720
Kailang Yangdf694da2005-12-05 19:42:22 +010012721 return 0;
12722}
12723
Kailang Yangdf694da2005-12-05 19:42:22 +010012724/*
Kailang Yanga361d842007-06-05 12:30:55 +020012725 * ALC268 channel source setting (2 channel)
12726 */
12727#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12728#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012729
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020012730static const hda_nid_t alc268_dac_nids[2] = {
Kailang Yanga361d842007-06-05 12:30:55 +020012731 /* front, hp */
12732 0x02, 0x03
12733};
12734
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020012735static const hda_nid_t alc268_adc_nids[2] = {
Kailang Yanga361d842007-06-05 12:30:55 +020012736 /* ADC0-1 */
12737 0x08, 0x07
12738};
12739
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020012740static const hda_nid_t alc268_adc_nids_alt[1] = {
Kailang Yanga361d842007-06-05 12:30:55 +020012741 /* ADC0 */
12742 0x08
12743};
12744
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020012745static const hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
Takashi Iwaie1406342008-02-11 18:32:32 +010012746
Takashi Iwaia9111322011-05-02 11:30:18 +020012747static const struct snd_kcontrol_new alc268_base_mixer[] = {
Kailang Yanga361d842007-06-05 12:30:55 +020012748 /* output mixer control */
12749 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12750 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12751 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12752 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010012753 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
12754 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
12755 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012756 { }
12757};
12758
Takashi Iwaia9111322011-05-02 11:30:18 +020012759static const struct snd_kcontrol_new alc268_toshiba_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012760 /* output mixer control */
12761 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12762 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12763 ALC262_HIPPO_MASTER_SWITCH,
David Henningsson5f99f862011-01-04 15:24:24 +010012764 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
12765 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
12766 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020012767 { }
12768};
12769
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012770/* bind Beep switches of both NID 0x0f and 0x10 */
Takashi Iwaia9111322011-05-02 11:30:18 +020012771static const struct hda_bind_ctls alc268_bind_beep_sw = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012772 .ops = &snd_hda_bind_sw,
12773 .values = {
12774 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12775 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12776 0
12777 },
12778};
12779
Takashi Iwaia9111322011-05-02 11:30:18 +020012780static const struct snd_kcontrol_new alc268_beep_mixer[] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012781 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12782 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12783 { }
12784};
12785
Takashi Iwaia9111322011-05-02 11:30:18 +020012786static const struct hda_verb alc268_eapd_verbs[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +020012787 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12788 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12789 { }
12790};
12791
Takashi Iwaid2738092007-08-16 14:59:45 +020012792/* Toshiba specific */
Takashi Iwaia9111322011-05-02 11:30:18 +020012793static const struct hda_verb alc268_toshiba_verbs[] = {
Takashi Iwaid2738092007-08-16 14:59:45 +020012794 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12795 { } /* end */
12796};
12797
12798/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020012799/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwaia9111322011-05-02 11:30:18 +020012800static const struct hda_bind_ctls alc268_acer_bind_master_vol = {
Takashi Iwai6bc96852007-08-17 09:02:12 +020012801 .ops = &snd_hda_bind_vol,
12802 .values = {
12803 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12804 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12805 0
12806 },
12807};
12808
Takashi Iwai0f0f3912011-04-28 16:26:24 +020012809static void alc268_acer_setup(struct hda_codec *codec)
Takashi Iwai889c4392007-08-23 18:56:52 +020012810{
12811 struct alc_spec *spec = codec->spec;
Takashi Iwai889c4392007-08-23 18:56:52 +020012812
Takashi Iwai0f0f3912011-04-28 16:26:24 +020012813 spec->autocfg.hp_pins[0] = 0x14;
12814 spec->autocfg.speaker_pins[0] = 0x15;
12815 spec->automute = 1;
12816 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai889c4392007-08-23 18:56:52 +020012817}
12818
Takashi Iwai0f0f3912011-04-28 16:26:24 +020012819#define alc268_acer_master_sw_get alc262_hp_master_sw_get
12820#define alc268_acer_master_sw_put alc262_hp_master_sw_put
Takashi Iwaid2738092007-08-16 14:59:45 +020012821
Takashi Iwaia9111322011-05-02 11:30:18 +020012822static const struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
Kailang Yang8ef355d2008-08-26 13:10:22 +020012823 /* output mixer control */
12824 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12825 {
12826 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12827 .name = "Master Playback Switch",
Takashi Iwai0f0f3912011-04-28 16:26:24 +020012828 .subdevice = HDA_SUBDEV_NID_FLAG | 0x15,
12829 .info = snd_ctl_boolean_mono_info,
12830 .get = alc268_acer_master_sw_get,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012831 .put = alc268_acer_master_sw_put,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012832 },
12833 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
12834 { }
12835};
12836
Takashi Iwaia9111322011-05-02 11:30:18 +020012837static const struct snd_kcontrol_new alc268_acer_mixer[] = {
Takashi Iwaid2738092007-08-16 14:59:45 +020012838 /* output mixer control */
12839 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12840 {
12841 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12842 .name = "Master Playback Switch",
Takashi Iwai0f0f3912011-04-28 16:26:24 +020012843 .subdevice = HDA_SUBDEV_NID_FLAG | 0x14,
12844 .info = snd_ctl_boolean_mono_info,
12845 .get = alc268_acer_master_sw_get,
Takashi Iwaid2738092007-08-16 14:59:45 +020012846 .put = alc268_acer_master_sw_put,
Takashi Iwaid2738092007-08-16 14:59:45 +020012847 },
David Henningsson5f99f862011-01-04 15:24:24 +010012848 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
12849 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
12850 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020012851 { }
12852};
12853
Takashi Iwaia9111322011-05-02 11:30:18 +020012854static const struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012855 /* output mixer control */
12856 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12857 {
12858 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12859 .name = "Master Playback Switch",
Takashi Iwai0f0f3912011-04-28 16:26:24 +020012860 .subdevice = HDA_SUBDEV_NID_FLAG | 0x14,
12861 .info = snd_ctl_boolean_mono_info,
12862 .get = alc268_acer_master_sw_get,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012863 .put = alc268_acer_master_sw_put,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012864 },
David Henningsson5f99f862011-01-04 15:24:24 +010012865 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
12866 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012867 { }
12868};
12869
Takashi Iwaia9111322011-05-02 11:30:18 +020012870static const struct hda_verb alc268_acer_aspire_one_verbs[] = {
Kailang Yang8ef355d2008-08-26 13:10:22 +020012871 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12872 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12873 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12874 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12875 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12876 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12877 { }
12878};
12879
Takashi Iwaia9111322011-05-02 11:30:18 +020012880static const struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012881 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12882 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012883 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12884 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012885 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12886 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012887 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12888 { }
12889};
12890
12891/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012892#define alc268_toshiba_setup alc262_hippo_setup
Takashi Iwaid2738092007-08-16 14:59:45 +020012893
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012894static void alc268_acer_lc_setup(struct hda_codec *codec)
12895{
12896 struct alc_spec *spec = codec->spec;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020012897 spec->autocfg.hp_pins[0] = 0x15;
12898 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020012899 spec->automute = 1;
Takashi Iwai54463a62011-06-13 08:32:06 +020012900 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012901 spec->ext_mic.pin = 0x18;
12902 spec->ext_mic.mux_idx = 0;
12903 spec->int_mic.pin = 0x12;
12904 spec->int_mic.mux_idx = 6;
12905 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012906}
12907
Takashi Iwaia9111322011-05-02 11:30:18 +020012908static const struct snd_kcontrol_new alc268_dell_mixer[] = {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012909 /* output mixer control */
12910 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12911 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12912 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12913 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010012914 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
12915 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012916 { }
12917};
12918
Takashi Iwaia9111322011-05-02 11:30:18 +020012919static const struct hda_verb alc268_dell_verbs[] = {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012920 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12921 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12922 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012923 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012924 { }
12925};
12926
12927/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012928static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012929{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012930 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012931
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012932 spec->autocfg.hp_pins[0] = 0x15;
12933 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012934 spec->ext_mic.pin = 0x18;
12935 spec->ext_mic.mux_idx = 0;
12936 spec->int_mic.pin = 0x19;
12937 spec->int_mic.mux_idx = 1;
12938 spec->auto_mic = 1;
Takashi Iwaid922b512011-04-28 12:18:53 +020012939 spec->automute = 1;
12940 spec->automute_mode = ALC_AUTOMUTE_PIN;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012941}
12942
Takashi Iwaia9111322011-05-02 11:30:18 +020012943static const struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012944 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12945 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12946 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12947 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12948 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12949 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010012950 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
12951 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012952 { }
12953};
12954
Takashi Iwaia9111322011-05-02 11:30:18 +020012955static const struct hda_verb alc267_quanta_il1_verbs[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012956 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12957 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12958 { }
12959};
12960
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012961static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012962{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012963 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012964 spec->autocfg.hp_pins[0] = 0x15;
12965 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012966 spec->ext_mic.pin = 0x18;
12967 spec->ext_mic.mux_idx = 0;
12968 spec->int_mic.pin = 0x19;
12969 spec->int_mic.mux_idx = 1;
12970 spec->auto_mic = 1;
Takashi Iwaid922b512011-04-28 12:18:53 +020012971 spec->automute = 1;
12972 spec->automute_mode = ALC_AUTOMUTE_PIN;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012973}
12974
Kailang Yanga361d842007-06-05 12:30:55 +020012975/*
12976 * generic initialization of ADC, input mixers and output mixers
12977 */
Takashi Iwaia9111322011-05-02 11:30:18 +020012978static const struct hda_verb alc268_base_init_verbs[] = {
Kailang Yanga361d842007-06-05 12:30:55 +020012979 /* Unmute DAC0-1 and set vol = 0 */
12980 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012981 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012982
12983 /*
12984 * Set up output mixers (0x0c - 0x0e)
12985 */
12986 /* set vol=0 to output mixers */
12987 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012988 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12989
12990 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12991 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12992
12993 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12994 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12995 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12996 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12997 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12998 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12999 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13000 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13001
13002 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13003 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13004 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13005 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013006 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013007
13008 /* set PCBEEP vol = 0, mute connections */
13009 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13010 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13011 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013012
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013013 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013014
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013015 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13016 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13017 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13018 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013019
Kailang Yanga361d842007-06-05 12:30:55 +020013020 { }
13021};
13022
Takashi Iwai1f0f4b82011-06-27 10:52:59 +020013023/* only for model=test */
13024#ifdef CONFIG_SND_DEBUG
Kailang Yanga361d842007-06-05 12:30:55 +020013025/*
13026 * generic initialization of ADC, input mixers and output mixers
13027 */
Takashi Iwaia9111322011-05-02 11:30:18 +020013028static const struct hda_verb alc268_volume_init_verbs[] = {
Kailang Yanga361d842007-06-05 12:30:55 +020013029 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013030 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13031 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013032
13033 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13034 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13035 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13036 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13037 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13038
Kailang Yanga361d842007-06-05 12:30:55 +020013039 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013040 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13041 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13042
13043 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013044 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai1f0f4b82011-06-27 10:52:59 +020013045 { }
13046};
13047#endif /* CONFIG_SND_DEBUG */
Kailang Yanga361d842007-06-05 12:30:55 +020013048
Takashi Iwai1f0f4b82011-06-27 10:52:59 +020013049/* set PCBEEP vol = 0, mute connections */
13050static const struct hda_verb alc268_beep_init_verbs[] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013051 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13052 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13053 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013054 { }
13055};
13056
Takashi Iwaia9111322011-05-02 11:30:18 +020013057static const struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013058 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13059 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13060 { } /* end */
13061};
13062
Takashi Iwaia9111322011-05-02 11:30:18 +020013063static const struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
Kailang Yanga361d842007-06-05 12:30:55 +020013064 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13065 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013066 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013067 { } /* end */
13068};
13069
Takashi Iwaia9111322011-05-02 11:30:18 +020013070static const struct snd_kcontrol_new alc268_capture_mixer[] = {
Kailang Yanga361d842007-06-05 12:30:55 +020013071 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13072 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13073 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13074 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013075 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013076 { } /* end */
13077};
13078
Takashi Iwaia9111322011-05-02 11:30:18 +020013079static const struct hda_input_mux alc268_capture_source = {
Kailang Yanga361d842007-06-05 12:30:55 +020013080 .num_items = 4,
13081 .items = {
13082 { "Mic", 0x0 },
13083 { "Front Mic", 0x1 },
13084 { "Line", 0x2 },
13085 { "CD", 0x3 },
13086 },
13087};
13088
Takashi Iwaia9111322011-05-02 11:30:18 +020013089static const struct hda_input_mux alc268_acer_capture_source = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013090 .num_items = 3,
13091 .items = {
13092 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013093 { "Internal Mic", 0x1 },
13094 { "Line", 0x2 },
13095 },
13096};
13097
Takashi Iwaia9111322011-05-02 11:30:18 +020013098static const struct hda_input_mux alc268_acer_dmic_capture_source = {
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013099 .num_items = 3,
13100 .items = {
13101 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013102 { "Internal Mic", 0x6 },
13103 { "Line", 0x2 },
13104 },
13105};
13106
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013107#ifdef CONFIG_SND_DEBUG
Takashi Iwaia9111322011-05-02 11:30:18 +020013108static const struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013109 /* Volume widgets */
13110 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13111 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13112 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13113 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13114 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13115 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13116 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13117 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13118 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13119 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13120 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13121 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13122 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013123 /* The below appears problematic on some hardwares */
13124 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013125 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13126 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13127 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13128 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13129
13130 /* Modes for retasking pin widgets */
13131 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13132 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13133 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13134 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13135
13136 /* Controls for GPIO pins, assuming they are configured as outputs */
13137 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13138 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13139 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13140 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13141
13142 /* Switches to allow the digital SPDIF output pin to be enabled.
13143 * The ALC268 does not have an SPDIF input.
13144 */
13145 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13146
13147 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13148 * this output to turn on an external amplifier.
13149 */
13150 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13151 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13152
13153 { } /* end */
13154};
13155#endif
13156
Kailang Yanga361d842007-06-05 12:30:55 +020013157/* create input playback/capture controls for the given pin */
13158static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13159 const char *ctlname, int idx)
13160{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013161 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013162 int err;
13163
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013164 switch (nid) {
13165 case 0x14:
13166 case 0x16:
13167 dac = 0x02;
13168 break;
13169 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013170 case 0x1a: /* ALC259/269 only */
13171 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013172 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013173 dac = 0x03;
13174 break;
13175 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013176 snd_printd(KERN_WARNING "hda_codec: "
13177 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013178 return 0;
13179 }
13180 if (spec->multiout.dac_nids[0] != dac &&
13181 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013182 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013183 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013184 HDA_OUTPUT));
13185 if (err < 0)
13186 return err;
Takashi Iwaidda14412011-05-02 11:29:30 +020013187 spec->private_dac_nids[spec->multiout.num_dacs++] = dac;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013188 }
13189
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013190 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013191 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013192 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013193 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013194 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013195 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013196 if (err < 0)
13197 return err;
13198 return 0;
13199}
13200
13201/* add playback controls from the parsed DAC table */
13202static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13203 const struct auto_pin_cfg *cfg)
13204{
13205 hda_nid_t nid;
13206 int err;
13207
Kailang Yanga361d842007-06-05 12:30:55 +020013208 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013209
13210 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013211 if (nid) {
13212 const char *name;
Takashi Iwai2e925dd2011-06-24 11:27:22 +020013213 int index;
13214 name = alc_get_line_out_pfx(spec, 0, true, &index);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013215 err = alc268_new_analog_output(spec, nid, name, 0);
13216 if (err < 0)
13217 return err;
13218 }
Kailang Yanga361d842007-06-05 12:30:55 +020013219
13220 nid = cfg->speaker_pins[0];
13221 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013222 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013223 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13224 if (err < 0)
13225 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013226 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013227 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13228 if (err < 0)
13229 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013230 }
13231 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013232 if (nid) {
13233 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13234 if (err < 0)
13235 return err;
13236 }
Kailang Yanga361d842007-06-05 12:30:55 +020013237
13238 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13239 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013240 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013241 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013242 if (err < 0)
13243 return err;
13244 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013245 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013246}
13247
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013248static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13249 hda_nid_t nid, int pin_type)
13250{
13251 int idx;
13252
13253 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai4f574b72011-06-27 16:17:07 +020013254 if (snd_hda_get_conn_list(codec, nid, NULL) <= 1)
13255 return;
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013256 if (nid == 0x14 || nid == 0x16)
13257 idx = 0;
13258 else
13259 idx = 1;
13260 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13261}
13262
Takashi Iwai1f0f4b82011-06-27 10:52:59 +020013263static void alc268_auto_init_dac(struct hda_codec *codec, hda_nid_t nid)
13264{
13265 if (!nid)
13266 return;
13267 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai7ec9c6c2011-06-27 15:53:38 +020013268 AMP_OUT_ZERO);
Takashi Iwai1f0f4b82011-06-27 10:52:59 +020013269}
13270
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013271static void alc268_auto_init_multi_out(struct hda_codec *codec)
13272{
13273 struct alc_spec *spec = codec->spec;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013274 int i;
13275
13276 for (i = 0; i < spec->autocfg.line_outs; i++) {
13277 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013278 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13279 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13280 }
Takashi Iwai1f0f4b82011-06-27 10:52:59 +020013281 /* mute DACs */
13282 for (i = 0; i < spec->multiout.num_dacs; i++)
13283 alc268_auto_init_dac(codec, spec->multiout.dac_nids[i]);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013284}
13285
13286static void alc268_auto_init_hp_out(struct hda_codec *codec)
13287{
13288 struct alc_spec *spec = codec->spec;
13289 hda_nid_t pin;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013290 int i;
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013291
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013292 for (i = 0; i < spec->autocfg.hp_outs; i++) {
13293 pin = spec->autocfg.hp_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013294 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013295 }
13296 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
13297 pin = spec->autocfg.speaker_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013298 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013299 }
13300 if (spec->autocfg.mono_out_pin)
13301 snd_hda_codec_write(codec, spec->autocfg.mono_out_pin, 0,
13302 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwai1f0f4b82011-06-27 10:52:59 +020013303 /* mute DACs */
13304 alc268_auto_init_dac(codec, spec->multiout.hp_nid);
13305 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++)
13306 alc268_auto_init_dac(codec, spec->multiout.extra_out_nid[i]);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013307}
13308
Kailang Yanga361d842007-06-05 12:30:55 +020013309static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13310{
13311 struct alc_spec *spec = codec->spec;
13312 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13313 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13314 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13315 unsigned int dac_vol1, dac_vol2;
13316
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013317 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013318 snd_hda_codec_write(codec, speaker_nid, 0,
13319 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013320 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013321 snd_hda_codec_write(codec, 0x0f, 0,
13322 AC_VERB_SET_AMP_GAIN_MUTE,
13323 AMP_IN_UNMUTE(1));
13324 snd_hda_codec_write(codec, 0x10, 0,
13325 AC_VERB_SET_AMP_GAIN_MUTE,
13326 AMP_IN_UNMUTE(1));
13327 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013328 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013329 snd_hda_codec_write(codec, 0x0f, 0,
13330 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13331 snd_hda_codec_write(codec, 0x10, 0,
13332 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13333 }
13334
13335 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013336 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013337 dac_vol2 = AMP_OUT_ZERO;
13338 else if (line_nid == 0x15)
13339 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013340 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013341 dac_vol2 = AMP_OUT_ZERO;
13342 else if (hp_nid == 0x15)
13343 dac_vol1 = AMP_OUT_ZERO;
13344 if (line_nid != 0x16 || hp_nid != 0x16 ||
13345 spec->autocfg.line_out_pins[1] != 0x16 ||
13346 spec->autocfg.line_out_pins[2] != 0x16)
13347 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13348
13349 snd_hda_codec_write(codec, 0x02, 0,
13350 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13351 snd_hda_codec_write(codec, 0x03, 0,
13352 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13353}
13354
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013355/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013356#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13357#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013358#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013359#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13360
13361/*
13362 * BIOS auto configuration
13363 */
13364static int alc268_parse_auto_config(struct hda_codec *codec)
13365{
13366 struct alc_spec *spec = codec->spec;
13367 int err;
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020013368 static const hda_nid_t alc268_ignore[] = { 0 };
Kailang Yanga361d842007-06-05 12:30:55 +020013369
13370 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13371 alc268_ignore);
13372 if (err < 0)
13373 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013374 if (!spec->autocfg.line_outs) {
13375 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13376 spec->multiout.max_channels = 2;
13377 spec->no_analog = 1;
13378 goto dig_only;
13379 }
Kailang Yanga361d842007-06-05 12:30:55 +020013380 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013381 }
Kailang Yanga361d842007-06-05 12:30:55 +020013382 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13383 if (err < 0)
13384 return err;
Takashi Iwaib7821702011-07-06 15:12:46 +020013385 err = alc_auto_create_input_ctls(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013386 if (err < 0)
13387 return err;
13388
13389 spec->multiout.max_channels = 2;
13390
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013391 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013392 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013393 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013394 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013395 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013396
Takashi Iwai4f574b72011-06-27 16:17:07 +020013397 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d) {
Takashi Iwaid88897e2008-10-31 15:01:37 +010013398 add_mixer(spec, alc268_beep_mixer);
Takashi Iwai4f574b72011-06-27 16:17:07 +020013399 add_verb(spec, alc268_beep_init_verbs);
13400 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013401
Takashi Iwaif970de22011-07-06 17:39:59 +020013402 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013403 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013404
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +020013405 if (!spec->dual_adc_switch)
13406 alc_remove_invalid_adc_nids(codec);
13407
Takashi Iwai776e1842007-08-29 15:07:11 +020013408 err = alc_auto_add_mic_boost(codec);
13409 if (err < 0)
13410 return err;
13411
Kailang Yang6227cdc2010-02-25 08:36:52 +010013412 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013413
Kailang Yanga361d842007-06-05 12:30:55 +020013414 return 1;
13415}
13416
Kailang Yanga361d842007-06-05 12:30:55 +020013417/* init callback for auto-configuration model -- overriding the default init */
13418static void alc268_auto_init(struct hda_codec *codec)
13419{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013420 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013421 alc268_auto_init_multi_out(codec);
13422 alc268_auto_init_hp_out(codec);
13423 alc268_auto_init_mono_speaker_out(codec);
Takashi Iwai0a7f5322011-07-06 15:15:12 +020013424 alc_auto_init_analog_input(codec);
Takashi Iwaif970de22011-07-06 17:39:59 +020013425 alc_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013426 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013427 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013428 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013429}
13430
13431/*
13432 * configuration and preset
13433 */
Takashi Iwaiea734962011-01-17 11:29:34 +010013434static const char * const alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013435 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013436 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013437 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013438 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013439 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013440 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013441 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013442 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013443#ifdef CONFIG_SND_DEBUG
13444 [ALC268_TEST] = "test",
13445#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013446 [ALC268_AUTO] = "auto",
13447};
13448
Takashi Iwaia9111322011-05-02 11:30:18 +020013449static const struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013450 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013451 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013452 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013453 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013454 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013455 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13456 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013457 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chen0a1896b2011-06-06 18:55:34 -040013458 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron 910", ALC268_AUTO),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013459 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13460 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013461 /* almost compatible with toshiba but with optional digital outs;
13462 * auto-probing seems working fine
13463 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013464 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013465 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013466 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013467 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013468 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013469 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013470 {}
13471};
13472
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013473/* Toshiba laptops have no unique PCI SSID but only codec SSID */
Takashi Iwaia9111322011-05-02 11:30:18 +020013474static const struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013475 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13476 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13477 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13478 ALC268_TOSHIBA),
13479 {}
13480};
13481
Takashi Iwaia9111322011-05-02 11:30:18 +020013482static const struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013483 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013484 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13485 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013486 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13487 alc267_quanta_il1_verbs },
13488 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13489 .dac_nids = alc268_dac_nids,
13490 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13491 .adc_nids = alc268_adc_nids_alt,
13492 .hp_nid = 0x03,
13493 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13494 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013495 .unsol_event = alc_sku_unsol_event,
13496 .setup = alc267_quanta_il1_setup,
13497 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013498 },
Kailang Yanga361d842007-06-05 12:30:55 +020013499 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013500 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13501 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013502 .init_verbs = { alc268_base_init_verbs },
13503 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13504 .dac_nids = alc268_dac_nids,
13505 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13506 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013507 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013508 .hp_nid = 0x03,
13509 .dig_out_nid = ALC268_DIGOUT_NID,
13510 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13511 .channel_mode = alc268_modes,
13512 .input_mux = &alc268_capture_source,
13513 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013514 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013515 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013516 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013517 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13518 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013519 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13520 .dac_nids = alc268_dac_nids,
13521 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13522 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013523 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013524 .hp_nid = 0x03,
13525 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13526 .channel_mode = alc268_modes,
13527 .input_mux = &alc268_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020013528 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013529 .setup = alc268_toshiba_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020013530 .init_hook = alc_inithook,
Takashi Iwaid2738092007-08-16 14:59:45 +020013531 },
13532 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013533 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013534 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013535 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13536 alc268_acer_verbs },
13537 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13538 .dac_nids = alc268_dac_nids,
13539 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13540 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013541 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013542 .hp_nid = 0x02,
13543 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13544 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013545 .input_mux = &alc268_acer_capture_source,
Takashi Iwai0f0f3912011-04-28 16:26:24 +020013546 .unsol_event = alc_sku_unsol_event,
13547 .setup = alc268_acer_setup,
13548 .init_hook = alc_inithook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013549 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013550 [ALC268_ACER_DMIC] = {
13551 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13552 alc268_beep_mixer },
13553 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13554 alc268_acer_verbs },
13555 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13556 .dac_nids = alc268_dac_nids,
13557 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13558 .adc_nids = alc268_adc_nids_alt,
13559 .capsrc_nids = alc268_capsrc_nids,
13560 .hp_nid = 0x02,
13561 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13562 .channel_mode = alc268_modes,
13563 .input_mux = &alc268_acer_dmic_capture_source,
Takashi Iwai0f0f3912011-04-28 16:26:24 +020013564 .unsol_event = alc_sku_unsol_event,
13565 .setup = alc268_acer_setup,
13566 .init_hook = alc_inithook,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013567 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013568 [ALC268_ACER_ASPIRE_ONE] = {
13569 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013570 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013571 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013572 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13573 alc268_acer_aspire_one_verbs },
13574 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13575 .dac_nids = alc268_dac_nids,
13576 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13577 .adc_nids = alc268_adc_nids_alt,
13578 .capsrc_nids = alc268_capsrc_nids,
13579 .hp_nid = 0x03,
13580 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13581 .channel_mode = alc268_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020013582 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013583 .setup = alc268_acer_lc_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020013584 .init_hook = alc_inithook,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013585 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013586 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013587 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13588 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013589 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13590 alc268_dell_verbs },
13591 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13592 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013593 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13594 .adc_nids = alc268_adc_nids_alt,
13595 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013596 .hp_nid = 0x02,
13597 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13598 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013599 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013600 .setup = alc268_dell_setup,
13601 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013602 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013603 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013604 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13605 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013606 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13607 alc268_toshiba_verbs },
13608 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13609 .dac_nids = alc268_dac_nids,
13610 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13611 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013612 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013613 .hp_nid = 0x03,
13614 .dig_out_nid = ALC268_DIGOUT_NID,
13615 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13616 .channel_mode = alc268_modes,
13617 .input_mux = &alc268_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020013618 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013619 .setup = alc268_toshiba_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020013620 .init_hook = alc_inithook,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013621 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013622#ifdef CONFIG_SND_DEBUG
13623 [ALC268_TEST] = {
13624 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13625 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
Takashi Iwai1f0f4b82011-06-27 10:52:59 +020013626 alc268_volume_init_verbs,
13627 alc268_beep_init_verbs },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013628 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13629 .dac_nids = alc268_dac_nids,
13630 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13631 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013632 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013633 .hp_nid = 0x03,
13634 .dig_out_nid = ALC268_DIGOUT_NID,
13635 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13636 .channel_mode = alc268_modes,
13637 .input_mux = &alc268_capture_source,
13638 },
13639#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013640};
13641
13642static int patch_alc268(struct hda_codec *codec)
13643{
13644 struct alc_spec *spec;
13645 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013646 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013647
Julia Lawallef86f582009-12-19 08:18:03 +010013648 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013649 if (spec == NULL)
13650 return -ENOMEM;
13651
13652 codec->spec = spec;
13653
Takashi Iwai1f0f4b82011-06-27 10:52:59 +020013654 /* ALC268 has no aa-loopback mixer */
13655
Kailang Yanga361d842007-06-05 12:30:55 +020013656 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13657 alc268_models,
13658 alc268_cfg_tbl);
13659
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013660 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13661 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013662 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013663
Kailang Yanga361d842007-06-05 12:30:55 +020013664 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013665 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13666 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013667 board_config = ALC268_AUTO;
13668 }
13669
13670 if (board_config == ALC268_AUTO) {
13671 /* automatic parse from the BIOS config */
13672 err = alc268_parse_auto_config(codec);
13673 if (err < 0) {
13674 alc_free(codec);
13675 return err;
13676 } else if (!err) {
13677 printk(KERN_INFO
13678 "hda_codec: Cannot set up configuration "
13679 "from BIOS. Using base mode...\n");
13680 board_config = ALC268_3ST;
13681 }
13682 }
13683
13684 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013685 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013686
Kailang Yanga361d842007-06-05 12:30:55 +020013687 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13688 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013689 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013690
Kailang Yanga361d842007-06-05 12:30:55 +020013691 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13692
Takashi Iwai22971e32009-02-10 11:56:44 +010013693 has_beep = 0;
13694 for (i = 0; i < spec->num_mixers; i++) {
13695 if (spec->mixers[i] == alc268_beep_mixer) {
13696 has_beep = 1;
13697 break;
13698 }
13699 }
13700
13701 if (has_beep) {
13702 err = snd_hda_attach_beep_device(codec, 0x1);
13703 if (err < 0) {
13704 alc_free(codec);
13705 return err;
13706 }
13707 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13708 /* override the amp caps for beep generator */
13709 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013710 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13711 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13712 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13713 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013714 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013715
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013716 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +020013717 alc_auto_fill_adc_caps(codec);
13718 alc_remove_invalid_adc_nids(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013719 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013720
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +020013721 if (!spec->cap_mixer && !spec->no_analog)
13722 set_capture_mixer(codec);
13723
Takashi Iwai2134ea42008-01-10 16:53:55 +010013724 spec->vmaster_nid = 0x02;
13725
Kailang Yanga361d842007-06-05 12:30:55 +020013726 codec->patch_ops = alc_patch_ops;
13727 if (board_config == ALC268_AUTO)
13728 spec->init_hook = alc268_auto_init;
Takashi Iwai1c7161532011-04-07 10:37:16 +020013729 spec->shutup = alc_eapd_shutup;
Kailang Yangea1fb292008-08-26 12:58:38 +020013730
Kailang Yangbf1b0222010-10-21 08:49:56 +020013731 alc_init_jacks(codec);
13732
Kailang Yanga361d842007-06-05 12:30:55 +020013733 return 0;
13734}
13735
13736/*
Kailang Yangf6a92242007-12-13 16:52:54 +010013737 * ALC269 channel source setting (2 channel)
13738 */
13739#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
13740
13741#define alc269_dac_nids alc260_dac_nids
13742
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020013743static const hda_nid_t alc269_adc_nids[1] = {
Kailang Yangf6a92242007-12-13 16:52:54 +010013744 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020013745 0x08,
13746};
13747
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020013748static const hda_nid_t alc269_capsrc_nids[1] = {
Takashi Iwaie01bf502008-08-21 16:25:07 +020013749 0x23,
13750};
13751
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020013752static const hda_nid_t alc269vb_adc_nids[1] = {
Kailang Yang84898e82010-02-04 14:16:14 +010013753 /* ADC1 */
13754 0x09,
13755};
13756
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020013757static const hda_nid_t alc269vb_capsrc_nids[1] = {
Kailang Yang84898e82010-02-04 14:16:14 +010013758 0x22,
13759};
13760
Kailang Yangf6a92242007-12-13 16:52:54 +010013761#define alc269_modes alc260_modes
13762#define alc269_capture_source alc880_lg_lw_capture_source
13763
Takashi Iwaia9111322011-05-02 11:30:18 +020013764static const struct snd_kcontrol_new alc269_base_mixer[] = {
Kailang Yangf6a92242007-12-13 16:52:54 +010013765 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13766 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13767 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13768 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13769 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13770 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013771 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010013772 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13773 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013774 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010013775 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13776 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13777 { } /* end */
13778};
13779
Takashi Iwaia9111322011-05-02 11:30:18 +020013780static const struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013781 /* output mixer control */
13782 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13783 {
13784 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13785 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013786 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020013787 .info = snd_hda_mixer_amp_switch_info,
13788 .get = snd_hda_mixer_amp_switch_get,
13789 .put = alc268_acer_master_sw_put,
13790 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13791 },
13792 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13793 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013794 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013795 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13796 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013797 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013798 { }
13799};
13800
Takashi Iwaia9111322011-05-02 11:30:18 +020013801static const struct snd_kcontrol_new alc269_lifebook_mixer[] = {
Tony Vroon64154832008-11-06 15:08:49 +000013802 /* output mixer control */
13803 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13804 {
13805 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13806 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013807 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000013808 .info = snd_hda_mixer_amp_switch_info,
13809 .get = snd_hda_mixer_amp_switch_get,
13810 .put = alc268_acer_master_sw_put,
13811 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13812 },
13813 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13814 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013815 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000013816 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13817 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013818 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000013819 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
13820 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013821 HDA_CODEC_VOLUME("Dock Mic Boost Volume", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000013822 { }
13823};
13824
Takashi Iwaia9111322011-05-02 11:30:18 +020013825static const struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020013826 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013827 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020013828 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013829 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020013830 { } /* end */
13831};
13832
Takashi Iwaia9111322011-05-02 11:30:18 +020013833static const struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
Kailang Yang84898e82010-02-04 14:16:14 +010013834 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13835 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13836 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13837 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13838 { } /* end */
13839};
13840
Takashi Iwaia9111322011-05-02 11:30:18 +020013841static const struct snd_kcontrol_new alc269_asus_mixer[] = {
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020013842 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13843 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
13844 { } /* end */
13845};
13846
Kailang Yangf6a92242007-12-13 16:52:54 +010013847/* capture mixer elements */
Takashi Iwaia9111322011-05-02 11:30:18 +020013848static const struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
Kailang Yang84898e82010-02-04 14:16:14 +010013849 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13850 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013851 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13852 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010013853 { } /* end */
13854};
13855
Takashi Iwaia9111322011-05-02 11:30:18 +020013856static const struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020013857 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13858 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013859 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013860 { } /* end */
13861};
13862
Takashi Iwaia9111322011-05-02 11:30:18 +020013863static const struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
Kailang Yang84898e82010-02-04 14:16:14 +010013864 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13865 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013866 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13867 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010013868 { } /* end */
13869};
13870
Takashi Iwaia9111322011-05-02 11:30:18 +020013871static const struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
Kailang Yang84898e82010-02-04 14:16:14 +010013872 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13873 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013874 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010013875 { } /* end */
13876};
13877
Takashi Iwai26f5df22008-11-03 17:39:46 +010013878/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010013879#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020013880
Takashi Iwaia9111322011-05-02 11:30:18 +020013881static const struct hda_verb alc269_quanta_fl1_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013882 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13883 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13884 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13885 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13886 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13887 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13888 { }
13889};
13890
Takashi Iwaia9111322011-05-02 11:30:18 +020013891static const struct hda_verb alc269_lifebook_verbs[] = {
Tony Vroon64154832008-11-06 15:08:49 +000013892 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13893 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13894 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13895 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13896 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13897 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13898 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13899 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13900 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13901 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13902 { }
13903};
13904
Kailang Yang60db6b52008-08-26 13:13:00 +020013905/* toggle speaker-output according to the hp-jack state */
13906static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13907{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020013908 alc_hp_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013909
13910 snd_hda_codec_write(codec, 0x20, 0,
13911 AC_VERB_SET_COEF_INDEX, 0x0c);
13912 snd_hda_codec_write(codec, 0x20, 0,
13913 AC_VERB_SET_PROC_COEF, 0x680);
13914
13915 snd_hda_codec_write(codec, 0x20, 0,
13916 AC_VERB_SET_COEF_INDEX, 0x0c);
13917 snd_hda_codec_write(codec, 0x20, 0,
13918 AC_VERB_SET_PROC_COEF, 0x480);
13919}
13920
Takashi Iwai3b8510c2011-04-28 14:03:24 +020013921#define alc269_lifebook_speaker_automute \
13922 alc269_quanta_fl1_speaker_automute
Tony Vroon64154832008-11-06 15:08:49 +000013923
Tony Vroon64154832008-11-06 15:08:49 +000013924static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13925{
13926 unsigned int present_laptop;
13927 unsigned int present_dock;
13928
Wu Fengguang864f92b2009-11-18 12:38:02 +080013929 present_laptop = snd_hda_jack_detect(codec, 0x18);
13930 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000013931
13932 /* Laptop mic port overrides dock mic port, design decision */
13933 if (present_dock)
13934 snd_hda_codec_write(codec, 0x23, 0,
13935 AC_VERB_SET_CONNECT_SEL, 0x3);
13936 if (present_laptop)
13937 snd_hda_codec_write(codec, 0x23, 0,
13938 AC_VERB_SET_CONNECT_SEL, 0x0);
13939 if (!present_dock && !present_laptop)
13940 snd_hda_codec_write(codec, 0x23, 0,
13941 AC_VERB_SET_CONNECT_SEL, 0x1);
13942}
13943
Kailang Yang60db6b52008-08-26 13:13:00 +020013944static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13945 unsigned int res)
13946{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013947 switch (res >> 26) {
13948 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013949 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013950 break;
13951 case ALC880_MIC_EVENT:
13952 alc_mic_automute(codec);
13953 break;
13954 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013955}
13956
Tony Vroon64154832008-11-06 15:08:49 +000013957static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13958 unsigned int res)
13959{
13960 if ((res >> 26) == ALC880_HP_EVENT)
13961 alc269_lifebook_speaker_automute(codec);
13962 if ((res >> 26) == ALC880_MIC_EVENT)
13963 alc269_lifebook_mic_autoswitch(codec);
13964}
13965
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013966static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13967{
13968 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013969 spec->autocfg.hp_pins[0] = 0x15;
13970 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020013971 spec->automute_mixer_nid[0] = 0x0c;
13972 spec->automute = 1;
13973 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013974 spec->ext_mic.pin = 0x18;
13975 spec->ext_mic.mux_idx = 0;
13976 spec->int_mic.pin = 0x19;
13977 spec->int_mic.mux_idx = 1;
13978 spec->auto_mic = 1;
13979}
13980
Kailang Yang60db6b52008-08-26 13:13:00 +020013981static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13982{
13983 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013984 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013985}
13986
Takashi Iwai3b8510c2011-04-28 14:03:24 +020013987static void alc269_lifebook_setup(struct hda_codec *codec)
13988{
13989 struct alc_spec *spec = codec->spec;
13990 spec->autocfg.hp_pins[0] = 0x15;
13991 spec->autocfg.hp_pins[1] = 0x1a;
13992 spec->autocfg.speaker_pins[0] = 0x14;
13993 spec->automute_mixer_nid[0] = 0x0c;
13994 spec->automute = 1;
13995 spec->automute_mode = ALC_AUTOMUTE_MIXER;
13996}
13997
Tony Vroon64154832008-11-06 15:08:49 +000013998static void alc269_lifebook_init_hook(struct hda_codec *codec)
13999{
14000 alc269_lifebook_speaker_automute(codec);
14001 alc269_lifebook_mic_autoswitch(codec);
14002}
14003
Takashi Iwaia9111322011-05-02 11:30:18 +020014004static const struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014005 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14006 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14007 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14008 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14009 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14010 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14011 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14012 {}
14013};
14014
Takashi Iwaia9111322011-05-02 11:30:18 +020014015static const struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014016 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14017 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14018 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14019 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
14020 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14021 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14022 {}
14023};
14024
Takashi Iwaia9111322011-05-02 11:30:18 +020014025static const struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
Kailang Yang84898e82010-02-04 14:16:14 +010014026 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14027 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14028 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14029 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14030 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14031 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14032 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14033 {}
14034};
14035
Takashi Iwaia9111322011-05-02 11:30:18 +020014036static const struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
Kailang Yang84898e82010-02-04 14:16:14 +010014037 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14038 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14039 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14040 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14041 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14042 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14043 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14044 {}
14045};
14046
Takashi Iwaia9111322011-05-02 11:30:18 +020014047static const struct hda_verb alc271_acer_dmic_verbs[] = {
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014048 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14049 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14050 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14051 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14052 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14053 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14054 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14055 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14056 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14057 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14058 { }
14059};
14060
Kailang Yang226b1ec2010-04-09 11:01:20 +020014061static void alc269_laptop_amic_setup(struct hda_codec *codec)
14062{
14063 struct alc_spec *spec = codec->spec;
14064 spec->autocfg.hp_pins[0] = 0x15;
14065 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014066 spec->automute_mixer_nid[0] = 0x0c;
14067 spec->automute = 1;
14068 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014069 spec->ext_mic.pin = 0x18;
14070 spec->ext_mic.mux_idx = 0;
14071 spec->int_mic.pin = 0x19;
14072 spec->int_mic.mux_idx = 1;
14073 spec->auto_mic = 1;
14074}
14075
Kailang Yang84898e82010-02-04 14:16:14 +010014076static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014077{
14078 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014079 spec->autocfg.hp_pins[0] = 0x15;
14080 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014081 spec->automute_mixer_nid[0] = 0x0c;
14082 spec->automute = 1;
14083 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014084 spec->ext_mic.pin = 0x18;
14085 spec->ext_mic.mux_idx = 0;
14086 spec->int_mic.pin = 0x12;
14087 spec->int_mic.mux_idx = 5;
14088 spec->auto_mic = 1;
14089}
14090
Kailang Yang226b1ec2010-04-09 11:01:20 +020014091static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014092{
14093 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014094 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014095 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014096 spec->automute_mixer_nid[0] = 0x0c;
14097 spec->automute = 1;
14098 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014099 spec->ext_mic.pin = 0x18;
14100 spec->ext_mic.mux_idx = 0;
14101 spec->int_mic.pin = 0x19;
14102 spec->int_mic.mux_idx = 1;
14103 spec->auto_mic = 1;
14104}
14105
Kailang Yang226b1ec2010-04-09 11:01:20 +020014106static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14107{
14108 struct alc_spec *spec = codec->spec;
14109 spec->autocfg.hp_pins[0] = 0x21;
14110 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014111 spec->automute_mixer_nid[0] = 0x0c;
14112 spec->automute = 1;
14113 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014114 spec->ext_mic.pin = 0x18;
14115 spec->ext_mic.mux_idx = 0;
14116 spec->int_mic.pin = 0x12;
14117 spec->int_mic.mux_idx = 6;
14118 spec->auto_mic = 1;
14119}
14120
Kailang Yangf6a92242007-12-13 16:52:54 +010014121/*
14122 * generic initialization of ADC, input mixers and output mixers
14123 */
Takashi Iwaia9111322011-05-02 11:30:18 +020014124static const struct hda_verb alc269_init_verbs[] = {
Kailang Yangf6a92242007-12-13 16:52:54 +010014125 /*
14126 * Unmute ADC0 and set the default input to mic-in
14127 */
Kailang Yang84898e82010-02-04 14:16:14 +010014128 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014129
14130 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014131 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014132 */
14133 /* set vol=0 to output mixers */
14134 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14135 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14136
14137 /* set up input amps for analog loopback */
14138 /* Amp Indices: DAC = 0, mixer = 1 */
14139 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14140 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14141 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14142 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14143 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14144 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14145
14146 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14147 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14148 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14149 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14150 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14151 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14152 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14153
14154 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14155 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014156
Kailang Yang84898e82010-02-04 14:16:14 +010014157 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014158 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14159 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014160 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014161
14162 /* set EAPD */
14163 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014164 { }
14165};
14166
Takashi Iwaia9111322011-05-02 11:30:18 +020014167static const struct hda_verb alc269vb_init_verbs[] = {
Kailang Yang84898e82010-02-04 14:16:14 +010014168 /*
14169 * Unmute ADC0 and set the default input to mic-in
14170 */
14171 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14172
14173 /*
14174 * Set up output mixers (0x02 - 0x03)
14175 */
14176 /* set vol=0 to output mixers */
14177 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14178 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14179
14180 /* set up input amps for analog loopback */
14181 /* Amp Indices: DAC = 0, mixer = 1 */
14182 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14183 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14184 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14185 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14186 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14187 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14188
14189 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14190 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14191 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14192 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14193 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14194 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14195 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14196
14197 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14198 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14199
14200 /* FIXME: use Mux-type input source selection */
14201 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14202 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14203 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14204
14205 /* set EAPD */
14206 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014207 { }
14208};
14209
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014210#define alc269_auto_create_multi_out_ctls \
14211 alc268_auto_create_multi_out_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014212
14213#ifdef CONFIG_SND_HDA_POWER_SAVE
14214#define alc269_loopbacks alc880_loopbacks
14215#endif
14216
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014217/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014218#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14219#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14220#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14221#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14222
Takashi Iwaia9111322011-05-02 11:30:18 +020014223static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
Takashi Iwaif03d3112009-03-05 14:18:16 +010014224 .substreams = 1,
14225 .channels_min = 2,
14226 .channels_max = 8,
14227 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14228 /* NID is set in alc_build_pcms */
14229 .ops = {
14230 .open = alc880_playback_pcm_open,
14231 .prepare = alc880_playback_pcm_prepare,
14232 .cleanup = alc880_playback_pcm_cleanup
14233 },
14234};
14235
Takashi Iwaia9111322011-05-02 11:30:18 +020014236static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
Takashi Iwaif03d3112009-03-05 14:18:16 +010014237 .substreams = 1,
14238 .channels_min = 2,
14239 .channels_max = 2,
14240 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14241 /* NID is set in alc_build_pcms */
14242};
14243
Takashi Iwaiad358792010-03-30 18:00:59 +020014244#ifdef CONFIG_SND_HDA_POWER_SAVE
14245static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14246{
14247 switch (codec->subsystem_id) {
14248 case 0x103c1586:
14249 return 1;
14250 }
14251 return 0;
14252}
14253
14254static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14255{
14256 /* update mute-LED according to the speaker mute state */
14257 if (nid == 0x01 || nid == 0x14) {
14258 int pinval;
14259 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14260 HDA_AMP_MUTE)
14261 pinval = 0x24;
14262 else
14263 pinval = 0x20;
14264 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a542010-03-30 18:03:44 +020014265 snd_hda_codec_update_cache(codec, 0x19, 0,
14266 AC_VERB_SET_PIN_WIDGET_CONTROL,
14267 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014268 }
14269 return alc_check_power_status(codec, nid);
14270}
14271#endif /* CONFIG_SND_HDA_POWER_SAVE */
14272
Takashi Iwai840b64c2010-07-13 22:49:01 +020014273static int alc275_setup_dual_adc(struct hda_codec *codec)
14274{
14275 struct alc_spec *spec = codec->spec;
14276
14277 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14278 return 0;
14279 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14280 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14281 if (spec->ext_mic.pin <= 0x12) {
14282 spec->private_adc_nids[0] = 0x08;
14283 spec->private_adc_nids[1] = 0x11;
14284 spec->private_capsrc_nids[0] = 0x23;
14285 spec->private_capsrc_nids[1] = 0x22;
14286 } else {
14287 spec->private_adc_nids[0] = 0x11;
14288 spec->private_adc_nids[1] = 0x08;
14289 spec->private_capsrc_nids[0] = 0x22;
14290 spec->private_capsrc_nids[1] = 0x23;
14291 }
14292 spec->adc_nids = spec->private_adc_nids;
14293 spec->capsrc_nids = spec->private_capsrc_nids;
14294 spec->num_adc_nids = 2;
14295 spec->dual_adc_switch = 1;
14296 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14297 spec->adc_nids[0], spec->adc_nids[1]);
14298 return 1;
14299 }
14300 return 0;
14301}
14302
Takashi Iwaid433a672010-09-20 15:11:54 +020014303/* different alc269-variants */
14304enum {
Kailang Yangb6878572011-07-06 09:51:29 +020014305 ALC269_TYPE_ALC269VA,
Kailang Yang48c88e82010-11-23 08:56:16 +010014306 ALC269_TYPE_ALC269VB,
Kailang Yangb6878572011-07-06 09:51:29 +020014307 ALC269_TYPE_ALC269VC,
Takashi Iwaid433a672010-09-20 15:11:54 +020014308};
14309
Kailang Yangf6a92242007-12-13 16:52:54 +010014310/*
14311 * BIOS auto configuration
14312 */
14313static int alc269_parse_auto_config(struct hda_codec *codec)
14314{
14315 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014316 int err;
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020014317 static const hda_nid_t alc269_ignore[] = { 0x1d, 0 };
Kailang Yangf6a92242007-12-13 16:52:54 +010014318
14319 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14320 alc269_ignore);
14321 if (err < 0)
14322 return err;
14323
14324 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14325 if (err < 0)
14326 return err;
Takashi Iwaib7821702011-07-06 15:12:46 +020014327 err = alc_auto_create_input_ctls(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014328 if (err < 0)
14329 return err;
14330
14331 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14332
Takashi Iwai757899a2010-07-30 10:48:14 +020014333 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014334
Takashi Iwai603c4012008-07-30 15:01:44 +020014335 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014336 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014337
Kailang Yangb6878572011-07-06 09:51:29 +020014338 if (spec->codec_variant != ALC269_TYPE_ALC269VA)
Kailang Yang6227cdc2010-02-25 08:36:52 +010014339 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Takashi Iwai1f0f4b82011-06-27 10:52:59 +020014340 else
Kailang Yang6227cdc2010-02-25 08:36:52 +010014341 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014342
Kailang Yangf6a92242007-12-13 16:52:54 +010014343 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014344 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014345
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +020014346 alc275_setup_dual_adc(codec);
14347 if (!spec->dual_adc_switch)
14348 alc_remove_invalid_adc_nids(codec);
Takashi Iwai66946352010-03-29 17:21:45 +020014349
Kailang Yangf6a92242007-12-13 16:52:54 +010014350 err = alc_auto_add_mic_boost(codec);
14351 if (err < 0)
14352 return err;
14353
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014354 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014355 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014356
Kailang Yangf6a92242007-12-13 16:52:54 +010014357 return 1;
14358}
14359
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014360#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14361#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014362
14363
14364/* init callback for auto-configuration model -- overriding the default init */
14365static void alc269_auto_init(struct hda_codec *codec)
14366{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014367 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014368 alc269_auto_init_multi_out(codec);
14369 alc269_auto_init_hp_out(codec);
Takashi Iwai0a7f5322011-07-06 15:15:12 +020014370 alc_auto_init_analog_input(codec);
Takashi Iwaif970de22011-07-06 17:39:59 +020014371 alc_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014372 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014373 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014374 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014375}
14376
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014377static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
14378{
14379 int val = alc_read_coef_idx(codec, 0x04);
14380 if (power_up)
14381 val |= 1 << 11;
14382 else
14383 val &= ~(1 << 11);
14384 alc_write_coef_idx(codec, 0x04, val);
14385}
14386
Takashi Iwai5402e4c2011-04-07 10:39:25 +020014387static void alc269_shutup(struct hda_codec *codec)
Kailang Yang977ddd62010-09-15 10:02:29 +020014388{
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014389 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017)
14390 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014391 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014392 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014393 msleep(150);
14394 }
Kailang Yang977ddd62010-09-15 10:02:29 +020014395}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014396
Takashi Iwai5402e4c2011-04-07 10:39:25 +020014397#ifdef SND_HDA_NEEDS_RESUME
Kailang Yang977ddd62010-09-15 10:02:29 +020014398static int alc269_resume(struct hda_codec *codec)
14399{
Kailang Yang977ddd62010-09-15 10:02:29 +020014400 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014401 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014402 msleep(150);
14403 }
14404
14405 codec->patch_ops.init(codec);
14406
14407 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014408 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014409 msleep(200);
14410 }
14411
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014412 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018)
14413 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014414
14415 snd_hda_codec_resume_amp(codec);
14416 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +020014417 hda_call_check_power_status(codec, 0x01);
Kailang Yang977ddd62010-09-15 10:02:29 +020014418 return 0;
14419}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014420#endif /* SND_HDA_NEEDS_RESUME */
Kailang Yang977ddd62010-09-15 10:02:29 +020014421
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014422static void alc269_fixup_hweq(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014423 const struct alc_fixup *fix, int action)
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014424{
14425 int coef;
14426
Takashi Iwai58701122011-01-13 15:41:45 +010014427 if (action != ALC_FIXUP_ACT_INIT)
Takashi Iwai9fb1ef22011-01-13 14:40:43 +010014428 return;
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014429 coef = alc_read_coef_idx(codec, 0x1e);
14430 alc_write_coef_idx(codec, 0x1e, coef | 0x80);
14431}
14432
Takashi Iwai6981d182011-04-15 10:11:12 +020014433static void alc271_fixup_dmic(struct hda_codec *codec,
14434 const struct alc_fixup *fix, int action)
14435{
Takashi Iwaia9111322011-05-02 11:30:18 +020014436 static const struct hda_verb verbs[] = {
Takashi Iwai6981d182011-04-15 10:11:12 +020014437 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14438 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14439 {}
14440 };
14441 unsigned int cfg;
14442
14443 if (strcmp(codec->chip_name, "ALC271X"))
14444 return;
14445 cfg = snd_hda_codec_get_pincfg(codec, 0x12);
14446 if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
14447 snd_hda_sequence_write(codec, verbs);
14448}
14449
Takashi Iwaiff818c22010-04-12 08:59:25 +020014450enum {
14451 ALC269_FIXUP_SONY_VAIO,
Takashi Iwai74dc8902011-01-13 14:14:41 +010014452 ALC275_FIXUP_SONY_VAIO_GPIO2,
David Henningsson145a9022010-09-16 10:07:53 +020014453 ALC269_FIXUP_DELL_M101Z,
David Henningsson022c92b2010-12-17 20:43:04 +010014454 ALC269_FIXUP_SKU_IGNORE,
David Henningssonac612402010-12-15 09:18:18 +010014455 ALC269_FIXUP_ASUS_G73JW,
Kailang Yang357f9152011-01-12 08:12:52 +010014456 ALC269_FIXUP_LENOVO_EAPD,
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014457 ALC275_FIXUP_SONY_HWEQ,
Takashi Iwai6981d182011-04-15 10:11:12 +020014458 ALC271_FIXUP_DMIC,
Takashi Iwaiff818c22010-04-12 08:59:25 +020014459};
14460
Takashi Iwaiff818c22010-04-12 08:59:25 +020014461static const struct alc_fixup alc269_fixups[] = {
14462 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014463 .type = ALC_FIXUP_VERBS,
14464 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020014465 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14466 {}
14467 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014468 },
Takashi Iwai74dc8902011-01-13 14:14:41 +010014469 [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014470 .type = ALC_FIXUP_VERBS,
14471 .v.verbs = (const struct hda_verb[]) {
Kailang Yang27855912010-12-21 09:09:53 +010014472 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
14473 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
14474 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
14475 { }
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014476 },
14477 .chained = true,
14478 .chain_id = ALC269_FIXUP_SONY_VAIO
Kailang Yang27855912010-12-21 09:09:53 +010014479 },
David Henningsson145a9022010-09-16 10:07:53 +020014480 [ALC269_FIXUP_DELL_M101Z] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014481 .type = ALC_FIXUP_VERBS,
14482 .v.verbs = (const struct hda_verb[]) {
David Henningsson145a9022010-09-16 10:07:53 +020014483 /* Enables internal speaker */
14484 {0x20, AC_VERB_SET_COEF_INDEX, 13},
14485 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
14486 {}
14487 }
14488 },
David Henningsson022c92b2010-12-17 20:43:04 +010014489 [ALC269_FIXUP_SKU_IGNORE] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014490 .type = ALC_FIXUP_SKU,
14491 .v.sku = ALC_FIXUP_SKU_IGNORE,
David Henningssonfe67b242010-12-15 08:01:46 +010014492 },
David Henningssonac612402010-12-15 09:18:18 +010014493 [ALC269_FIXUP_ASUS_G73JW] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014494 .type = ALC_FIXUP_PINS,
14495 .v.pins = (const struct alc_pincfg[]) {
David Henningssonac612402010-12-15 09:18:18 +010014496 { 0x17, 0x99130111 }, /* subwoofer */
14497 { }
14498 }
14499 },
Kailang Yang357f9152011-01-12 08:12:52 +010014500 [ALC269_FIXUP_LENOVO_EAPD] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014501 .type = ALC_FIXUP_VERBS,
14502 .v.verbs = (const struct hda_verb[]) {
Kailang Yang357f9152011-01-12 08:12:52 +010014503 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
14504 {}
14505 }
14506 },
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014507 [ALC275_FIXUP_SONY_HWEQ] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014508 .type = ALC_FIXUP_FUNC,
14509 .v.func = alc269_fixup_hweq,
14510 .chained = true,
14511 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
Takashi Iwai6981d182011-04-15 10:11:12 +020014512 },
14513 [ALC271_FIXUP_DMIC] = {
14514 .type = ALC_FIXUP_FUNC,
14515 .v.func = alc271_fixup_dmic,
14516 },
Takashi Iwaiff818c22010-04-12 08:59:25 +020014517};
14518
Takashi Iwaia9111322011-05-02 11:30:18 +020014519static const struct snd_pci_quirk alc269_fixup_tbl[] = {
Takashi Iwai74dc8902011-01-13 14:14:41 +010014520 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014521 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
14522 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
Takashi Iwai7039c742010-12-23 16:35:34 +010014523 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningsson145a9022010-09-16 10:07:53 +020014524 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
Takashi Iwai6981d182011-04-15 10:11:12 +020014525 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
David Henningsson022c92b2010-12-17 20:43:04 +010014526 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
David Henningssonded9f522011-01-26 11:46:12 +010014527 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
14528 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
14529 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
14530 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
David Henningssonac612402010-12-15 09:18:18 +010014531 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
Kailang Yang357f9152011-01-12 08:12:52 +010014532 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014533 {}
14534};
14535
14536
Kailang Yangf6a92242007-12-13 16:52:54 +010014537/*
14538 * configuration and preset
14539 */
Takashi Iwaiea734962011-01-17 11:29:34 +010014540static const char * const alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014541 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014542 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014543 [ALC269_AMIC] = "laptop-amic",
14544 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014545 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014546 [ALC269_LIFEBOOK] = "lifebook",
14547 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014548};
14549
Takashi Iwaia9111322011-05-02 11:30:18 +020014550static const struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014551 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014552 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020014553 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014554 ALC269_AMIC),
14555 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14556 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14557 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14558 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14559 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14560 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14561 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14562 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14563 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
Chih-Wei Huangc790ad32011-02-25 11:14:31 +080014564 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269VB_AMIC),
Kailang Yang84898e82010-02-04 14:16:14 +010014565 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14566 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14567 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14568 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14569 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14570 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14571 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14572 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14573 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14574 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14575 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14576 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14577 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14578 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14579 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14580 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14581 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14582 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14583 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14584 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14585 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14586 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14587 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14588 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14589 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14590 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014591 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014592 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014593 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014594 ALC269_DMIC),
14595 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14596 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014597 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000014598 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014599 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14600 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14601 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14602 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14603 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14604 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014605 {}
14606};
14607
Takashi Iwaia9111322011-05-02 11:30:18 +020014608static const struct alc_config_preset alc269_presets[] = {
Kailang Yangf6a92242007-12-13 16:52:54 +010014609 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014610 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010014611 .init_verbs = { alc269_init_verbs },
14612 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14613 .dac_nids = alc269_dac_nids,
14614 .hp_nid = 0x03,
14615 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14616 .channel_mode = alc269_modes,
14617 .input_mux = &alc269_capture_source,
14618 },
Kailang Yang60db6b52008-08-26 13:13:00 +020014619 [ALC269_QUANTA_FL1] = {
14620 .mixers = { alc269_quanta_fl1_mixer },
14621 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
14622 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14623 .dac_nids = alc269_dac_nids,
14624 .hp_nid = 0x03,
14625 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14626 .channel_mode = alc269_modes,
14627 .input_mux = &alc269_capture_source,
14628 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014629 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020014630 .init_hook = alc269_quanta_fl1_init_hook,
14631 },
Kailang Yang84898e82010-02-04 14:16:14 +010014632 [ALC269_AMIC] = {
14633 .mixers = { alc269_laptop_mixer },
14634 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014635 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014636 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014637 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14638 .dac_nids = alc269_dac_nids,
14639 .hp_nid = 0x03,
14640 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14641 .channel_mode = alc269_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014642 .unsol_event = alc_sku_unsol_event,
Kailang Yang84898e82010-02-04 14:16:14 +010014643 .setup = alc269_laptop_amic_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014644 .init_hook = alc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014645 },
Kailang Yang84898e82010-02-04 14:16:14 +010014646 [ALC269_DMIC] = {
14647 .mixers = { alc269_laptop_mixer },
14648 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014649 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014650 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014651 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14652 .dac_nids = alc269_dac_nids,
14653 .hp_nid = 0x03,
14654 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14655 .channel_mode = alc269_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014656 .unsol_event = alc_sku_unsol_event,
Kailang Yang84898e82010-02-04 14:16:14 +010014657 .setup = alc269_laptop_dmic_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014658 .init_hook = alc_inithook,
Kailang Yang84898e82010-02-04 14:16:14 +010014659 },
14660 [ALC269VB_AMIC] = {
14661 .mixers = { alc269vb_laptop_mixer },
14662 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14663 .init_verbs = { alc269vb_init_verbs,
14664 alc269vb_laptop_amic_init_verbs },
14665 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14666 .dac_nids = alc269_dac_nids,
14667 .hp_nid = 0x03,
14668 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14669 .channel_mode = alc269_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014670 .unsol_event = alc_sku_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020014671 .setup = alc269vb_laptop_amic_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014672 .init_hook = alc_inithook,
Kailang Yang84898e82010-02-04 14:16:14 +010014673 },
14674 [ALC269VB_DMIC] = {
14675 .mixers = { alc269vb_laptop_mixer },
14676 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14677 .init_verbs = { alc269vb_init_verbs,
14678 alc269vb_laptop_dmic_init_verbs },
14679 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14680 .dac_nids = alc269_dac_nids,
14681 .hp_nid = 0x03,
14682 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14683 .channel_mode = alc269_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014684 .unsol_event = alc_sku_unsol_event,
Kailang Yang84898e82010-02-04 14:16:14 +010014685 .setup = alc269vb_laptop_dmic_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014686 .init_hook = alc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014687 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014688 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014689 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014690 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014691 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014692 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014693 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14694 .dac_nids = alc269_dac_nids,
14695 .hp_nid = 0x03,
14696 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14697 .channel_mode = alc269_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014698 .unsol_event = alc_sku_unsol_event,
Kailang Yang84898e82010-02-04 14:16:14 +010014699 .setup = alc269_laptop_dmic_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014700 .init_hook = alc_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014701 },
Tony Vroon64154832008-11-06 15:08:49 +000014702 [ALC269_LIFEBOOK] = {
14703 .mixers = { alc269_lifebook_mixer },
14704 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
14705 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14706 .dac_nids = alc269_dac_nids,
14707 .hp_nid = 0x03,
14708 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14709 .channel_mode = alc269_modes,
14710 .input_mux = &alc269_capture_source,
14711 .unsol_event = alc269_lifebook_unsol_event,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014712 .setup = alc269_lifebook_setup,
Tony Vroon64154832008-11-06 15:08:49 +000014713 .init_hook = alc269_lifebook_init_hook,
14714 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014715 [ALC271_ACER] = {
14716 .mixers = { alc269_asus_mixer },
14717 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14718 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
14719 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14720 .dac_nids = alc269_dac_nids,
14721 .adc_nids = alc262_dmic_adc_nids,
14722 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
14723 .capsrc_nids = alc262_dmic_capsrc_nids,
14724 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14725 .channel_mode = alc269_modes,
14726 .input_mux = &alc269_capture_source,
14727 .dig_out_nid = ALC880_DIGOUT_NID,
14728 .unsol_event = alc_sku_unsol_event,
14729 .setup = alc269vb_laptop_dmic_setup,
14730 .init_hook = alc_inithook,
14731 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014732};
14733
Kailang Yang977ddd62010-09-15 10:02:29 +020014734static int alc269_fill_coef(struct hda_codec *codec)
14735{
14736 int val;
14737
14738 if ((alc_read_coef_idx(codec, 0) & 0x00ff) < 0x015) {
14739 alc_write_coef_idx(codec, 0xf, 0x960b);
14740 alc_write_coef_idx(codec, 0xe, 0x8817);
14741 }
14742
14743 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x016) {
14744 alc_write_coef_idx(codec, 0xf, 0x960b);
14745 alc_write_coef_idx(codec, 0xe, 0x8814);
14746 }
14747
14748 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
14749 val = alc_read_coef_idx(codec, 0x04);
14750 /* Power up output pin */
14751 alc_write_coef_idx(codec, 0x04, val | (1<<11));
14752 }
14753
14754 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
14755 val = alc_read_coef_idx(codec, 0xd);
14756 if ((val & 0x0c00) >> 10 != 0x1) {
14757 /* Capless ramp up clock control */
Kailang Yangb896b4e2011-05-18 11:53:16 +020014758 alc_write_coef_idx(codec, 0xd, val | (1<<10));
Kailang Yang977ddd62010-09-15 10:02:29 +020014759 }
14760 val = alc_read_coef_idx(codec, 0x17);
14761 if ((val & 0x01c0) >> 6 != 0x4) {
14762 /* Class D power on reset */
Kailang Yangb896b4e2011-05-18 11:53:16 +020014763 alc_write_coef_idx(codec, 0x17, val | (1<<7));
Kailang Yang977ddd62010-09-15 10:02:29 +020014764 }
14765 }
Kailang Yangb896b4e2011-05-18 11:53:16 +020014766
14767 val = alc_read_coef_idx(codec, 0xd); /* Class D */
14768 alc_write_coef_idx(codec, 0xd, val | (1<<14));
14769
14770 val = alc_read_coef_idx(codec, 0x4); /* HP */
14771 alc_write_coef_idx(codec, 0x4, val | (1<<11));
14772
Kailang Yang977ddd62010-09-15 10:02:29 +020014773 return 0;
14774}
14775
Kailang Yangf6a92242007-12-13 16:52:54 +010014776static int patch_alc269(struct hda_codec *codec)
14777{
14778 struct alc_spec *spec;
Kailang Yang48c88e82010-11-23 08:56:16 +010014779 int board_config, coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010014780 int err;
14781
14782 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14783 if (spec == NULL)
14784 return -ENOMEM;
14785
14786 codec->spec = spec;
14787
Takashi Iwai1f0f4b82011-06-27 10:52:59 +020014788 spec->mixer_nid = 0x0b;
14789
Kailang Yangda00c242010-03-19 11:23:45 +010014790 alc_auto_parse_customize_define(codec);
14791
Kailang Yangc793bec2010-12-21 09:14:13 +010014792 if (codec->vendor_id == 0x10ec0269) {
Kailang Yangb6878572011-07-06 09:51:29 +020014793 spec->codec_variant = ALC269_TYPE_ALC269VA;
Kailang Yangc793bec2010-12-21 09:14:13 +010014794 coef = alc_read_coef_idx(codec, 0);
14795 if ((coef & 0x00f0) == 0x0010) {
14796 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
14797 spec->cdefine.platform_type == 1) {
14798 alc_codec_rename(codec, "ALC271X");
Kailang Yangc793bec2010-12-21 09:14:13 +010014799 } else if ((coef & 0xf000) == 0x2000) {
14800 alc_codec_rename(codec, "ALC259");
Kailang Yangc793bec2010-12-21 09:14:13 +010014801 } else if ((coef & 0xf000) == 0x3000) {
14802 alc_codec_rename(codec, "ALC258");
Kailang Yangb6878572011-07-06 09:51:29 +020014803 } else if ((coef & 0xfff0) == 0x3010) {
14804 alc_codec_rename(codec, "ALC277");
Kailang Yangc793bec2010-12-21 09:14:13 +010014805 } else {
14806 alc_codec_rename(codec, "ALC269VB");
Kailang Yangc793bec2010-12-21 09:14:13 +010014807 }
Kailang Yangb6878572011-07-06 09:51:29 +020014808 spec->codec_variant = ALC269_TYPE_ALC269VB;
14809 } else if ((coef & 0x00f0) == 0x0020) {
14810 if (coef == 0xa023)
14811 alc_codec_rename(codec, "ALC259");
14812 else if (coef == 0x6023)
14813 alc_codec_rename(codec, "ALC281X");
14814 else if (codec->bus->pci->subsystem_vendor == 0x17aa &&
14815 codec->bus->pci->subsystem_device == 0x21f3)
14816 alc_codec_rename(codec, "ALC3202");
14817 else
14818 alc_codec_rename(codec, "ALC269VC");
14819 spec->codec_variant = ALC269_TYPE_ALC269VC;
Kailang Yangc793bec2010-12-21 09:14:13 +010014820 } else
14821 alc_fix_pll_init(codec, 0x20, 0x04, 15);
14822 alc269_fill_coef(codec);
14823 }
Kailang Yang977ddd62010-09-15 10:02:29 +020014824
Kailang Yangf6a92242007-12-13 16:52:54 +010014825 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
14826 alc269_models,
14827 alc269_cfg_tbl);
14828
14829 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014830 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14831 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010014832 board_config = ALC269_AUTO;
14833 }
14834
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014835 if (board_config == ALC269_AUTO) {
14836 alc_pick_fixup(codec, NULL, alc269_fixup_tbl, alc269_fixups);
14837 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
14838 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014839
Kailang Yangf6a92242007-12-13 16:52:54 +010014840 if (board_config == ALC269_AUTO) {
14841 /* automatic parse from the BIOS config */
14842 err = alc269_parse_auto_config(codec);
14843 if (err < 0) {
14844 alc_free(codec);
14845 return err;
14846 } else if (!err) {
14847 printk(KERN_INFO
14848 "hda_codec: Cannot set up configuration "
14849 "from BIOS. Using base mode...\n");
14850 board_config = ALC269_BASIC;
14851 }
14852 }
14853
Takashi Iwaidc1eae22010-07-29 15:30:02 +020014854 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020014855 err = snd_hda_attach_beep_device(codec, 0x1);
14856 if (err < 0) {
14857 alc_free(codec);
14858 return err;
14859 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014860 }
14861
Kailang Yangf6a92242007-12-13 16:52:54 +010014862 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014863 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010014864
Kailang Yang84898e82010-02-04 14:16:14 +010014865 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010014866 /* Due to a hardware problem on Lenovo Ideadpad, we need to
14867 * fix the sample rate of analog I/O to 44.1kHz
14868 */
14869 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
14870 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020014871 } else if (spec->dual_adc_switch) {
14872 spec->stream_analog_playback = &alc269_pcm_analog_playback;
14873 /* switch ADC dynamically */
14874 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010014875 } else {
14876 spec->stream_analog_playback = &alc269_pcm_analog_playback;
14877 spec->stream_analog_capture = &alc269_pcm_analog_capture;
14878 }
Kailang Yangf6a92242007-12-13 16:52:54 +010014879 spec->stream_digital_playback = &alc269_pcm_digital_playback;
14880 spec->stream_digital_capture = &alc269_pcm_digital_capture;
14881
Takashi Iwai66946352010-03-29 17:21:45 +020014882 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +020014883 alc_auto_fill_adc_caps(codec);
14884 alc_remove_invalid_adc_nids(codec);
Kailang Yang84898e82010-02-04 14:16:14 +010014885 }
14886
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014887 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014888 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020014889 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010014890 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010014891
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014892 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwaiff818c22010-04-12 08:59:25 +020014893
Takashi Iwai100d5eb2009-08-10 11:55:51 +020014894 spec->vmaster_nid = 0x02;
14895
Kailang Yangf6a92242007-12-13 16:52:54 +010014896 codec->patch_ops = alc_patch_ops;
Kailang Yang977ddd62010-09-15 10:02:29 +020014897#ifdef SND_HDA_NEEDS_RESUME
14898 codec->patch_ops.resume = alc269_resume;
14899#endif
Kailang Yangf6a92242007-12-13 16:52:54 +010014900 if (board_config == ALC269_AUTO)
14901 spec->init_hook = alc269_auto_init;
Takashi Iwai5402e4c2011-04-07 10:39:25 +020014902 spec->shutup = alc269_shutup;
Kailang Yangbf1b0222010-10-21 08:49:56 +020014903
14904 alc_init_jacks(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014905#ifdef CONFIG_SND_HDA_POWER_SAVE
14906 if (!spec->loopback.amplist)
14907 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020014908 if (alc269_mic2_for_mute_led(codec))
14909 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010014910#endif
14911
14912 return 0;
14913}
14914
14915/*
Kailang Yangdf694da2005-12-05 19:42:22 +010014916 * ALC861 channel source setting (2/6 channel selection for 3-stack)
14917 */
14918
14919/*
14920 * set the path ways for 2 channel output
14921 * need to set the codec line out and mic 1 pin widgets to inputs
14922 */
Takashi Iwaia9111322011-05-02 11:30:18 +020014923static const struct hda_verb alc861_threestack_ch2_init[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010014924 /* set pin widget 1Ah (line in) for input */
14925 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014926 /* set pin widget 18h (mic1/2) for input, for mic also enable
14927 * the vref
14928 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014929 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14930
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014931 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14932#if 0
14933 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14934 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14935#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014936 { } /* end */
14937};
14938/*
14939 * 6ch mode
14940 * need to set the codec line out and mic 1 pin widgets to outputs
14941 */
Takashi Iwaia9111322011-05-02 11:30:18 +020014942static const struct hda_verb alc861_threestack_ch6_init[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010014943 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14944 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14945 /* set pin widget 18h (mic1) for output (CLFE)*/
14946 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14947
14948 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014949 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014950
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014951 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14952#if 0
14953 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14954 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14955#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014956 { } /* end */
14957};
14958
Takashi Iwaia9111322011-05-02 11:30:18 +020014959static const struct hda_channel_mode alc861_threestack_modes[2] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010014960 { 2, alc861_threestack_ch2_init },
14961 { 6, alc861_threestack_ch6_init },
14962};
Takashi Iwai22309c32006-08-09 16:57:28 +020014963/* Set mic1 as input and unmute the mixer */
Takashi Iwaia9111322011-05-02 11:30:18 +020014964static const struct hda_verb alc861_uniwill_m31_ch2_init[] = {
Takashi Iwai22309c32006-08-09 16:57:28 +020014965 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14966 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14967 { } /* end */
14968};
14969/* Set mic1 as output and mute mixer */
Takashi Iwaia9111322011-05-02 11:30:18 +020014970static const struct hda_verb alc861_uniwill_m31_ch4_init[] = {
Takashi Iwai22309c32006-08-09 16:57:28 +020014971 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14972 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14973 { } /* end */
14974};
14975
Takashi Iwaia9111322011-05-02 11:30:18 +020014976static const struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
Takashi Iwai22309c32006-08-09 16:57:28 +020014977 { 2, alc861_uniwill_m31_ch2_init },
14978 { 4, alc861_uniwill_m31_ch4_init },
14979};
Kailang Yangdf694da2005-12-05 19:42:22 +010014980
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014981/* Set mic1 and line-in as input and unmute the mixer */
Takashi Iwaia9111322011-05-02 11:30:18 +020014982static const struct hda_verb alc861_asus_ch2_init[] = {
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014983 /* set pin widget 1Ah (line in) for input */
14984 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014985 /* set pin widget 18h (mic1/2) for input, for mic also enable
14986 * the vref
14987 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014988 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14989
14990 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14991#if 0
14992 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14993 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14994#endif
14995 { } /* end */
14996};
14997/* Set mic1 nad line-in as output and mute mixer */
Takashi Iwaia9111322011-05-02 11:30:18 +020014998static const struct hda_verb alc861_asus_ch6_init[] = {
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014999 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15000 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15001 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15002 /* set pin widget 18h (mic1) for output (CLFE)*/
15003 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15004 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15005 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
15006 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
15007
15008 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15009#if 0
15010 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15011 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15012#endif
15013 { } /* end */
15014};
15015
Takashi Iwaia9111322011-05-02 11:30:18 +020015016static const struct hda_channel_mode alc861_asus_modes[2] = {
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015017 { 2, alc861_asus_ch2_init },
15018 { 6, alc861_asus_ch6_init },
15019};
15020
Kailang Yangdf694da2005-12-05 19:42:22 +010015021/* patch-ALC861 */
15022
Takashi Iwaia9111322011-05-02 11:30:18 +020015023static const struct snd_kcontrol_new alc861_base_mixer[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010015024 /* output mixer control */
15025 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15026 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15027 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15028 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15029 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15030
15031 /*Input mixer control */
15032 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15033 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15034 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15035 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15036 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15037 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15038 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15039 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15040 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15041 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015042
Kailang Yangdf694da2005-12-05 19:42:22 +010015043 { } /* end */
15044};
15045
Takashi Iwaia9111322011-05-02 11:30:18 +020015046static const struct snd_kcontrol_new alc861_3ST_mixer[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010015047 /* output mixer control */
15048 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15049 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15050 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15051 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15052 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15053
15054 /* Input mixer control */
15055 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15056 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15057 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15058 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15059 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15060 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15061 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15062 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15063 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15064 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015065
Kailang Yangdf694da2005-12-05 19:42:22 +010015066 {
15067 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15068 .name = "Channel Mode",
15069 .info = alc_ch_mode_info,
15070 .get = alc_ch_mode_get,
15071 .put = alc_ch_mode_put,
15072 .private_value = ARRAY_SIZE(alc861_threestack_modes),
15073 },
15074 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015075};
15076
Takashi Iwaia9111322011-05-02 11:30:18 +020015077static const struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015078 /* output mixer control */
15079 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15080 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15081 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015082
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015083 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015084};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015085
Takashi Iwaia9111322011-05-02 11:30:18 +020015086static const struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
Takashi Iwai22309c32006-08-09 16:57:28 +020015087 /* output mixer control */
15088 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15089 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15090 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15091 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15092 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15093
15094 /* Input mixer control */
15095 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15096 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15097 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15098 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15099 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15100 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15101 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15102 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15103 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15104 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015105
Takashi Iwai22309c32006-08-09 16:57:28 +020015106 {
15107 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15108 .name = "Channel Mode",
15109 .info = alc_ch_mode_info,
15110 .get = alc_ch_mode_get,
15111 .put = alc_ch_mode_put,
15112 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
15113 },
15114 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015115};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015116
Takashi Iwaia9111322011-05-02 11:30:18 +020015117static const struct snd_kcontrol_new alc861_asus_mixer[] = {
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015118 /* output mixer control */
15119 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15120 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15121 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15122 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15123 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15124
15125 /* Input mixer control */
15126 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15127 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15128 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15129 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15130 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15131 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15132 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15133 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15134 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015135 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
15136
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015137 {
15138 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15139 .name = "Channel Mode",
15140 .info = alc_ch_mode_info,
15141 .get = alc_ch_mode_get,
15142 .put = alc_ch_mode_put,
15143 .private_value = ARRAY_SIZE(alc861_asus_modes),
15144 },
15145 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015146};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015147
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015148/* additional mixer */
Takashi Iwaia9111322011-05-02 11:30:18 +020015149static const struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015150 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15151 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015152 { }
15153};
15154
Kailang Yangdf694da2005-12-05 19:42:22 +010015155/*
15156 * generic initialization of ADC, input mixers and output mixers
15157 */
Takashi Iwaia9111322011-05-02 11:30:18 +020015158static const struct hda_verb alc861_base_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010015159 /*
15160 * Unmute ADC0 and set the default input to mic-in
15161 */
15162 /* port-A for surround (rear panel) */
15163 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15164 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
15165 /* port-B for mic-in (rear panel) with vref */
15166 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15167 /* port-C for line-in (rear panel) */
15168 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15169 /* port-D for Front */
15170 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15171 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15172 /* port-E for HP out (front panel) */
15173 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15174 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015175 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015176 /* port-F for mic-in (front panel) with vref */
15177 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15178 /* port-G for CLFE (rear panel) */
15179 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15180 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15181 /* port-H for side (rear panel) */
15182 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15183 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15184 /* CD-in */
15185 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15186 /* route front mic to ADC1*/
15187 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15188 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015189
Kailang Yangdf694da2005-12-05 19:42:22 +010015190 /* Unmute DAC0~3 & spdif out*/
15191 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15192 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15193 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15194 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15195 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015196
Kailang Yangdf694da2005-12-05 19:42:22 +010015197 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15198 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15199 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15200 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15201 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015202
Kailang Yangdf694da2005-12-05 19:42:22 +010015203 /* Unmute Stereo Mixer 15 */
15204 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15205 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15206 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015207 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015208
15209 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15210 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15211 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15212 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15213 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15214 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15215 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15216 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015217 /* hp used DAC 3 (Front) */
15218 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015219 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15220
15221 { }
15222};
15223
Takashi Iwaia9111322011-05-02 11:30:18 +020015224static const struct hda_verb alc861_threestack_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010015225 /*
15226 * Unmute ADC0 and set the default input to mic-in
15227 */
15228 /* port-A for surround (rear panel) */
15229 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15230 /* port-B for mic-in (rear panel) with vref */
15231 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15232 /* port-C for line-in (rear panel) */
15233 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15234 /* port-D for Front */
15235 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15236 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15237 /* port-E for HP out (front panel) */
15238 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15239 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015240 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015241 /* port-F for mic-in (front panel) with vref */
15242 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15243 /* port-G for CLFE (rear panel) */
15244 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15245 /* port-H for side (rear panel) */
15246 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15247 /* CD-in */
15248 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15249 /* route front mic to ADC1*/
15250 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15251 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15252 /* Unmute DAC0~3 & spdif out*/
15253 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15254 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15255 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15256 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15257 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015258
Kailang Yangdf694da2005-12-05 19:42:22 +010015259 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15260 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15261 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15262 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15263 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015264
Kailang Yangdf694da2005-12-05 19:42:22 +010015265 /* Unmute Stereo Mixer 15 */
15266 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15267 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15268 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015269 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015270
15271 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15272 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15273 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15274 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15275 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15276 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15277 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15278 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015279 /* hp used DAC 3 (Front) */
15280 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015281 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15282 { }
15283};
Takashi Iwai22309c32006-08-09 16:57:28 +020015284
Takashi Iwaia9111322011-05-02 11:30:18 +020015285static const struct hda_verb alc861_uniwill_m31_init_verbs[] = {
Takashi Iwai22309c32006-08-09 16:57:28 +020015286 /*
15287 * Unmute ADC0 and set the default input to mic-in
15288 */
15289 /* port-A for surround (rear panel) */
15290 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15291 /* port-B for mic-in (rear panel) with vref */
15292 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15293 /* port-C for line-in (rear panel) */
15294 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15295 /* port-D for Front */
15296 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15297 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15298 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015299 /* this has to be set to VREF80 */
15300 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015301 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015302 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015303 /* port-F for mic-in (front panel) with vref */
15304 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15305 /* port-G for CLFE (rear panel) */
15306 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15307 /* port-H for side (rear panel) */
15308 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15309 /* CD-in */
15310 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15311 /* route front mic to ADC1*/
15312 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15313 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15314 /* Unmute DAC0~3 & spdif out*/
15315 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15316 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15317 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15318 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15319 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015320
Takashi Iwai22309c32006-08-09 16:57:28 +020015321 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15322 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15323 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15324 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15325 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015326
Takashi Iwai22309c32006-08-09 16:57:28 +020015327 /* Unmute Stereo Mixer 15 */
15328 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15329 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15330 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015331 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015332
15333 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15334 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15335 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15336 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15337 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15338 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15339 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15340 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015341 /* hp used DAC 3 (Front) */
15342 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015343 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15344 { }
15345};
15346
Takashi Iwaia9111322011-05-02 11:30:18 +020015347static const struct hda_verb alc861_asus_init_verbs[] = {
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015348 /*
15349 * Unmute ADC0 and set the default input to mic-in
15350 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015351 /* port-A for surround (rear panel)
15352 * according to codec#0 this is the HP jack
15353 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015354 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15355 /* route front PCM to HP */
15356 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15357 /* port-B for mic-in (rear panel) with vref */
15358 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15359 /* port-C for line-in (rear panel) */
15360 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15361 /* port-D for Front */
15362 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15363 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15364 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015365 /* this has to be set to VREF80 */
15366 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015367 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015368 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015369 /* port-F for mic-in (front panel) with vref */
15370 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15371 /* port-G for CLFE (rear panel) */
15372 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15373 /* port-H for side (rear panel) */
15374 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15375 /* CD-in */
15376 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15377 /* route front mic to ADC1*/
15378 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15379 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15380 /* Unmute DAC0~3 & spdif out*/
15381 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15382 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15383 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15384 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15385 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15386 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15387 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15388 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15389 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15390 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015391
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015392 /* Unmute Stereo Mixer 15 */
15393 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15394 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15395 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015396 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015397
15398 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15399 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15400 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15401 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15402 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15403 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15404 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15405 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015406 /* hp used DAC 3 (Front) */
15407 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015408 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15409 { }
15410};
15411
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015412/* additional init verbs for ASUS laptops */
Takashi Iwaia9111322011-05-02 11:30:18 +020015413static const struct hda_verb alc861_asus_laptop_init_verbs[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015414 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15415 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15416 { }
15417};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015418
Takashi Iwaia9111322011-05-02 11:30:18 +020015419static const struct hda_verb alc861_toshiba_init_verbs[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015420 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015421
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015422 { }
15423};
15424
15425/* toggle speaker-output according to the hp-jack state */
15426static void alc861_toshiba_automute(struct hda_codec *codec)
15427{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015428 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015429
Takashi Iwai47fd8302007-08-10 17:11:07 +020015430 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15431 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15432 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15433 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015434}
15435
15436static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15437 unsigned int res)
15438{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015439 if ((res >> 26) == ALC880_HP_EVENT)
15440 alc861_toshiba_automute(codec);
15441}
15442
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015443/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015444#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15445#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15446#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15447#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15448
15449
15450#define ALC861_DIGOUT_NID 0x07
15451
Takashi Iwaia9111322011-05-02 11:30:18 +020015452static const struct hda_channel_mode alc861_8ch_modes[1] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010015453 { 8, NULL }
15454};
15455
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020015456static const hda_nid_t alc861_dac_nids[4] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010015457 /* front, surround, clfe, side */
15458 0x03, 0x06, 0x05, 0x04
15459};
15460
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020015461static const hda_nid_t alc660_dac_nids[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015462 /* front, clfe, surround */
15463 0x03, 0x05, 0x06
15464};
15465
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020015466static const hda_nid_t alc861_adc_nids[1] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010015467 /* ADC0-2 */
15468 0x08,
15469};
15470
Takashi Iwaia9111322011-05-02 11:30:18 +020015471static const struct hda_input_mux alc861_capture_source = {
Kailang Yangdf694da2005-12-05 19:42:22 +010015472 .num_items = 5,
15473 .items = {
15474 { "Mic", 0x0 },
15475 { "Front Mic", 0x3 },
15476 { "Line", 0x1 },
15477 { "CD", 0x4 },
15478 { "Mixer", 0x5 },
15479 },
15480};
15481
Takashi Iwai1c209302009-07-22 15:17:45 +020015482static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15483{
15484 struct alc_spec *spec = codec->spec;
15485 hda_nid_t mix, srcs[5];
Takashi Iwai3af9ee62011-06-27 12:34:01 +020015486 int i, num;
Takashi Iwai1c209302009-07-22 15:17:45 +020015487
15488 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15489 return 0;
15490 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15491 if (num < 0)
15492 return 0;
15493 for (i = 0; i < num; i++) {
15494 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015495 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015496 if (type != AC_WID_AUD_OUT)
15497 continue;
Takashi Iwai3af9ee62011-06-27 12:34:01 +020015498 if (!found_in_nid_list(srcs[i], spec->multiout.dac_nids,
15499 spec->multiout.num_dacs))
Takashi Iwai1c209302009-07-22 15:17:45 +020015500 return srcs[i];
15501 }
15502 return 0;
15503}
15504
Kailang Yangdf694da2005-12-05 19:42:22 +010015505/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaicb053a82011-06-27 11:32:07 +020015506static int alc861_auto_fill_dac_nids(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010015507{
Takashi Iwai1c209302009-07-22 15:17:45 +020015508 struct alc_spec *spec = codec->spec;
Takashi Iwaicb053a82011-06-27 11:32:07 +020015509 const struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +010015510 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015511 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015512
15513 spec->multiout.dac_nids = spec->private_dac_nids;
15514 for (i = 0; i < cfg->line_outs; i++) {
15515 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015516 dac = alc861_look_for_dac(codec, nid);
15517 if (!dac)
15518 continue;
Takashi Iwaidda14412011-05-02 11:29:30 +020015519 spec->private_dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015520 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015521 return 0;
15522}
15523
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015524static int __alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15525 hda_nid_t nid, int idx, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015526{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015527 return __add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx, idx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015528 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15529}
15530
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015531#define alc861_create_out_sw(codec, pfx, nid, chs) \
15532 __alc861_create_out_sw(codec, pfx, nid, 0, chs)
15533
Takashi Iwai1c209302009-07-22 15:17:45 +020015534/* add playback controls from the parsed DAC table */
15535static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15536 const struct auto_pin_cfg *cfg)
15537{
15538 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015539 hda_nid_t nid;
Takashi Iwaice764ab2011-04-27 16:35:23 +020015540 int i, err, noutputs;
Takashi Iwai1c209302009-07-22 15:17:45 +020015541
Takashi Iwaice764ab2011-04-27 16:35:23 +020015542 noutputs = cfg->line_outs;
15543 if (spec->multi_ios > 0)
15544 noutputs += spec->multi_ios;
15545
15546 for (i = 0; i < noutputs; i++) {
Takashi Iwai6843ca12011-06-24 11:03:58 +020015547 const char *name;
15548 int index;
Kailang Yangdf694da2005-12-05 19:42:22 +010015549 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015550 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015551 continue;
Takashi Iwai6843ca12011-06-24 11:03:58 +020015552 name = alc_get_line_out_pfx(spec, i, true, &index);
15553 if (!name) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015554 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015555 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015556 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015557 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015558 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015559 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015560 return err;
15561 } else {
David Henningsson5a882642011-03-23 08:35:07 +010015562 err = __alc861_create_out_sw(codec, name, nid, index, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015563 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015564 return err;
15565 }
15566 }
15567 return 0;
15568}
15569
Takashi Iwai1c209302009-07-22 15:17:45 +020015570static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015571{
Takashi Iwai1c209302009-07-22 15:17:45 +020015572 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015573 int err;
15574 hda_nid_t nid;
15575
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015576 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015577 return 0;
15578
15579 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020015580 nid = alc861_look_for_dac(codec, pin);
15581 if (nid) {
15582 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
15583 if (err < 0)
15584 return err;
15585 spec->multiout.hp_nid = nid;
15586 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015587 }
15588 return 0;
15589}
15590
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015591static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
15592 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020015593 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010015594{
Takashi Iwai1c209302009-07-22 15:17:45 +020015595 hda_nid_t mix, srcs[5];
15596 int i, num;
15597
Jacek Luczak564c5be2008-05-03 18:41:23 +020015598 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
15599 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020015600 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020015601 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020015602 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
15603 return;
15604 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15605 if (num < 0)
15606 return;
15607 for (i = 0; i < num; i++) {
15608 unsigned int mute;
15609 if (srcs[i] == dac || srcs[i] == 0x15)
15610 mute = AMP_IN_UNMUTE(i);
15611 else
15612 mute = AMP_IN_MUTE(i);
15613 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15614 mute);
15615 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015616}
15617
15618static void alc861_auto_init_multi_out(struct hda_codec *codec)
15619{
15620 struct alc_spec *spec = codec->spec;
15621 int i;
15622
Takashi Iwai1f0f4b82011-06-27 10:52:59 +020015623 for (i = 0; i < spec->autocfg.line_outs + spec->multi_ios; i++) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015624 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015625 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015626 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015627 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015628 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015629 }
15630}
15631
15632static void alc861_auto_init_hp_out(struct hda_codec *codec)
15633{
15634 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015635
Takashi Iwai15870f02009-10-05 08:25:13 +020015636 if (spec->autocfg.hp_outs)
15637 alc861_auto_set_output_and_unmute(codec,
15638 spec->autocfg.hp_pins[0],
15639 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020015640 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020015641 if (spec->autocfg.speaker_outs)
15642 alc861_auto_set_output_and_unmute(codec,
15643 spec->autocfg.speaker_pins[0],
15644 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020015645 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015646}
15647
Kailang Yangdf694da2005-12-05 19:42:22 +010015648/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015649/* return 1 if successful, 0 if the proper config is not found,
15650 * or a negative error code
15651 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015652static int alc861_parse_auto_config(struct hda_codec *codec)
15653{
15654 struct alc_spec *spec = codec->spec;
15655 int err;
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020015656 static const hda_nid_t alc861_ignore[] = { 0x1d, 0 };
Kailang Yangdf694da2005-12-05 19:42:22 +010015657
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015658 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15659 alc861_ignore);
15660 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015661 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015662 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015663 return 0; /* can't find valid BIOS pin config */
15664
Takashi Iwaicb053a82011-06-27 11:32:07 +020015665 err = alc861_auto_fill_dac_nids(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015666 if (err < 0)
15667 return err;
Takashi Iwaicb053a82011-06-27 11:32:07 +020015668 err = alc_auto_add_multi_channel_mode(codec, alc861_auto_fill_dac_nids);
Takashi Iwaice764ab2011-04-27 16:35:23 +020015669 if (err < 0)
15670 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015671 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015672 if (err < 0)
15673 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015674 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015675 if (err < 0)
15676 return err;
Takashi Iwaib7821702011-07-06 15:12:46 +020015677 err = alc_auto_create_input_ctls(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015678 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015679 return err;
15680
15681 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15682
Takashi Iwai757899a2010-07-30 10:48:14 +020015683 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015684
Takashi Iwai603c4012008-07-30 15:01:44 +020015685 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015686 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010015687
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020015688 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015689 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010015690
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +020015691 if (!spec->dual_adc_switch)
15692 alc_remove_invalid_adc_nids(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015693
Kailang Yang6227cdc2010-02-25 08:36:52 +010015694 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015695
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +020015696 set_capture_mixer(codec);
15697
Kailang Yangdf694da2005-12-05 19:42:22 +010015698 return 1;
15699}
15700
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015701/* additional initialization for auto-configuration model */
15702static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010015703{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015704 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015705 alc861_auto_init_multi_out(codec);
15706 alc861_auto_init_hp_out(codec);
Takashi Iwai0a7f5322011-07-06 15:15:12 +020015707 alc_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020015708 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015709 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015710 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015711}
15712
Takashi Iwaicb53c622007-08-10 17:21:45 +020015713#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaia9111322011-05-02 11:30:18 +020015714static const struct hda_amp_list alc861_loopbacks[] = {
Takashi Iwaicb53c622007-08-10 17:21:45 +020015715 { 0x15, HDA_INPUT, 0 },
15716 { 0x15, HDA_INPUT, 1 },
15717 { 0x15, HDA_INPUT, 2 },
15718 { 0x15, HDA_INPUT, 3 },
15719 { } /* end */
15720};
15721#endif
15722
Kailang Yangdf694da2005-12-05 19:42:22 +010015723
15724/*
15725 * configuration and preset
15726 */
Takashi Iwaiea734962011-01-17 11:29:34 +010015727static const char * const alc861_models[ALC861_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015728 [ALC861_3ST] = "3stack",
15729 [ALC660_3ST] = "3stack-660",
15730 [ALC861_3ST_DIG] = "3stack-dig",
15731 [ALC861_6ST_DIG] = "6stack-dig",
15732 [ALC861_UNIWILL_M31] = "uniwill-m31",
15733 [ALC861_TOSHIBA] = "toshiba",
15734 [ALC861_ASUS] = "asus",
15735 [ALC861_ASUS_LAPTOP] = "asus-laptop",
15736 [ALC861_AUTO] = "auto",
15737};
15738
Takashi Iwaia9111322011-05-02 11:30:18 +020015739static const struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010015740 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015741 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15742 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15743 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015744 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020015745 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010015746 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020015747 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
15748 * Any other models that need this preset?
15749 */
15750 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020015751 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
15752 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015753 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
15754 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
15755 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
15756 /* FIXME: the below seems conflict */
15757 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
15758 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
15759 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010015760 {}
15761};
15762
Takashi Iwaia9111322011-05-02 11:30:18 +020015763static const struct alc_config_preset alc861_presets[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010015764 [ALC861_3ST] = {
15765 .mixers = { alc861_3ST_mixer },
15766 .init_verbs = { alc861_threestack_init_verbs },
15767 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15768 .dac_nids = alc861_dac_nids,
15769 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15770 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015771 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015772 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15773 .adc_nids = alc861_adc_nids,
15774 .input_mux = &alc861_capture_source,
15775 },
15776 [ALC861_3ST_DIG] = {
15777 .mixers = { alc861_base_mixer },
15778 .init_verbs = { alc861_threestack_init_verbs },
15779 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15780 .dac_nids = alc861_dac_nids,
15781 .dig_out_nid = ALC861_DIGOUT_NID,
15782 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15783 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015784 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015785 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15786 .adc_nids = alc861_adc_nids,
15787 .input_mux = &alc861_capture_source,
15788 },
15789 [ALC861_6ST_DIG] = {
15790 .mixers = { alc861_base_mixer },
15791 .init_verbs = { alc861_base_init_verbs },
15792 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15793 .dac_nids = alc861_dac_nids,
15794 .dig_out_nid = ALC861_DIGOUT_NID,
15795 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
15796 .channel_mode = alc861_8ch_modes,
15797 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15798 .adc_nids = alc861_adc_nids,
15799 .input_mux = &alc861_capture_source,
15800 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015801 [ALC660_3ST] = {
15802 .mixers = { alc861_3ST_mixer },
15803 .init_verbs = { alc861_threestack_init_verbs },
15804 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
15805 .dac_nids = alc660_dac_nids,
15806 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15807 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015808 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015809 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15810 .adc_nids = alc861_adc_nids,
15811 .input_mux = &alc861_capture_source,
15812 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015813 [ALC861_UNIWILL_M31] = {
15814 .mixers = { alc861_uniwill_m31_mixer },
15815 .init_verbs = { alc861_uniwill_m31_init_verbs },
15816 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15817 .dac_nids = alc861_dac_nids,
15818 .dig_out_nid = ALC861_DIGOUT_NID,
15819 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
15820 .channel_mode = alc861_uniwill_m31_modes,
15821 .need_dac_fix = 1,
15822 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15823 .adc_nids = alc861_adc_nids,
15824 .input_mux = &alc861_capture_source,
15825 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015826 [ALC861_TOSHIBA] = {
15827 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015828 .init_verbs = { alc861_base_init_verbs,
15829 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015830 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15831 .dac_nids = alc861_dac_nids,
15832 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15833 .channel_mode = alc883_3ST_2ch_modes,
15834 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15835 .adc_nids = alc861_adc_nids,
15836 .input_mux = &alc861_capture_source,
15837 .unsol_event = alc861_toshiba_unsol_event,
15838 .init_hook = alc861_toshiba_automute,
15839 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015840 [ALC861_ASUS] = {
15841 .mixers = { alc861_asus_mixer },
15842 .init_verbs = { alc861_asus_init_verbs },
15843 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15844 .dac_nids = alc861_dac_nids,
15845 .dig_out_nid = ALC861_DIGOUT_NID,
15846 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
15847 .channel_mode = alc861_asus_modes,
15848 .need_dac_fix = 1,
15849 .hp_nid = 0x06,
15850 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15851 .adc_nids = alc861_adc_nids,
15852 .input_mux = &alc861_capture_source,
15853 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015854 [ALC861_ASUS_LAPTOP] = {
15855 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
15856 .init_verbs = { alc861_asus_init_verbs,
15857 alc861_asus_laptop_init_verbs },
15858 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15859 .dac_nids = alc861_dac_nids,
15860 .dig_out_nid = ALC861_DIGOUT_NID,
15861 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15862 .channel_mode = alc883_3ST_2ch_modes,
15863 .need_dac_fix = 1,
15864 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15865 .adc_nids = alc861_adc_nids,
15866 .input_mux = &alc861_capture_source,
15867 },
15868};
Kailang Yangdf694da2005-12-05 19:42:22 +010015869
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015870/* Pin config fixes */
15871enum {
15872 PINFIX_FSC_AMILO_PI1505,
15873};
15874
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015875static const struct alc_fixup alc861_fixups[] = {
15876 [PINFIX_FSC_AMILO_PI1505] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010015877 .type = ALC_FIXUP_PINS,
15878 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020015879 { 0x0b, 0x0221101f }, /* HP */
15880 { 0x0f, 0x90170310 }, /* speaker */
15881 { }
15882 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015883 },
15884};
15885
Takashi Iwaia9111322011-05-02 11:30:18 +020015886static const struct snd_pci_quirk alc861_fixup_tbl[] = {
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015887 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
15888 {}
15889};
Kailang Yangdf694da2005-12-05 19:42:22 +010015890
15891static int patch_alc861(struct hda_codec *codec)
15892{
15893 struct alc_spec *spec;
15894 int board_config;
15895 int err;
15896
Robert P. J. Daydc041e02006-12-19 14:44:15 +010015897 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010015898 if (spec == NULL)
15899 return -ENOMEM;
15900
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015901 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015902
Takashi Iwai1f0f4b82011-06-27 10:52:59 +020015903 spec->mixer_nid = 0x15;
15904
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015905 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
15906 alc861_models,
15907 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015908
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015909 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015910 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15911 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010015912 board_config = ALC861_AUTO;
15913 }
15914
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010015915 if (board_config == ALC861_AUTO) {
15916 alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
15917 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
15918 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015919
Kailang Yangdf694da2005-12-05 19:42:22 +010015920 if (board_config == ALC861_AUTO) {
15921 /* automatic parse from the BIOS config */
15922 err = alc861_parse_auto_config(codec);
15923 if (err < 0) {
15924 alc_free(codec);
15925 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015926 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015927 printk(KERN_INFO
15928 "hda_codec: Cannot set up configuration "
15929 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010015930 board_config = ALC861_3ST_DIG;
15931 }
15932 }
15933
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015934 err = snd_hda_attach_beep_device(codec, 0x23);
15935 if (err < 0) {
15936 alc_free(codec);
15937 return err;
15938 }
15939
Kailang Yangdf694da2005-12-05 19:42:22 +010015940 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015941 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015942
Kailang Yangdf694da2005-12-05 19:42:22 +010015943 spec->stream_analog_playback = &alc861_pcm_analog_playback;
15944 spec->stream_analog_capture = &alc861_pcm_analog_capture;
15945
Kailang Yangdf694da2005-12-05 19:42:22 +010015946 spec->stream_digital_playback = &alc861_pcm_digital_playback;
15947 spec->stream_digital_capture = &alc861_pcm_digital_capture;
15948
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010015949 if (!spec->cap_mixer)
15950 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015951 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
15952
Takashi Iwai2134ea42008-01-10 16:53:55 +010015953 spec->vmaster_nid = 0x03;
15954
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010015955 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020015956
Kailang Yangdf694da2005-12-05 19:42:22 +010015957 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050015958 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015959 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015960#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050015961 spec->power_hook = alc_power_eapd;
15962#endif
15963 }
15964#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020015965 if (!spec->loopback.amplist)
15966 spec->loopback.amplist = alc861_loopbacks;
15967#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020015968
Kailang Yangdf694da2005-12-05 19:42:22 +010015969 return 0;
15970}
15971
15972/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015973 * ALC861-VD support
15974 *
15975 * Based on ALC882
15976 *
15977 * In addition, an independent DAC
15978 */
15979#define ALC861VD_DIGOUT_NID 0x06
15980
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020015981static const hda_nid_t alc861vd_dac_nids[4] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015982 /* front, surr, clfe, side surr */
15983 0x02, 0x03, 0x04, 0x05
15984};
15985
15986/* dac_nids for ALC660vd are in a different order - according to
15987 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015988 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015989 * of ALC660vd codecs, but for now there is only 3stack mixer
15990 * - and it is the same as in 861vd.
15991 * adc_nids in ALC660vd are (is) the same as in 861vd
15992 */
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020015993static const hda_nid_t alc660vd_dac_nids[3] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015994 /* front, rear, clfe, rear_surr */
15995 0x02, 0x04, 0x03
15996};
15997
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020015998static const hda_nid_t alc861vd_adc_nids[1] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015999 /* ADC0 */
16000 0x09,
16001};
16002
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020016003static const hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010016004
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016005/* input MUX */
16006/* FIXME: should be a matrix-type input source selection */
Takashi Iwaia9111322011-05-02 11:30:18 +020016007static const struct hda_input_mux alc861vd_capture_source = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016008 .num_items = 4,
16009 .items = {
16010 { "Mic", 0x0 },
16011 { "Front Mic", 0x1 },
16012 { "Line", 0x2 },
16013 { "CD", 0x4 },
16014 },
16015};
16016
Takashi Iwaia9111322011-05-02 11:30:18 +020016017static const struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010016018 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020016019 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +010016020 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +010016021 { "Internal Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020016022 },
16023};
16024
Takashi Iwaia9111322011-05-02 11:30:18 +020016025static const struct hda_input_mux alc861vd_hp_capture_source = {
Kailang Yangd1a991a2007-08-15 16:21:59 +020016026 .num_items = 2,
16027 .items = {
16028 { "Front Mic", 0x0 },
16029 { "ATAPI Mic", 0x1 },
16030 },
16031};
16032
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016033/*
16034 * 2ch mode
16035 */
Takashi Iwaia9111322011-05-02 11:30:18 +020016036static const struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016037 { 2, NULL }
16038};
16039
16040/*
16041 * 6ch mode
16042 */
Takashi Iwaia9111322011-05-02 11:30:18 +020016043static const struct hda_verb alc861vd_6stack_ch6_init[] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016044 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16045 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16046 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16047 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16048 { } /* end */
16049};
16050
16051/*
16052 * 8ch mode
16053 */
Takashi Iwaia9111322011-05-02 11:30:18 +020016054static const struct hda_verb alc861vd_6stack_ch8_init[] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016055 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16056 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16057 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16058 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16059 { } /* end */
16060};
16061
Takashi Iwaia9111322011-05-02 11:30:18 +020016062static const struct hda_channel_mode alc861vd_6stack_modes[2] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016063 { 6, alc861vd_6stack_ch6_init },
16064 { 8, alc861vd_6stack_ch8_init },
16065};
16066
Takashi Iwaia9111322011-05-02 11:30:18 +020016067static const struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016068 {
16069 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16070 .name = "Channel Mode",
16071 .info = alc_ch_mode_info,
16072 .get = alc_ch_mode_get,
16073 .put = alc_ch_mode_put,
16074 },
16075 { } /* end */
16076};
16077
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016078/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16079 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16080 */
Takashi Iwaia9111322011-05-02 11:30:18 +020016081static const struct snd_kcontrol_new alc861vd_6st_mixer[] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016082 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16083 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16084
16085 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16086 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16087
16088 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16089 HDA_OUTPUT),
16090 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16091 HDA_OUTPUT),
16092 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16093 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16094
16095 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16096 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16097
16098 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16099
David Henningsson5f99f862011-01-04 15:24:24 +010016100 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016101 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16102 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16103
David Henningsson5f99f862011-01-04 15:24:24 +010016104 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016105 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16106 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16107
16108 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16109 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16110
16111 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16112 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16113
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016114 { } /* end */
16115};
16116
Takashi Iwaia9111322011-05-02 11:30:18 +020016117static const struct snd_kcontrol_new alc861vd_3st_mixer[] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016118 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16119 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16120
16121 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16122
David Henningsson5f99f862011-01-04 15:24:24 +010016123 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016124 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16125 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16126
David Henningsson5f99f862011-01-04 15:24:24 +010016127 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016128 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16129 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16130
16131 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16132 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16133
16134 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16135 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16136
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016137 { } /* end */
16138};
16139
Takashi Iwaia9111322011-05-02 11:30:18 +020016140static const struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016141 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16142 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16143 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16144
16145 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16146
David Henningsson5f99f862011-01-04 15:24:24 +010016147 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +020016148 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16149 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16150
David Henningsson5f99f862011-01-04 15:24:24 +010016151 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +020016152 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16153 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16154
16155 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16156 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16157
16158 { } /* end */
16159};
16160
Tobin Davisb419f342008-03-07 11:57:51 +010016161/* Pin assignment: Speaker=0x14, HP = 0x15,
David Henningsson8607f7c2010-12-20 14:43:54 +010016162 * Mic=0x18, Internal Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016163 */
Takashi Iwaia9111322011-05-02 11:30:18 +020016164static const struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016165 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16166 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016167 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16168 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010016169 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson8607f7c2010-12-20 14:43:54 +010016170 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16171 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010016172 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010016173 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16174 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016175 { } /* end */
16176};
16177
Kailang Yangd1a991a2007-08-15 16:21:59 +020016178/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16179 * Front Mic=0x18, ATAPI Mic = 0x19,
16180 */
Takashi Iwaia9111322011-05-02 11:30:18 +020016181static const struct snd_kcontrol_new alc861vd_hp_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +020016182 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16183 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16184 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16185 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16186 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16187 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16188 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16189 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016190
Kailang Yangd1a991a2007-08-15 16:21:59 +020016191 { } /* end */
16192};
16193
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016194/*
16195 * generic initialization of ADC, input mixers and output mixers
16196 */
Takashi Iwaia9111322011-05-02 11:30:18 +020016197static const struct hda_verb alc861vd_volume_init_verbs[] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016198 /*
16199 * Unmute ADC0 and set the default input to mic-in
16200 */
16201 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16202 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16203
16204 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16205 * the analog-loopback mixer widget
16206 */
16207 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016208 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16209 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16210 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16211 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16212 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016213
16214 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016215 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16216 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16217 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016218 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016219
16220 /*
16221 * Set up output mixers (0x02 - 0x05)
16222 */
16223 /* set vol=0 to output mixers */
16224 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16225 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16226 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16227 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16228
16229 /* set up input amps for analog loopback */
16230 /* Amp Indices: DAC = 0, mixer = 1 */
16231 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16232 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16233 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16234 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16235 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16236 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16237 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16238 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16239
16240 { }
16241};
16242
16243/*
16244 * 3-stack pin configuration:
16245 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16246 */
Takashi Iwaia9111322011-05-02 11:30:18 +020016247static const struct hda_verb alc861vd_3stack_init_verbs[] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016248 /*
16249 * Set pin mode and muting
16250 */
16251 /* set front pin widgets 0x14 for output */
16252 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16253 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16254 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16255
16256 /* Mic (rear) pin: input vref at 80% */
16257 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16258 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16259 /* Front Mic pin: input vref at 80% */
16260 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16261 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16262 /* Line In pin: input */
16263 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16264 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16265 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16266 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16267 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16268 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16269 /* CD pin widget for input */
16270 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16271
16272 { }
16273};
16274
16275/*
16276 * 6-stack pin configuration:
16277 */
Takashi Iwaia9111322011-05-02 11:30:18 +020016278static const struct hda_verb alc861vd_6stack_init_verbs[] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016279 /*
16280 * Set pin mode and muting
16281 */
16282 /* set front pin widgets 0x14 for output */
16283 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16284 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16285 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16286
16287 /* Rear Pin: output 1 (0x0d) */
16288 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16289 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16290 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16291 /* CLFE Pin: output 2 (0x0e) */
16292 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16293 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16294 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16295 /* Side Pin: output 3 (0x0f) */
16296 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16297 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16298 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16299
16300 /* Mic (rear) pin: input vref at 80% */
16301 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16302 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16303 /* Front Mic pin: input vref at 80% */
16304 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16305 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16306 /* Line In pin: input */
16307 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16308 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16309 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16310 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16311 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16312 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16313 /* CD pin widget for input */
16314 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16315
16316 { }
16317};
16318
Takashi Iwaia9111322011-05-02 11:30:18 +020016319static const struct hda_verb alc861vd_eapd_verbs[] = {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016320 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16321 { }
16322};
16323
Takashi Iwaia9111322011-05-02 11:30:18 +020016324static const struct hda_verb alc660vd_eapd_verbs[] = {
Kailang Yangf9423e72008-05-27 12:32:25 +020016325 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16326 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16327 { }
16328};
16329
Takashi Iwaia9111322011-05-02 11:30:18 +020016330static const struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016331 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16332 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16333 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16334 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016335 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016336 {}
16337};
16338
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016339static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016340{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016341 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016342 spec->autocfg.hp_pins[0] = 0x1b;
16343 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +020016344 spec->automute = 1;
16345 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016346}
16347
16348static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16349{
Takashi Iwaid922b512011-04-28 12:18:53 +020016350 alc_hp_automute(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +010016351 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016352}
16353
16354static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16355 unsigned int res)
16356{
16357 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016358 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +010016359 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016360 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016361 default:
Takashi Iwaid922b512011-04-28 12:18:53 +020016362 alc_sku_unsol_event(codec, res);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016363 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016364 }
16365}
16366
Takashi Iwaia9111322011-05-02 11:30:18 +020016367static const struct hda_verb alc861vd_dallas_verbs[] = {
Kailang Yang272a5272007-05-14 11:00:38 +020016368 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16369 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16370 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16371 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16372
16373 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16374 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16375 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16376 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16377 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16378 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16379 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16380 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016381
Kailang Yang272a5272007-05-14 11:00:38 +020016382 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16383 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16384 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16385 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16386 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16387 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16388 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16389 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16390
16391 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16392 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16393 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16394 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16395 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16396 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16397 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16398 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16399
16400 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16401 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16402 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16403 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16404
16405 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016406 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016407 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16408
16409 { } /* end */
16410};
16411
16412/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016413static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016414{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016415 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016416
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016417 spec->autocfg.hp_pins[0] = 0x15;
16418 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +020016419 spec->automute = 1;
16420 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yang272a5272007-05-14 11:00:38 +020016421}
16422
Takashi Iwaicb53c622007-08-10 17:21:45 +020016423#ifdef CONFIG_SND_HDA_POWER_SAVE
16424#define alc861vd_loopbacks alc880_loopbacks
16425#endif
16426
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016427/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016428#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16429#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16430#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16431#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16432
16433/*
16434 * configuration and preset
16435 */
Takashi Iwaiea734962011-01-17 11:29:34 +010016436static const char * const alc861vd_models[ALC861VD_MODEL_LAST] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016437 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016438 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016439 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016440 [ALC861VD_3ST] = "3stack",
16441 [ALC861VD_3ST_DIG] = "3stack-digout",
16442 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016443 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016444 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016445 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016446 [ALC861VD_AUTO] = "auto",
16447};
16448
Takashi Iwaia9111322011-05-02 11:30:18 +020016449static const struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016450 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16451 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016452 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016453 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016454 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016455 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016456 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016457 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016458 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016459 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016460 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016461 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016462 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016463 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016464 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016465 {}
16466};
16467
Takashi Iwaia9111322011-05-02 11:30:18 +020016468static const struct alc_config_preset alc861vd_presets[] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016469 [ALC660VD_3ST] = {
16470 .mixers = { alc861vd_3st_mixer },
16471 .init_verbs = { alc861vd_volume_init_verbs,
16472 alc861vd_3stack_init_verbs },
16473 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16474 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016475 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16476 .channel_mode = alc861vd_3stack_2ch_modes,
16477 .input_mux = &alc861vd_capture_source,
16478 },
Mike Crash6963f842007-06-25 12:12:51 +020016479 [ALC660VD_3ST_DIG] = {
16480 .mixers = { alc861vd_3st_mixer },
16481 .init_verbs = { alc861vd_volume_init_verbs,
16482 alc861vd_3stack_init_verbs },
16483 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16484 .dac_nids = alc660vd_dac_nids,
16485 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016486 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16487 .channel_mode = alc861vd_3stack_2ch_modes,
16488 .input_mux = &alc861vd_capture_source,
16489 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016490 [ALC861VD_3ST] = {
16491 .mixers = { alc861vd_3st_mixer },
16492 .init_verbs = { alc861vd_volume_init_verbs,
16493 alc861vd_3stack_init_verbs },
16494 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16495 .dac_nids = alc861vd_dac_nids,
16496 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16497 .channel_mode = alc861vd_3stack_2ch_modes,
16498 .input_mux = &alc861vd_capture_source,
16499 },
16500 [ALC861VD_3ST_DIG] = {
16501 .mixers = { alc861vd_3st_mixer },
16502 .init_verbs = { alc861vd_volume_init_verbs,
16503 alc861vd_3stack_init_verbs },
16504 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16505 .dac_nids = alc861vd_dac_nids,
16506 .dig_out_nid = ALC861VD_DIGOUT_NID,
16507 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16508 .channel_mode = alc861vd_3stack_2ch_modes,
16509 .input_mux = &alc861vd_capture_source,
16510 },
16511 [ALC861VD_6ST_DIG] = {
16512 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16513 .init_verbs = { alc861vd_volume_init_verbs,
16514 alc861vd_6stack_init_verbs },
16515 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16516 .dac_nids = alc861vd_dac_nids,
16517 .dig_out_nid = ALC861VD_DIGOUT_NID,
16518 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16519 .channel_mode = alc861vd_6stack_modes,
16520 .input_mux = &alc861vd_capture_source,
16521 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016522 [ALC861VD_LENOVO] = {
16523 .mixers = { alc861vd_lenovo_mixer },
16524 .init_verbs = { alc861vd_volume_init_verbs,
16525 alc861vd_3stack_init_verbs,
16526 alc861vd_eapd_verbs,
16527 alc861vd_lenovo_unsol_verbs },
16528 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16529 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016530 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16531 .channel_mode = alc861vd_3stack_2ch_modes,
16532 .input_mux = &alc861vd_capture_source,
16533 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016534 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016535 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016536 },
Kailang Yang272a5272007-05-14 11:00:38 +020016537 [ALC861VD_DALLAS] = {
16538 .mixers = { alc861vd_dallas_mixer },
16539 .init_verbs = { alc861vd_dallas_verbs },
16540 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16541 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016542 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16543 .channel_mode = alc861vd_3stack_2ch_modes,
16544 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020016545 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016546 .setup = alc861vd_dallas_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020016547 .init_hook = alc_hp_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016548 },
16549 [ALC861VD_HP] = {
16550 .mixers = { alc861vd_hp_mixer },
16551 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
16552 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16553 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016554 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016555 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16556 .channel_mode = alc861vd_3stack_2ch_modes,
16557 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020016558 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016559 .setup = alc861vd_dallas_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020016560 .init_hook = alc_hp_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020016561 },
Takashi Iwai13c94742008-11-05 08:06:08 +010016562 [ALC660VD_ASUS_V1S] = {
16563 .mixers = { alc861vd_lenovo_mixer },
16564 .init_verbs = { alc861vd_volume_init_verbs,
16565 alc861vd_3stack_init_verbs,
16566 alc861vd_eapd_verbs,
16567 alc861vd_lenovo_unsol_verbs },
16568 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16569 .dac_nids = alc660vd_dac_nids,
16570 .dig_out_nid = ALC861VD_DIGOUT_NID,
16571 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16572 .channel_mode = alc861vd_3stack_2ch_modes,
16573 .input_mux = &alc861vd_capture_source,
16574 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016575 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016576 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010016577 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016578};
16579
16580/*
16581 * BIOS auto configuration
16582 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016583#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
16584#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
16585
16586/* add playback controls from the parsed DAC table */
Takashi Iwai569ed342011-01-19 10:14:46 +010016587/* Based on ALC880 version. But ALC861VD has separate,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016588 * different NIDs for mute/unmute switch and volume control */
16589static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
16590 const struct auto_pin_cfg *cfg)
16591{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016592 hda_nid_t nid_v, nid_s;
Takashi Iwaice764ab2011-04-27 16:35:23 +020016593 int i, err, noutputs;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016594
Takashi Iwaice764ab2011-04-27 16:35:23 +020016595 noutputs = cfg->line_outs;
16596 if (spec->multi_ios > 0)
16597 noutputs += spec->multi_ios;
16598
16599 for (i = 0; i < noutputs; i++) {
Takashi Iwai6843ca12011-06-24 11:03:58 +020016600 const char *name;
16601 int index;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016602 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016603 continue;
16604 nid_v = alc861vd_idx_to_mixer_vol(
16605 alc880_dac_to_idx(
16606 spec->multiout.dac_nids[i]));
16607 nid_s = alc861vd_idx_to_mixer_switch(
16608 alc880_dac_to_idx(
16609 spec->multiout.dac_nids[i]));
16610
Takashi Iwai6843ca12011-06-24 11:03:58 +020016611 name = alc_get_line_out_pfx(spec, i, true, &index);
16612 if (!name) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016613 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016614 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16615 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016616 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
16617 HDA_OUTPUT));
16618 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016619 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016620 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16621 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016622 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
16623 HDA_OUTPUT));
16624 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016625 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016626 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16627 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016628 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
16629 HDA_INPUT));
16630 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016631 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016632 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16633 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016634 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
16635 HDA_INPUT));
16636 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016637 return err;
16638 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010016639 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
David Henningsson5a882642011-03-23 08:35:07 +010016640 name, index,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016641 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
16642 HDA_OUTPUT));
16643 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016644 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010016645 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
David Henningsson5a882642011-03-23 08:35:07 +010016646 name, index,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016647 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016648 HDA_INPUT));
16649 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016650 return err;
16651 }
16652 }
16653 return 0;
16654}
16655
16656/* add playback controls for speaker and HP outputs */
16657/* Based on ALC880 version. But ALC861VD has separate,
16658 * different NIDs for mute/unmute switch and volume control */
16659static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
16660 hda_nid_t pin, const char *pfx)
16661{
16662 hda_nid_t nid_v, nid_s;
16663 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016664
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016665 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016666 return 0;
16667
16668 if (alc880_is_fixed_pin(pin)) {
16669 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16670 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016671 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016672 spec->multiout.hp_nid = nid_v;
16673 else
16674 spec->multiout.extra_out_nid[0] = nid_v;
16675 /* control HP volume/switch on the output mixer amp */
16676 nid_v = alc861vd_idx_to_mixer_vol(
16677 alc880_fixed_pin_idx(pin));
16678 nid_s = alc861vd_idx_to_mixer_switch(
16679 alc880_fixed_pin_idx(pin));
16680
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016681 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016682 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
16683 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016684 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016685 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016686 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
16687 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016688 return err;
16689 } else if (alc880_is_multi_pin(pin)) {
16690 /* set manual connection */
16691 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016692 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016693 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16694 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016695 return err;
16696 }
16697 return 0;
16698}
16699
16700/* parse the BIOS configuration and set up the alc_spec
16701 * return 1 if successful, 0 if the proper config is not found,
16702 * or a negative error code
16703 * Based on ALC880 version - had to change it to override
16704 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
16705static int alc861vd_parse_auto_config(struct hda_codec *codec)
16706{
16707 struct alc_spec *spec = codec->spec;
16708 int err;
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020016709 static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016710
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016711 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16712 alc861vd_ignore);
16713 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016714 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016715 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016716 return 0; /* can't find valid BIOS pin config */
16717
Takashi Iwai343a04b2011-07-06 14:28:39 +020016718 err = alc_auto_fill_dac_nids(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016719 if (err < 0)
16720 return err;
Takashi Iwai343a04b2011-07-06 14:28:39 +020016721 err = alc_auto_add_multi_channel_mode(codec, alc_auto_fill_dac_nids);
Takashi Iwaice764ab2011-04-27 16:35:23 +020016722 if (err < 0)
16723 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016724 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
16725 if (err < 0)
16726 return err;
16727 err = alc861vd_auto_create_extra_out(spec,
16728 spec->autocfg.speaker_pins[0],
16729 "Speaker");
16730 if (err < 0)
16731 return err;
16732 err = alc861vd_auto_create_extra_out(spec,
16733 spec->autocfg.hp_pins[0],
16734 "Headphone");
16735 if (err < 0)
16736 return err;
Takashi Iwaib7821702011-07-06 15:12:46 +020016737 err = alc_auto_create_input_ctls(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016738 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016739 return err;
16740
16741 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16742
Takashi Iwai757899a2010-07-30 10:48:14 +020016743 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016744
Takashi Iwai603c4012008-07-30 15:01:44 +020016745 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016746 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016747
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016748 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016749 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016750
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +020016751 if (!spec->dual_adc_switch)
16752 alc_remove_invalid_adc_nids(codec);
16753
Takashi Iwai776e1842007-08-29 15:07:11 +020016754 err = alc_auto_add_mic_boost(codec);
16755 if (err < 0)
16756 return err;
16757
Kailang Yang6227cdc2010-02-25 08:36:52 +010016758 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016759
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016760 return 1;
16761}
16762
16763/* additional initialization for auto-configuration model */
16764static void alc861vd_auto_init(struct hda_codec *codec)
16765{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016766 struct alc_spec *spec = codec->spec;
Takashi Iwai343a04b2011-07-06 14:28:39 +020016767 alc_auto_init_multi_out(codec);
16768 alc_auto_init_extra_out(codec);
Takashi Iwai0a7f5322011-07-06 15:15:12 +020016769 alc_auto_init_analog_input(codec);
Takashi Iwaif970de22011-07-06 17:39:59 +020016770 alc_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020016771 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016772 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016773 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016774}
16775
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016776enum {
16777 ALC660VD_FIX_ASUS_GPIO1
16778};
16779
16780/* reset GPIO1 */
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016781static const struct alc_fixup alc861vd_fixups[] = {
16782 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016783 .type = ALC_FIXUP_VERBS,
16784 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020016785 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
16786 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
16787 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
16788 { }
16789 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016790 },
16791};
16792
Takashi Iwaia9111322011-05-02 11:30:18 +020016793static const struct snd_pci_quirk alc861vd_fixup_tbl[] = {
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016794 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
16795 {}
16796};
16797
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016798static int patch_alc861vd(struct hda_codec *codec)
16799{
16800 struct alc_spec *spec;
16801 int err, board_config;
16802
16803 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16804 if (spec == NULL)
16805 return -ENOMEM;
16806
16807 codec->spec = spec;
16808
Takashi Iwai1f0f4b82011-06-27 10:52:59 +020016809 spec->mixer_nid = 0x0b;
16810
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016811 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
16812 alc861vd_models,
16813 alc861vd_cfg_tbl);
16814
16815 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016816 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16817 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016818 board_config = ALC861VD_AUTO;
16819 }
16820
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016821 if (board_config == ALC861VD_AUTO) {
16822 alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
16823 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
16824 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016825
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016826 if (board_config == ALC861VD_AUTO) {
16827 /* automatic parse from the BIOS config */
16828 err = alc861vd_parse_auto_config(codec);
16829 if (err < 0) {
16830 alc_free(codec);
16831 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016832 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016833 printk(KERN_INFO
16834 "hda_codec: Cannot set up configuration "
16835 "from BIOS. Using base mode...\n");
16836 board_config = ALC861VD_3ST;
16837 }
16838 }
16839
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016840 err = snd_hda_attach_beep_device(codec, 0x23);
16841 if (err < 0) {
16842 alc_free(codec);
16843 return err;
16844 }
16845
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016846 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016847 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016848
Kailang Yang2f893282008-05-27 12:14:47 +020016849 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020016850 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010016851 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020016852 }
16853
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016854 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
16855 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
16856
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016857 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
16858 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
16859
Takashi Iwaidd704692009-08-11 08:45:11 +020016860 if (!spec->adc_nids) {
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +020016861 alc_auto_fill_adc_caps(codec);
16862 alc_remove_invalid_adc_nids(codec);
Takashi Iwaidd704692009-08-11 08:45:11 +020016863 }
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016864
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016865 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016866 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016867
Takashi Iwai2134ea42008-01-10 16:53:55 +010016868 spec->vmaster_nid = 0x02;
16869
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016870 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016871
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016872 codec->patch_ops = alc_patch_ops;
16873
16874 if (board_config == ALC861VD_AUTO)
16875 spec->init_hook = alc861vd_auto_init;
Takashi Iwai1c7161532011-04-07 10:37:16 +020016876 spec->shutup = alc_eapd_shutup;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016877#ifdef CONFIG_SND_HDA_POWER_SAVE
16878 if (!spec->loopback.amplist)
16879 spec->loopback.amplist = alc861vd_loopbacks;
16880#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016881
16882 return 0;
16883}
16884
16885/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016886 * ALC662 support
16887 *
16888 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
16889 * configuration. Each pin widget can choose any input DACs and a mixer.
16890 * Each ADC is connected from a mixer of all inputs. This makes possible
16891 * 6-channel independent captures.
16892 *
16893 * In addition, an independent DAC for the multi-playback (not used in this
16894 * driver yet).
16895 */
16896#define ALC662_DIGOUT_NID 0x06
16897#define ALC662_DIGIN_NID 0x0a
16898
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020016899static const hda_nid_t alc662_dac_nids[3] = {
Raymond Yau4bf4a6c2011-04-05 22:47:15 +080016900 /* front, rear, clfe */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016901 0x02, 0x03, 0x04
16902};
16903
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020016904static const hda_nid_t alc272_dac_nids[2] = {
Kailang Yang622e84c2009-04-21 07:39:04 +020016905 0x02, 0x03
16906};
16907
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020016908static const hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016909 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016910 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016911};
Takashi Iwaie1406342008-02-11 18:32:32 +010016912
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020016913static const hda_nid_t alc272_adc_nids[1] = {
Kailang Yang622e84c2009-04-21 07:39:04 +020016914 /* ADC1-2 */
16915 0x08,
16916};
16917
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020016918static const hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
16919static const hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020016920
Takashi Iwaie1406342008-02-11 18:32:32 +010016921
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016922/* input MUX */
16923/* FIXME: should be a matrix-type input source selection */
Takashi Iwaia9111322011-05-02 11:30:18 +020016924static const struct hda_input_mux alc662_capture_source = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016925 .num_items = 4,
16926 .items = {
16927 { "Mic", 0x0 },
16928 { "Front Mic", 0x1 },
16929 { "Line", 0x2 },
16930 { "CD", 0x4 },
16931 },
16932};
16933
Takashi Iwaia9111322011-05-02 11:30:18 +020016934static const struct hda_input_mux alc662_lenovo_101e_capture_source = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016935 .num_items = 2,
16936 .items = {
16937 { "Mic", 0x1 },
16938 { "Line", 0x2 },
16939 },
16940};
Kailang Yang291702f2007-10-16 14:28:03 +020016941
Takashi Iwaia9111322011-05-02 11:30:18 +020016942static const struct hda_input_mux alc663_capture_source = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020016943 .num_items = 3,
16944 .items = {
16945 { "Mic", 0x0 },
16946 { "Front Mic", 0x1 },
16947 { "Line", 0x2 },
16948 },
16949};
16950
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016951#if 0 /* set to 1 for testing other input sources below */
Takashi Iwaia9111322011-05-02 11:30:18 +020016952static const struct hda_input_mux alc272_nc10_capture_source = {
Chris Pockelé9541ba12009-05-12 08:08:53 +020016953 .num_items = 16,
16954 .items = {
16955 { "Autoselect Mic", 0x0 },
16956 { "Internal Mic", 0x1 },
16957 { "In-0x02", 0x2 },
16958 { "In-0x03", 0x3 },
16959 { "In-0x04", 0x4 },
16960 { "In-0x05", 0x5 },
16961 { "In-0x06", 0x6 },
16962 { "In-0x07", 0x7 },
16963 { "In-0x08", 0x8 },
16964 { "In-0x09", 0x9 },
16965 { "In-0x0a", 0x0a },
16966 { "In-0x0b", 0x0b },
16967 { "In-0x0c", 0x0c },
16968 { "In-0x0d", 0x0d },
16969 { "In-0x0e", 0x0e },
16970 { "In-0x0f", 0x0f },
16971 },
16972};
16973#endif
16974
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016975/*
16976 * 2ch mode
16977 */
Takashi Iwaia9111322011-05-02 11:30:18 +020016978static const struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016979 { 2, NULL }
16980};
16981
16982/*
16983 * 2ch mode
16984 */
Takashi Iwaia9111322011-05-02 11:30:18 +020016985static const struct hda_verb alc662_3ST_ch2_init[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016986 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
16987 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16988 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
16989 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16990 { } /* end */
16991};
16992
16993/*
16994 * 6ch mode
16995 */
Takashi Iwaia9111322011-05-02 11:30:18 +020016996static const struct hda_verb alc662_3ST_ch6_init[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016997 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16998 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16999 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17000 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17001 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17002 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17003 { } /* end */
17004};
17005
Takashi Iwaia9111322011-05-02 11:30:18 +020017006static const struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017007 { 2, alc662_3ST_ch2_init },
17008 { 6, alc662_3ST_ch6_init },
17009};
17010
17011/*
17012 * 2ch mode
17013 */
Takashi Iwaia9111322011-05-02 11:30:18 +020017014static const struct hda_verb alc662_sixstack_ch6_init[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017015 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17016 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17017 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17018 { } /* end */
17019};
17020
17021/*
17022 * 6ch mode
17023 */
Takashi Iwaia9111322011-05-02 11:30:18 +020017024static const struct hda_verb alc662_sixstack_ch8_init[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017025 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17026 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17027 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17028 { } /* end */
17029};
17030
Takashi Iwaia9111322011-05-02 11:30:18 +020017031static const struct hda_channel_mode alc662_5stack_modes[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017032 { 2, alc662_sixstack_ch6_init },
17033 { 6, alc662_sixstack_ch8_init },
17034};
17035
17036/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17037 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17038 */
17039
Takashi Iwaia9111322011-05-02 11:30:18 +020017040static const struct snd_kcontrol_new alc662_base_mixer[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017041 /* output mixer control */
17042 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017043 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017044 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017045 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017046 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17047 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017048 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17049 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017050 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17051
17052 /*Input mixer control */
17053 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17054 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17055 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17056 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17057 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17058 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17059 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17060 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017061 { } /* end */
17062};
17063
Takashi Iwaia9111322011-05-02 11:30:18 +020017064static const struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017065 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017066 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017067 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17068 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17069 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17070 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17071 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17072 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17073 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17074 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17075 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017076 { } /* end */
17077};
17078
Takashi Iwaia9111322011-05-02 11:30:18 +020017079static const struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017080 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017081 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017082 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017083 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017084 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17085 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017086 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17087 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017088 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17089 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17090 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17091 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17092 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17093 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17094 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17095 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17096 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017097 { } /* end */
17098};
17099
Takashi Iwaia9111322011-05-02 11:30:18 +020017100static const struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017101 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17102 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017103 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17104 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017105 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17106 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17107 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17108 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17109 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017110 { } /* end */
17111};
17112
Takashi Iwaia9111322011-05-02 11:30:18 +020017113static const struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017114 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17115 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017116
David Henningsson5f99f862011-01-04 15:24:24 +010017117 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017118 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17119 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020017120
David Henningsson5f99f862011-01-04 15:24:24 +010017121 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017122 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17123 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020017124 { } /* end */
17125};
17126
Takashi Iwaia9111322011-05-02 11:30:18 +020017127static const struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017128 ALC262_HIPPO_MASTER_SWITCH,
17129 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017130 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017131 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17132 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017133 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17134 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17135 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17136 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17137 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17138 { } /* end */
17139};
17140
Takashi Iwaia9111322011-05-02 11:30:18 +020017141static const struct hda_bind_ctls alc663_asus_bind_master_vol = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017142 .ops = &snd_hda_bind_vol,
17143 .values = {
17144 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17145 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17146 0
17147 },
17148};
17149
Takashi Iwaia9111322011-05-02 11:30:18 +020017150static const struct hda_bind_ctls alc663_asus_one_bind_switch = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017151 .ops = &snd_hda_bind_sw,
17152 .values = {
17153 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17154 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17155 0
17156 },
17157};
17158
Takashi Iwaia9111322011-05-02 11:30:18 +020017159static const struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017160 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17161 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17162 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17163 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17164 { } /* end */
17165};
17166
Takashi Iwaia9111322011-05-02 11:30:18 +020017167static const struct hda_bind_ctls alc663_asus_tree_bind_switch = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017168 .ops = &snd_hda_bind_sw,
17169 .values = {
17170 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17171 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17172 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17173 0
17174 },
17175};
17176
Takashi Iwaia9111322011-05-02 11:30:18 +020017177static const struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017178 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17179 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17180 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17181 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17182 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17183 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17184
17185 { } /* end */
17186};
17187
Takashi Iwaia9111322011-05-02 11:30:18 +020017188static const struct hda_bind_ctls alc663_asus_four_bind_switch = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017189 .ops = &snd_hda_bind_sw,
17190 .values = {
17191 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17192 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17193 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17194 0
17195 },
17196};
17197
Takashi Iwaia9111322011-05-02 11:30:18 +020017198static const struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017199 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17200 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17201 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17202 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17203 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17204 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17205 { } /* end */
17206};
17207
Takashi Iwaia9111322011-05-02 11:30:18 +020017208static const struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017209 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17210 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017211 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17212 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17213 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17214 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17215 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17216 { } /* end */
17217};
17218
Takashi Iwaia9111322011-05-02 11:30:18 +020017219static const struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017220 .ops = &snd_hda_bind_vol,
17221 .values = {
17222 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17223 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17224 0
17225 },
17226};
17227
Takashi Iwaia9111322011-05-02 11:30:18 +020017228static const struct hda_bind_ctls alc663_asus_two_bind_switch = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017229 .ops = &snd_hda_bind_sw,
17230 .values = {
17231 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17232 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17233 0
17234 },
17235};
17236
Takashi Iwaia9111322011-05-02 11:30:18 +020017237static const struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017238 HDA_BIND_VOL("Master Playback Volume",
17239 &alc663_asus_two_bind_master_vol),
17240 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17241 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017242 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17243 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17244 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017245 { } /* end */
17246};
17247
Takashi Iwaia9111322011-05-02 11:30:18 +020017248static const struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017249 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17250 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17251 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17252 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17253 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17254 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017255 { } /* end */
17256};
17257
Takashi Iwaia9111322011-05-02 11:30:18 +020017258static const struct snd_kcontrol_new alc663_g71v_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017259 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17260 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17261 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17262 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17263 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17264
17265 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17266 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017267 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17268 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017269 { } /* end */
17270};
17271
Takashi Iwaia9111322011-05-02 11:30:18 +020017272static const struct snd_kcontrol_new alc663_g50v_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017273 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17274 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17275 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17276
17277 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17278 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017279 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17280 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017281 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17282 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17283 { } /* end */
17284};
17285
Takashi Iwaia9111322011-05-02 11:30:18 +020017286static const struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
Kailang Yangebb83ee2009-12-17 12:23:00 +010017287 .ops = &snd_hda_bind_sw,
17288 .values = {
17289 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17290 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17291 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17292 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17293 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17294 0
17295 },
17296};
17297
Takashi Iwaia9111322011-05-02 11:30:18 +020017298static const struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
Kailang Yangebb83ee2009-12-17 12:23:00 +010017299 .ops = &snd_hda_bind_sw,
17300 .values = {
17301 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17302 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17303 0
17304 },
17305};
17306
Takashi Iwaia9111322011-05-02 11:30:18 +020017307static const struct snd_kcontrol_new alc663_mode7_mixer[] = {
Kailang Yangebb83ee2009-12-17 12:23:00 +010017308 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17309 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17310 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17311 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17312 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17313 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17314 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17315 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17316 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17317 { } /* end */
17318};
17319
Takashi Iwaia9111322011-05-02 11:30:18 +020017320static const struct snd_kcontrol_new alc663_mode8_mixer[] = {
Kailang Yangebb83ee2009-12-17 12:23:00 +010017321 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17322 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17323 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17324 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17325 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17326 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17327 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17328 { } /* end */
17329};
17330
17331
Takashi Iwaia9111322011-05-02 11:30:18 +020017332static const struct snd_kcontrol_new alc662_chmode_mixer[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017333 {
17334 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17335 .name = "Channel Mode",
17336 .info = alc_ch_mode_info,
17337 .get = alc_ch_mode_get,
17338 .put = alc_ch_mode_put,
17339 },
17340 { } /* end */
17341};
17342
Takashi Iwaia9111322011-05-02 11:30:18 +020017343static const struct hda_verb alc662_init_verbs[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017344 /* ADC: mute amp left and right */
17345 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17346 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017347
Kailang Yangb60dd392007-09-20 12:50:29 +020017348 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17349 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17350 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17351 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17352 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17353 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017354
17355 /* Front Pin: output 0 (0x0c) */
17356 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17357 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17358
17359 /* Rear Pin: output 1 (0x0d) */
17360 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17361 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17362
17363 /* CLFE Pin: output 2 (0x0e) */
17364 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17365 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17366
17367 /* Mic (rear) pin: input vref at 80% */
17368 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17369 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17370 /* Front Mic pin: input vref at 80% */
17371 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17372 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17373 /* Line In pin: input */
17374 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17375 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17376 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17377 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17378 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17379 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17380 /* CD pin widget for input */
17381 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17382
17383 /* FIXME: use matrix-type input source selection */
17384 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17385 /* Input mixer */
17386 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017387 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017388
Takashi Iwaia7f23712011-04-07 10:24:23 +020017389 { }
17390};
17391
Takashi Iwaia9111322011-05-02 11:30:18 +020017392static const struct hda_verb alc662_eapd_init_verbs[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017393 /* always trun on EAPD */
17394 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17395 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017396 { }
17397};
17398
Takashi Iwaia9111322011-05-02 11:30:18 +020017399static const struct hda_verb alc662_sue_init_verbs[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017400 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17401 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017402 {}
17403};
17404
Takashi Iwaia9111322011-05-02 11:30:18 +020017405static const struct hda_verb alc662_eeepc_sue_init_verbs[] = {
Kailang Yang291702f2007-10-16 14:28:03 +020017406 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17407 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17408 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017409};
17410
Kailang Yang8c427222008-01-10 13:03:59 +010017411/* Set Unsolicited Event*/
Takashi Iwaia9111322011-05-02 11:30:18 +020017412static const struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
Kailang Yang8c427222008-01-10 13:03:59 +010017413 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17414 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17415 {}
17416};
17417
Takashi Iwaia9111322011-05-02 11:30:18 +020017418static const struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017419 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17420 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017421 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17422 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017423 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17424 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17425 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017426 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17427 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17428 {}
17429};
17430
Takashi Iwaia9111322011-05-02 11:30:18 +020017431static const struct hda_verb alc663_21jd_amic_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017432 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17433 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17434 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17435 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17436 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17437 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17438 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17439 {}
17440};
17441
Takashi Iwaia9111322011-05-02 11:30:18 +020017442static const struct hda_verb alc662_1bjd_amic_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017443 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17444 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17445 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17446 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17447 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17448 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17449 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17450 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17451 {}
17452};
17453
Takashi Iwaia9111322011-05-02 11:30:18 +020017454static const struct hda_verb alc663_15jd_amic_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017455 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17456 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17457 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17458 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17459 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17460 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17461 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17462 {}
17463};
17464
Takashi Iwaia9111322011-05-02 11:30:18 +020017465static const struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017466 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17467 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17468 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17469 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17470 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17471 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17472 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17473 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17474 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17475 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17476 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17477 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17478 {}
17479};
17480
Takashi Iwaia9111322011-05-02 11:30:18 +020017481static const struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017482 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17483 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17484 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17485 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17486 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17487 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17488 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17489 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17490 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17491 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17492 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17493 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17494 {}
17495};
17496
Takashi Iwaia9111322011-05-02 11:30:18 +020017497static const struct hda_verb alc663_g71v_init_verbs[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017498 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17499 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
17500 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
17501
17502 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17503 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17504 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17505
17506 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17507 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
17508 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
17509 {}
17510};
17511
Takashi Iwaia9111322011-05-02 11:30:18 +020017512static const struct hda_verb alc663_g50v_init_verbs[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017513 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17514 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17515 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17516
17517 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17518 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17519 {}
17520};
17521
Takashi Iwaia9111322011-05-02 11:30:18 +020017522static const struct hda_verb alc662_ecs_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017523 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
17524 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17525 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17526 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17527 {}
17528};
17529
Takashi Iwaia9111322011-05-02 11:30:18 +020017530static const struct hda_verb alc272_dell_zm1_init_verbs[] = {
Kailang Yang622e84c2009-04-21 07:39:04 +020017531 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17532 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17533 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17534 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17535 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17536 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17537 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17538 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17539 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17540 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17541 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17542 {}
17543};
17544
Takashi Iwaia9111322011-05-02 11:30:18 +020017545static const struct hda_verb alc272_dell_init_verbs[] = {
Kailang Yang622e84c2009-04-21 07:39:04 +020017546 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17547 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17548 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17549 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17550 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17551 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17552 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17553 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17554 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17555 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17556 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17557 {}
17558};
17559
Takashi Iwaia9111322011-05-02 11:30:18 +020017560static const struct hda_verb alc663_mode7_init_verbs[] = {
Kailang Yangebb83ee2009-12-17 12:23:00 +010017561 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17562 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17563 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17564 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17565 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17566 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17567 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
17568 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17569 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17570 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17571 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17572 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17573 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17574 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17575 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17576 {}
17577};
17578
Takashi Iwaia9111322011-05-02 11:30:18 +020017579static const struct hda_verb alc663_mode8_init_verbs[] = {
Kailang Yangebb83ee2009-12-17 12:23:00 +010017580 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17581 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17582 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17583 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
17584 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17585 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17586 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17587 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17588 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17589 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17590 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17591 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17592 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17593 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17594 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17595 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17596 {}
17597};
17598
Takashi Iwaia9111322011-05-02 11:30:18 +020017599static const struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017600 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
17601 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
17602 { } /* end */
17603};
17604
Takashi Iwaia9111322011-05-02 11:30:18 +020017605static const struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
Kailang Yang622e84c2009-04-21 07:39:04 +020017606 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
17607 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
17608 { } /* end */
17609};
17610
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020017611static void alc662_lenovo_101e_setup(struct hda_codec *codec)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017612{
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020017613 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017614
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020017615 spec->autocfg.hp_pins[0] = 0x1b;
17616 spec->autocfg.line_out_pins[0] = 0x14;
17617 spec->autocfg.speaker_pins[0] = 0x15;
17618 spec->automute = 1;
17619 spec->detect_line = 1;
17620 spec->automute_lines = 1;
17621 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017622}
17623
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017624static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020017625{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017626 struct alc_spec *spec = codec->spec;
17627
17628 alc262_hippo1_setup(codec);
17629 spec->ext_mic.pin = 0x18;
17630 spec->ext_mic.mux_idx = 0;
17631 spec->int_mic.pin = 0x19;
17632 spec->int_mic.mux_idx = 1;
17633 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020017634}
17635
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017636static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010017637{
Takashi Iwai42171c12009-05-08 14:11:43 +020017638 struct alc_spec *spec = codec->spec;
17639
17640 spec->autocfg.hp_pins[0] = 0x14;
17641 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaie9427962011-04-28 15:46:07 +020017642 spec->automute = 1;
17643 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yang8c427222008-01-10 13:03:59 +010017644}
17645
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017646static void alc663_m51va_setup(struct hda_codec *codec)
17647{
17648 struct alc_spec *spec = codec->spec;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020017649 spec->autocfg.hp_pins[0] = 0x21;
17650 spec->autocfg.speaker_pins[0] = 0x14;
17651 spec->automute_mixer_nid[0] = 0x0c;
17652 spec->automute = 1;
17653 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017654 spec->ext_mic.pin = 0x18;
17655 spec->ext_mic.mux_idx = 0;
17656 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010017657 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017658 spec->auto_mic = 1;
17659}
17660
Kailang Yangf1d4e282008-08-26 14:03:29 +020017661/* ***************** Mode1 ******************************/
Kailang Yangebb83ee2009-12-17 12:23:00 +010017662static void alc663_mode1_setup(struct hda_codec *codec)
17663{
17664 struct alc_spec *spec = codec->spec;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020017665 spec->autocfg.hp_pins[0] = 0x21;
17666 spec->autocfg.speaker_pins[0] = 0x14;
17667 spec->automute_mixer_nid[0] = 0x0c;
17668 spec->automute = 1;
17669 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Kailang Yangebb83ee2009-12-17 12:23:00 +010017670 spec->ext_mic.pin = 0x18;
17671 spec->ext_mic.mux_idx = 0;
17672 spec->int_mic.pin = 0x19;
17673 spec->int_mic.mux_idx = 1;
17674 spec->auto_mic = 1;
17675}
17676
Kailang Yangf1d4e282008-08-26 14:03:29 +020017677/* ***************** Mode2 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020017678static void alc662_mode2_setup(struct hda_codec *codec)
Kailang Yangf1d4e282008-08-26 14:03:29 +020017679{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020017680 struct alc_spec *spec = codec->spec;
17681 spec->autocfg.hp_pins[0] = 0x1b;
17682 spec->autocfg.speaker_pins[0] = 0x14;
17683 spec->automute = 1;
17684 spec->automute_mode = ALC_AUTOMUTE_PIN;
17685 spec->ext_mic.pin = 0x18;
17686 spec->ext_mic.mux_idx = 0;
17687 spec->int_mic.pin = 0x19;
17688 spec->int_mic.mux_idx = 1;
17689 spec->auto_mic = 1;
Kailang Yangf1d4e282008-08-26 14:03:29 +020017690}
17691
Kailang Yangf1d4e282008-08-26 14:03:29 +020017692/* ***************** Mode3 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020017693static void alc663_mode3_setup(struct hda_codec *codec)
Kailang Yangf1d4e282008-08-26 14:03:29 +020017694{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020017695 struct alc_spec *spec = codec->spec;
17696 spec->autocfg.hp_pins[0] = 0x21;
17697 spec->autocfg.hp_pins[0] = 0x15;
17698 spec->autocfg.speaker_pins[0] = 0x14;
17699 spec->automute = 1;
17700 spec->automute_mode = ALC_AUTOMUTE_PIN;
17701 spec->ext_mic.pin = 0x18;
17702 spec->ext_mic.mux_idx = 0;
17703 spec->int_mic.pin = 0x19;
17704 spec->int_mic.mux_idx = 1;
17705 spec->auto_mic = 1;
Kailang Yangf1d4e282008-08-26 14:03:29 +020017706}
17707
Kailang Yangf1d4e282008-08-26 14:03:29 +020017708/* ***************** Mode4 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020017709static void alc663_mode4_setup(struct hda_codec *codec)
Kailang Yangf1d4e282008-08-26 14:03:29 +020017710{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020017711 struct alc_spec *spec = codec->spec;
17712 spec->autocfg.hp_pins[0] = 0x21;
17713 spec->autocfg.speaker_pins[0] = 0x14;
17714 spec->autocfg.speaker_pins[1] = 0x16;
17715 spec->automute_mixer_nid[0] = 0x0c;
17716 spec->automute_mixer_nid[1] = 0x0e;
17717 spec->automute = 1;
17718 spec->automute_mode = ALC_AUTOMUTE_MIXER;
17719 spec->ext_mic.pin = 0x18;
17720 spec->ext_mic.mux_idx = 0;
17721 spec->int_mic.pin = 0x19;
17722 spec->int_mic.mux_idx = 1;
17723 spec->auto_mic = 1;
Kailang Yangf1d4e282008-08-26 14:03:29 +020017724}
17725
Kailang Yangf1d4e282008-08-26 14:03:29 +020017726/* ***************** Mode5 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020017727static void alc663_mode5_setup(struct hda_codec *codec)
Kailang Yangf1d4e282008-08-26 14:03:29 +020017728{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020017729 struct alc_spec *spec = codec->spec;
17730 spec->autocfg.hp_pins[0] = 0x15;
17731 spec->autocfg.speaker_pins[0] = 0x14;
17732 spec->autocfg.speaker_pins[1] = 0x16;
17733 spec->automute_mixer_nid[0] = 0x0c;
17734 spec->automute_mixer_nid[1] = 0x0e;
17735 spec->automute = 1;
17736 spec->automute_mode = ALC_AUTOMUTE_MIXER;
17737 spec->ext_mic.pin = 0x18;
17738 spec->ext_mic.mux_idx = 0;
17739 spec->int_mic.pin = 0x19;
17740 spec->int_mic.mux_idx = 1;
17741 spec->auto_mic = 1;
Kailang Yangf1d4e282008-08-26 14:03:29 +020017742}
17743
Kailang Yangf1d4e282008-08-26 14:03:29 +020017744/* ***************** Mode6 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020017745static void alc663_mode6_setup(struct hda_codec *codec)
Kailang Yangf1d4e282008-08-26 14:03:29 +020017746{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020017747 struct alc_spec *spec = codec->spec;
17748 spec->autocfg.hp_pins[0] = 0x1b;
17749 spec->autocfg.hp_pins[0] = 0x15;
17750 spec->autocfg.speaker_pins[0] = 0x14;
17751 spec->automute_mixer_nid[0] = 0x0c;
17752 spec->automute = 1;
17753 spec->automute_mode = ALC_AUTOMUTE_MIXER;
17754 spec->ext_mic.pin = 0x18;
17755 spec->ext_mic.mux_idx = 0;
17756 spec->int_mic.pin = 0x19;
17757 spec->int_mic.mux_idx = 1;
17758 spec->auto_mic = 1;
Kailang Yangf1d4e282008-08-26 14:03:29 +020017759}
17760
Kailang Yangebb83ee2009-12-17 12:23:00 +010017761/* ***************** Mode7 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020017762static void alc663_mode7_setup(struct hda_codec *codec)
Kailang Yangebb83ee2009-12-17 12:23:00 +010017763{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020017764 struct alc_spec *spec = codec->spec;
17765 spec->autocfg.hp_pins[0] = 0x1b;
17766 spec->autocfg.hp_pins[0] = 0x21;
17767 spec->autocfg.speaker_pins[0] = 0x14;
17768 spec->autocfg.speaker_pins[0] = 0x17;
17769 spec->automute = 1;
17770 spec->automute_mode = ALC_AUTOMUTE_PIN;
17771 spec->ext_mic.pin = 0x18;
17772 spec->ext_mic.mux_idx = 0;
17773 spec->int_mic.pin = 0x19;
17774 spec->int_mic.mux_idx = 1;
17775 spec->auto_mic = 1;
Kailang Yangebb83ee2009-12-17 12:23:00 +010017776}
17777
17778/* ***************** Mode8 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020017779static void alc663_mode8_setup(struct hda_codec *codec)
Kailang Yangebb83ee2009-12-17 12:23:00 +010017780{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020017781 struct alc_spec *spec = codec->spec;
17782 spec->autocfg.hp_pins[0] = 0x21;
17783 spec->autocfg.hp_pins[1] = 0x15;
17784 spec->autocfg.speaker_pins[0] = 0x14;
17785 spec->autocfg.speaker_pins[0] = 0x17;
17786 spec->automute = 1;
17787 spec->automute_mode = ALC_AUTOMUTE_PIN;
17788 spec->ext_mic.pin = 0x18;
17789 spec->ext_mic.mux_idx = 0;
17790 spec->int_mic.pin = 0x12;
17791 spec->int_mic.mux_idx = 9;
17792 spec->auto_mic = 1;
Kailang Yangebb83ee2009-12-17 12:23:00 +010017793}
17794
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020017795static void alc663_g71v_setup(struct hda_codec *codec)
Kailang Yang6dda9f42008-05-27 12:05:31 +020017796{
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020017797 struct alc_spec *spec = codec->spec;
17798 spec->autocfg.hp_pins[0] = 0x21;
17799 spec->autocfg.line_out_pins[0] = 0x15;
17800 spec->autocfg.speaker_pins[0] = 0x14;
17801 spec->automute = 1;
17802 spec->automute_mode = ALC_AUTOMUTE_AMP;
17803 spec->detect_line = 1;
17804 spec->automute_lines = 1;
17805 spec->ext_mic.pin = 0x18;
17806 spec->ext_mic.mux_idx = 0;
17807 spec->int_mic.pin = 0x12;
17808 spec->int_mic.mux_idx = 9;
17809 spec->auto_mic = 1;
Kailang Yang6dda9f42008-05-27 12:05:31 +020017810}
17811
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017812#define alc663_g50v_setup alc663_m51va_setup
17813
Takashi Iwaia9111322011-05-02 11:30:18 +020017814static const struct snd_kcontrol_new alc662_ecs_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017815 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020017816 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017817
David Henningsson5f99f862011-01-04 15:24:24 +010017818 HDA_CODEC_VOLUME("Mic/LineIn Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017819 HDA_CODEC_VOLUME("Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
17820 HDA_CODEC_MUTE("Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017821
David Henningsson5f99f862011-01-04 15:24:24 +010017822 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017823 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17824 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017825 { } /* end */
17826};
17827
Takashi Iwaia9111322011-05-02 11:30:18 +020017828static const struct snd_kcontrol_new alc272_nc10_mixer[] = {
Chris Pockelé9541ba12009-05-12 08:08:53 +020017829 /* Master Playback automatically created from Speaker and Headphone */
17830 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17831 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17832 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17833 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17834
David Henningsson8607f7c2010-12-20 14:43:54 +010017835 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17836 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010017837 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Chris Pockelé9541ba12009-05-12 08:08:53 +020017838
David Henningsson28c4edb2010-12-20 14:24:29 +010017839 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17840 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010017841 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Chris Pockelé9541ba12009-05-12 08:08:53 +020017842 { } /* end */
17843};
17844
Takashi Iwaicb53c622007-08-10 17:21:45 +020017845#ifdef CONFIG_SND_HDA_POWER_SAVE
17846#define alc662_loopbacks alc880_loopbacks
17847#endif
17848
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017849
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017850/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017851#define alc662_pcm_analog_playback alc880_pcm_analog_playback
17852#define alc662_pcm_analog_capture alc880_pcm_analog_capture
17853#define alc662_pcm_digital_playback alc880_pcm_digital_playback
17854#define alc662_pcm_digital_capture alc880_pcm_digital_capture
17855
17856/*
17857 * configuration and preset
17858 */
Takashi Iwaiea734962011-01-17 11:29:34 +010017859static const char * const alc662_models[ALC662_MODEL_LAST] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017860 [ALC662_3ST_2ch_DIG] = "3stack-dig",
17861 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
17862 [ALC662_3ST_6ch] = "3stack-6ch",
Raymond Yau4bf4a6c2011-04-05 22:47:15 +080017863 [ALC662_5ST_DIG] = "5stack-dig",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017864 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020017865 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010017866 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017867 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020017868 [ALC663_ASUS_M51VA] = "m51va",
17869 [ALC663_ASUS_G71V] = "g71v",
17870 [ALC663_ASUS_H13] = "h13",
17871 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017872 [ALC663_ASUS_MODE1] = "asus-mode1",
17873 [ALC662_ASUS_MODE2] = "asus-mode2",
17874 [ALC663_ASUS_MODE3] = "asus-mode3",
17875 [ALC663_ASUS_MODE4] = "asus-mode4",
17876 [ALC663_ASUS_MODE5] = "asus-mode5",
17877 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010017878 [ALC663_ASUS_MODE7] = "asus-mode7",
17879 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020017880 [ALC272_DELL] = "dell",
17881 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020017882 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017883 [ALC662_AUTO] = "auto",
17884};
17885
Takashi Iwaia9111322011-05-02 11:30:18 +020017886static const struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010017887 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020017888 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
17889 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017890 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
17891 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010017892 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017893 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
17894 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
17895 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
17896 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017897 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
17898 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017899 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017900 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
17901 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
17902 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
17903 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
17904 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017905 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017906 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
17907 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017908 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
17909 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
17910 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
17911 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017912 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017913 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
17914 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
17915 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017916 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
17917 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
17918 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
17919 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017920 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017921 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
17922 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017923 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017924 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
17925 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
17926 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017927 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010017928 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017929 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
17930 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017931 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
17932 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
17933 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017934 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017935 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
17936 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017937 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017938 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020017939 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017940 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
17941 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
17942 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017943 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017944 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
17945 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010017946 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020017947 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010017948 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017949 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030017950 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
17951 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010017952 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020017953 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Takashi Iwaiebb47242011-05-02 10:37:29 +020017954 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
17955 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010017956 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020017957 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020017958 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017959 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020017960 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020017961 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017962 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
17963 ALC663_ASUS_H13),
Anisse Astier965b76d2011-02-10 13:14:44 +010017964 SND_PCI_QUIRK(0x1991, 0x5628, "Ordissimo EVE", ALC662_LENOVO_101E),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017965 {}
17966};
17967
Takashi Iwaia9111322011-05-02 11:30:18 +020017968static const struct alc_config_preset alc662_presets[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017969 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017970 .mixers = { alc662_3ST_2ch_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020017971 .init_verbs = { alc662_init_verbs, alc662_eapd_init_verbs },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017972 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17973 .dac_nids = alc662_dac_nids,
17974 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017975 .dig_in_nid = ALC662_DIGIN_NID,
17976 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17977 .channel_mode = alc662_3ST_2ch_modes,
17978 .input_mux = &alc662_capture_source,
17979 },
17980 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017981 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020017982 .init_verbs = { alc662_init_verbs, alc662_eapd_init_verbs },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017983 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17984 .dac_nids = alc662_dac_nids,
17985 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017986 .dig_in_nid = ALC662_DIGIN_NID,
17987 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17988 .channel_mode = alc662_3ST_6ch_modes,
17989 .need_dac_fix = 1,
17990 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017991 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017992 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017993 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020017994 .init_verbs = { alc662_init_verbs, alc662_eapd_init_verbs },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017995 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17996 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017997 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17998 .channel_mode = alc662_3ST_6ch_modes,
17999 .need_dac_fix = 1,
18000 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018001 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018002 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018003 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018004 .init_verbs = { alc662_init_verbs, alc662_eapd_init_verbs },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018005 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18006 .dac_nids = alc662_dac_nids,
18007 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018008 .dig_in_nid = ALC662_DIGIN_NID,
18009 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18010 .channel_mode = alc662_5stack_modes,
18011 .input_mux = &alc662_capture_source,
18012 },
18013 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018014 .mixers = { alc662_lenovo_101e_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018015 .init_verbs = { alc662_init_verbs,
18016 alc662_eapd_init_verbs,
18017 alc662_sue_init_verbs },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018018 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18019 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018020 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18021 .channel_mode = alc662_3ST_2ch_modes,
18022 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020018023 .unsol_event = alc_sku_unsol_event,
18024 .setup = alc662_lenovo_101e_setup,
18025 .init_hook = alc_inithook,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018026 },
Kailang Yang291702f2007-10-16 14:28:03 +020018027 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018028 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018029 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018030 alc662_eapd_init_verbs,
Kailang Yang291702f2007-10-16 14:28:03 +020018031 alc662_eeepc_sue_init_verbs },
18032 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18033 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018034 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18035 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwaie9427962011-04-28 15:46:07 +020018036 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018037 .setup = alc662_eeepc_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020018038 .init_hook = alc_inithook,
Kailang Yang291702f2007-10-16 14:28:03 +020018039 },
Kailang Yang8c427222008-01-10 13:03:59 +010018040 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018041 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018042 alc662_chmode_mixer },
18043 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018044 alc662_eapd_init_verbs,
Kailang Yang8c427222008-01-10 13:03:59 +010018045 alc662_eeepc_ep20_sue_init_verbs },
18046 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18047 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018048 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18049 .channel_mode = alc662_3ST_6ch_modes,
18050 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020018051 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018052 .setup = alc662_eeepc_ep20_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020018053 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010018054 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018055 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018056 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018057 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018058 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018059 alc662_ecs_init_verbs },
18060 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18061 .dac_nids = alc662_dac_nids,
18062 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18063 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwaie9427962011-04-28 15:46:07 +020018064 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018065 .setup = alc662_eeepc_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020018066 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018067 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018068 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018069 .mixers = { alc663_m51va_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018070 .init_verbs = { alc662_init_verbs,
18071 alc662_eapd_init_verbs,
18072 alc663_m51va_init_verbs },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018073 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18074 .dac_nids = alc662_dac_nids,
18075 .dig_out_nid = ALC662_DIGOUT_NID,
18076 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18077 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018078 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018079 .setup = alc663_m51va_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018080 .init_hook = alc_inithook,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018081 },
18082 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018083 .mixers = { alc663_g71v_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018084 .init_verbs = { alc662_init_verbs,
18085 alc662_eapd_init_verbs,
18086 alc663_g71v_init_verbs },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018087 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18088 .dac_nids = alc662_dac_nids,
18089 .dig_out_nid = ALC662_DIGOUT_NID,
18090 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18091 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020018092 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018093 .setup = alc663_g71v_setup,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020018094 .init_hook = alc_inithook,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018095 },
18096 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018097 .mixers = { alc663_m51va_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018098 .init_verbs = { alc662_init_verbs,
18099 alc662_eapd_init_verbs,
18100 alc663_m51va_init_verbs },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018101 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18102 .dac_nids = alc662_dac_nids,
18103 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18104 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018105 .setup = alc663_m51va_setup,
18106 .unsol_event = alc_sku_unsol_event,
18107 .init_hook = alc_inithook,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018108 },
18109 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018110 .mixers = { alc663_g50v_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018111 .init_verbs = { alc662_init_verbs,
18112 alc662_eapd_init_verbs,
18113 alc663_g50v_init_verbs },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018114 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18115 .dac_nids = alc662_dac_nids,
18116 .dig_out_nid = ALC662_DIGOUT_NID,
18117 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18118 .channel_mode = alc662_3ST_6ch_modes,
18119 .input_mux = &alc663_capture_source,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018120 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018121 .setup = alc663_g50v_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018122 .init_hook = alc_inithook,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018123 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018124 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018125 .mixers = { alc663_m51va_mixer },
18126 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018127 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018128 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018129 alc663_21jd_amic_init_verbs },
18130 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18131 .hp_nid = 0x03,
18132 .dac_nids = alc662_dac_nids,
18133 .dig_out_nid = ALC662_DIGOUT_NID,
18134 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18135 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018136 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018137 .setup = alc663_mode1_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018138 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018139 },
18140 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018141 .mixers = { alc662_1bjd_mixer },
18142 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018143 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018144 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018145 alc662_1bjd_amic_init_verbs },
18146 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18147 .dac_nids = alc662_dac_nids,
18148 .dig_out_nid = ALC662_DIGOUT_NID,
18149 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18150 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018151 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018152 .setup = alc662_mode2_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018153 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018154 },
18155 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018156 .mixers = { alc663_two_hp_m1_mixer },
18157 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018158 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018159 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018160 alc663_two_hp_amic_m1_init_verbs },
18161 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18162 .hp_nid = 0x03,
18163 .dac_nids = alc662_dac_nids,
18164 .dig_out_nid = ALC662_DIGOUT_NID,
18165 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18166 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018167 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018168 .setup = alc663_mode3_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018169 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018170 },
18171 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018172 .mixers = { alc663_asus_21jd_clfe_mixer },
18173 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018174 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018175 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018176 alc663_21jd_amic_init_verbs},
18177 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18178 .hp_nid = 0x03,
18179 .dac_nids = alc662_dac_nids,
18180 .dig_out_nid = ALC662_DIGOUT_NID,
18181 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18182 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018183 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018184 .setup = alc663_mode4_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018185 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018186 },
18187 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018188 .mixers = { alc663_asus_15jd_clfe_mixer },
18189 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018190 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018191 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018192 alc663_15jd_amic_init_verbs },
18193 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18194 .hp_nid = 0x03,
18195 .dac_nids = alc662_dac_nids,
18196 .dig_out_nid = ALC662_DIGOUT_NID,
18197 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18198 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018199 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018200 .setup = alc663_mode5_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018201 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018202 },
18203 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018204 .mixers = { alc663_two_hp_m2_mixer },
18205 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018206 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018207 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018208 alc663_two_hp_amic_m2_init_verbs },
18209 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18210 .hp_nid = 0x03,
18211 .dac_nids = alc662_dac_nids,
18212 .dig_out_nid = ALC662_DIGOUT_NID,
18213 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18214 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018215 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018216 .setup = alc663_mode6_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018217 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018218 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018219 [ALC663_ASUS_MODE7] = {
18220 .mixers = { alc663_mode7_mixer },
18221 .cap_mixer = alc662_auto_capture_mixer,
18222 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018223 alc662_eapd_init_verbs,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018224 alc663_mode7_init_verbs },
18225 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18226 .hp_nid = 0x03,
18227 .dac_nids = alc662_dac_nids,
18228 .dig_out_nid = ALC662_DIGOUT_NID,
18229 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18230 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018231 .unsol_event = alc_sku_unsol_event,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018232 .setup = alc663_mode7_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018233 .init_hook = alc_inithook,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018234 },
18235 [ALC663_ASUS_MODE8] = {
18236 .mixers = { alc663_mode8_mixer },
18237 .cap_mixer = alc662_auto_capture_mixer,
18238 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018239 alc662_eapd_init_verbs,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018240 alc663_mode8_init_verbs },
18241 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18242 .hp_nid = 0x03,
18243 .dac_nids = alc662_dac_nids,
18244 .dig_out_nid = ALC662_DIGOUT_NID,
18245 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18246 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018247 .unsol_event = alc_sku_unsol_event,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018248 .setup = alc663_mode8_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018249 .init_hook = alc_inithook,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018250 },
Kailang Yang622e84c2009-04-21 07:39:04 +020018251 [ALC272_DELL] = {
18252 .mixers = { alc663_m51va_mixer },
18253 .cap_mixer = alc272_auto_capture_mixer,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018254 .init_verbs = { alc662_init_verbs,
18255 alc662_eapd_init_verbs,
18256 alc272_dell_init_verbs },
Kailang Yang622e84c2009-04-21 07:39:04 +020018257 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
Takashi Iwai1bc7cf92011-04-06 09:42:29 +020018258 .dac_nids = alc272_dac_nids,
Kailang Yang622e84c2009-04-21 07:39:04 +020018259 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18260 .adc_nids = alc272_adc_nids,
18261 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
18262 .capsrc_nids = alc272_capsrc_nids,
18263 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018264 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018265 .setup = alc663_m51va_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018266 .init_hook = alc_inithook,
Kailang Yang622e84c2009-04-21 07:39:04 +020018267 },
18268 [ALC272_DELL_ZM1] = {
18269 .mixers = { alc663_m51va_mixer },
18270 .cap_mixer = alc662_auto_capture_mixer,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018271 .init_verbs = { alc662_init_verbs,
18272 alc662_eapd_init_verbs,
18273 alc272_dell_zm1_init_verbs },
Kailang Yang622e84c2009-04-21 07:39:04 +020018274 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
Takashi Iwai1bc7cf92011-04-06 09:42:29 +020018275 .dac_nids = alc272_dac_nids,
Kailang Yang622e84c2009-04-21 07:39:04 +020018276 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18277 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018278 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020018279 .capsrc_nids = alc662_capsrc_nids,
18280 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018281 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018282 .setup = alc663_m51va_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018283 .init_hook = alc_inithook,
Kailang Yang622e84c2009-04-21 07:39:04 +020018284 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020018285 [ALC272_SAMSUNG_NC10] = {
18286 .mixers = { alc272_nc10_mixer },
18287 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018288 alc662_eapd_init_verbs,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018289 alc663_21jd_amic_init_verbs },
18290 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18291 .dac_nids = alc272_dac_nids,
18292 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18293 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018294 /*.input_mux = &alc272_nc10_capture_source,*/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018295 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018296 .setup = alc663_mode4_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018297 .init_hook = alc_inithook,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018298 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018299};
18300
18301
18302/*
18303 * BIOS auto configuration
18304 */
18305
Takashi Iwai7085ec12009-10-02 09:03:58 +020018306/* convert from MIX nid to DAC */
Takashi Iwai604401a2011-04-27 15:14:23 +020018307static hda_nid_t alc_auto_mix_to_dac(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018308{
Takashi Iwai604401a2011-04-27 15:14:23 +020018309 hda_nid_t list[5];
Takashi Iwai1304ac82011-04-06 15:16:21 +020018310 int i, num;
18311
18312 num = snd_hda_get_connections(codec, nid, list, ARRAY_SIZE(list));
18313 for (i = 0; i < num; i++) {
18314 if (get_wcaps_type(get_wcaps(codec, list[i])) == AC_WID_AUD_OUT)
18315 return list[i];
18316 }
18317 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018318}
18319
Takashi Iwai604401a2011-04-27 15:14:23 +020018320/* go down to the selector widget before the mixer */
18321static hda_nid_t alc_go_down_to_selector(struct hda_codec *codec, hda_nid_t pin)
18322{
18323 hda_nid_t srcs[5];
18324 int num = snd_hda_get_connections(codec, pin, srcs,
18325 ARRAY_SIZE(srcs));
18326 if (num != 1 ||
18327 get_wcaps_type(get_wcaps(codec, srcs[0])) != AC_WID_AUD_SEL)
18328 return pin;
18329 return srcs[0];
18330}
18331
Takashi Iwai7085ec12009-10-02 09:03:58 +020018332/* get MIX nid connected to the given pin targeted to DAC */
Takashi Iwai604401a2011-04-27 15:14:23 +020018333static hda_nid_t alc_auto_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018334 hda_nid_t dac)
18335{
David Henningssoncc1c4522010-11-24 14:17:47 +010018336 hda_nid_t mix[5];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018337 int i, num;
18338
Takashi Iwai604401a2011-04-27 15:14:23 +020018339 pin = alc_go_down_to_selector(codec, pin);
Takashi Iwai7085ec12009-10-02 09:03:58 +020018340 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
18341 for (i = 0; i < num; i++) {
Takashi Iwai604401a2011-04-27 15:14:23 +020018342 if (alc_auto_mix_to_dac(codec, mix[i]) == dac)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018343 return mix[i];
18344 }
18345 return 0;
18346}
18347
Takashi Iwaice764ab2011-04-27 16:35:23 +020018348/* select the connection from pin to DAC if needed */
18349static int alc_auto_select_dac(struct hda_codec *codec, hda_nid_t pin,
18350 hda_nid_t dac)
18351{
18352 hda_nid_t mix[5];
18353 int i, num;
18354
18355 pin = alc_go_down_to_selector(codec, pin);
18356 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
18357 if (num < 2)
18358 return 0;
18359 for (i = 0; i < num; i++) {
18360 if (alc_auto_mix_to_dac(codec, mix[i]) == dac) {
18361 snd_hda_codec_update_cache(codec, pin, 0,
18362 AC_VERB_SET_CONNECT_SEL, i);
18363 return 0;
18364 }
18365 }
18366 return 0;
18367}
18368
Takashi Iwai7085ec12009-10-02 09:03:58 +020018369/* look for an empty DAC slot */
Takashi Iwai604401a2011-04-27 15:14:23 +020018370static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018371{
18372 struct alc_spec *spec = codec->spec;
18373 hda_nid_t srcs[5];
Takashi Iwai3af9ee62011-06-27 12:34:01 +020018374 int i, num;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018375
Takashi Iwai604401a2011-04-27 15:14:23 +020018376 pin = alc_go_down_to_selector(codec, pin);
Takashi Iwai7085ec12009-10-02 09:03:58 +020018377 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
Takashi Iwai7085ec12009-10-02 09:03:58 +020018378 for (i = 0; i < num; i++) {
Takashi Iwai604401a2011-04-27 15:14:23 +020018379 hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]);
Takashi Iwai7085ec12009-10-02 09:03:58 +020018380 if (!nid)
18381 continue;
Takashi Iwai3af9ee62011-06-27 12:34:01 +020018382 if (found_in_nid_list(nid, spec->multiout.dac_nids,
18383 spec->multiout.num_dacs))
18384 continue;
18385 if (spec->multiout.hp_nid == nid)
18386 continue;
18387 if (found_in_nid_list(nid, spec->multiout.extra_out_nid,
18388 ARRAY_SIZE(spec->multiout.extra_out_nid)))
18389 continue;
18390 return nid;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018391 }
18392 return 0;
18393}
18394
Takashi Iwai3af9ee62011-06-27 12:34:01 +020018395static hda_nid_t get_dac_if_single(struct hda_codec *codec, hda_nid_t pin)
18396{
18397 hda_nid_t sel = alc_go_down_to_selector(codec, pin);
18398 if (snd_hda_get_conn_list(codec, sel, NULL) == 1)
18399 return alc_auto_look_for_dac(codec, pin);
18400 return 0;
18401}
18402
Takashi Iwai7085ec12009-10-02 09:03:58 +020018403/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai343a04b2011-07-06 14:28:39 +020018404static int alc_auto_fill_dac_nids(struct hda_codec *codec)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018405{
18406 struct alc_spec *spec = codec->spec;
Takashi Iwaicb053a82011-06-27 11:32:07 +020018407 const struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai350434e2011-06-30 21:29:12 +020018408 bool redone = false;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018409 int i;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018410
Takashi Iwai3af9ee62011-06-27 12:34:01 +020018411 again:
Takashi Iwai3fccdfd2011-06-24 10:35:05 +020018412 spec->multiout.num_dacs = 0;
Takashi Iwai3af9ee62011-06-27 12:34:01 +020018413 spec->multiout.hp_nid = 0;
18414 spec->multiout.extra_out_nid[0] = 0;
18415 memset(spec->private_dac_nids, 0, sizeof(spec->private_dac_nids));
18416 spec->multiout.dac_nids = spec->private_dac_nids;
18417
18418 /* fill hard-wired DACs first */
18419 if (!redone) {
18420 for (i = 0; i < cfg->line_outs; i++)
18421 spec->private_dac_nids[i] =
18422 get_dac_if_single(codec, cfg->line_out_pins[i]);
18423 if (cfg->hp_outs)
18424 spec->multiout.hp_nid =
18425 get_dac_if_single(codec, cfg->hp_pins[0]);
18426 if (cfg->speaker_outs)
18427 spec->multiout.extra_out_nid[0] =
18428 get_dac_if_single(codec, cfg->speaker_pins[0]);
Takashi Iwai7085ec12009-10-02 09:03:58 +020018429 }
Takashi Iwai3af9ee62011-06-27 12:34:01 +020018430
18431 for (i = 0; i < cfg->line_outs; i++) {
18432 hda_nid_t pin = cfg->line_out_pins[i];
18433 if (spec->private_dac_nids[i])
18434 continue;
18435 spec->private_dac_nids[i] = alc_auto_look_for_dac(codec, pin);
18436 if (!spec->private_dac_nids[i] && !redone) {
18437 /* if we can't find primary DACs, re-probe without
18438 * checking the hard-wired DACs
18439 */
18440 redone = true;
18441 goto again;
18442 }
18443 }
18444
18445 for (i = 0; i < cfg->line_outs; i++) {
18446 if (spec->private_dac_nids[i])
18447 spec->multiout.num_dacs++;
18448 else
18449 memmove(spec->private_dac_nids + i,
18450 spec->private_dac_nids + i + 1,
18451 sizeof(hda_nid_t) * (cfg->line_outs - i - 1));
18452 }
18453
Takashi Iwaibb8bf4d2011-07-06 13:07:54 +020018454 if (cfg->hp_outs && !spec->multiout.hp_nid)
18455 spec->multiout.hp_nid =
18456 alc_auto_look_for_dac(codec, cfg->hp_pins[0]);
18457 if (cfg->speaker_outs && !spec->multiout.extra_out_nid[0])
18458 spec->multiout.extra_out_nid[0] =
18459 alc_auto_look_for_dac(codec, cfg->speaker_pins[0]);
18460
Takashi Iwai7085ec12009-10-02 09:03:58 +020018461 return 0;
18462}
18463
Takashi Iwai343a04b2011-07-06 14:28:39 +020018464static int alc_auto_add_vol_ctl(struct hda_codec *codec,
Takashi Iwai97aaab72011-07-06 14:02:55 +020018465 const char *pfx, int cidx,
18466 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018467{
Takashi Iwai97aaab72011-07-06 14:02:55 +020018468 return __add_pb_vol_ctrl(codec->spec, ALC_CTL_WIDGET_VOL, pfx, cidx,
18469 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
Takashi Iwai7085ec12009-10-02 09:03:58 +020018470}
18471
Takashi Iwai343a04b2011-07-06 14:28:39 +020018472#define alc_auto_add_stereo_vol(codec, pfx, cidx, nid) \
18473 alc_auto_add_vol_ctl(codec, pfx, cidx, nid, 3)
Takashi Iwai97aaab72011-07-06 14:02:55 +020018474
18475/* create a mute-switch for the given mixer widget;
18476 * if it has multiple sources (e.g. DAC and loopback), create a bind-mute
18477 */
Takashi Iwai343a04b2011-07-06 14:28:39 +020018478static int alc_auto_add_sw_ctl(struct hda_codec *codec,
Takashi Iwai97aaab72011-07-06 14:02:55 +020018479 const char *pfx, int cidx,
18480 hda_nid_t nid, unsigned int chs)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018481{
Takashi Iwai97aaab72011-07-06 14:02:55 +020018482 int type;
18483 unsigned long val;
18484 if (snd_hda_get_conn_list(codec, nid, NULL) == 1) {
18485 type = ALC_CTL_WIDGET_MUTE;
18486 val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT);
18487 } else {
18488 type = ALC_CTL_BIND_MUTE;
18489 val = HDA_COMPOSE_AMP_VAL(nid, chs, 2, HDA_INPUT);
18490 }
18491 return __add_pb_sw_ctrl(codec->spec, type, pfx, cidx, val);
Takashi Iwai7085ec12009-10-02 09:03:58 +020018492}
18493
Takashi Iwai343a04b2011-07-06 14:28:39 +020018494#define alc_auto_add_stereo_sw(codec, pfx, cidx, nid) \
18495 alc_auto_add_sw_ctl(codec, pfx, cidx, nid, 3)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018496
18497/* add playback controls from the parsed DAC table */
Takashi Iwai343a04b2011-07-06 14:28:39 +020018498static int alc_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018499 const struct auto_pin_cfg *cfg)
18500{
18501 struct alc_spec *spec = codec->spec;
Takashi Iwaice764ab2011-04-27 16:35:23 +020018502 hda_nid_t nid, mix, pin;
18503 int i, err, noutputs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018504
Takashi Iwaice764ab2011-04-27 16:35:23 +020018505 noutputs = cfg->line_outs;
18506 if (spec->multi_ios > 0)
18507 noutputs += spec->multi_ios;
18508
18509 for (i = 0; i < noutputs; i++) {
Takashi Iwai6843ca12011-06-24 11:03:58 +020018510 const char *name;
18511 int index;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018512 nid = spec->multiout.dac_nids[i];
18513 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018514 continue;
Takashi Iwaice764ab2011-04-27 16:35:23 +020018515 if (i >= cfg->line_outs)
18516 pin = spec->multi_io[i - 1].pin;
18517 else
18518 pin = cfg->line_out_pins[i];
18519 mix = alc_auto_dac_to_mix(codec, pin, nid);
Takashi Iwai7085ec12009-10-02 09:03:58 +020018520 if (!mix)
18521 continue;
Takashi Iwai6843ca12011-06-24 11:03:58 +020018522 name = alc_get_line_out_pfx(spec, i, true, &index);
18523 if (!name) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018524 /* Center/LFE */
Takashi Iwai343a04b2011-07-06 14:28:39 +020018525 err = alc_auto_add_vol_ctl(codec, "Center", 0, nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018526 if (err < 0)
18527 return err;
Takashi Iwai343a04b2011-07-06 14:28:39 +020018528 err = alc_auto_add_vol_ctl(codec, "LFE", 0, nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018529 if (err < 0)
18530 return err;
Takashi Iwai343a04b2011-07-06 14:28:39 +020018531 err = alc_auto_add_sw_ctl(codec, "Center", 0, mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018532 if (err < 0)
18533 return err;
Takashi Iwai343a04b2011-07-06 14:28:39 +020018534 err = alc_auto_add_sw_ctl(codec, "LFE", 0, mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018535 if (err < 0)
18536 return err;
18537 } else {
Takashi Iwai343a04b2011-07-06 14:28:39 +020018538 err = alc_auto_add_stereo_vol(codec, name, index, nid);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018539 if (err < 0)
18540 return err;
Takashi Iwai343a04b2011-07-06 14:28:39 +020018541 err = alc_auto_add_stereo_sw(codec, name, index, mix);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018542 if (err < 0)
18543 return err;
18544 }
18545 }
18546 return 0;
18547}
18548
18549/* add playback controls for speaker and HP outputs */
Takashi Iwai343a04b2011-07-06 14:28:39 +020018550static int alc_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Takashi Iwai3af9ee62011-06-27 12:34:01 +020018551 hda_nid_t dac, const char *pfx)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018552{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018553 struct alc_spec *spec = codec->spec;
Takashi Iwai3af9ee62011-06-27 12:34:01 +020018554 hda_nid_t mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018555 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018556
18557 if (!pin)
18558 return 0;
Takashi Iwai3af9ee62011-06-27 12:34:01 +020018559 if (!dac) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018560 /* the corresponding DAC is already occupied */
18561 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
18562 return 0; /* no way */
18563 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018564 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018565 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
18566 }
18567
Takashi Iwai3af9ee62011-06-27 12:34:01 +020018568 mix = alc_auto_dac_to_mix(codec, pin, dac);
Takashi Iwai7085ec12009-10-02 09:03:58 +020018569 if (!mix)
18570 return 0;
Takashi Iwai343a04b2011-07-06 14:28:39 +020018571 err = alc_auto_add_stereo_vol(codec, pfx, 0, dac);
Takashi Iwai7085ec12009-10-02 09:03:58 +020018572 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020018573 return err;
Takashi Iwai343a04b2011-07-06 14:28:39 +020018574 err = alc_auto_add_stereo_sw(codec, pfx, 0, mix);
Takashi Iwai7085ec12009-10-02 09:03:58 +020018575 if (err < 0)
18576 return err;
Takashi Iwai3af9ee62011-06-27 12:34:01 +020018577 return 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018578}
18579
Takashi Iwai343a04b2011-07-06 14:28:39 +020018580static int alc_auto_create_hp_out(struct hda_codec *codec)
18581{
18582 struct alc_spec *spec = codec->spec;
18583 return alc_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
18584 spec->multiout.hp_nid,
18585 "Headphone");
18586}
18587
18588static int alc_auto_create_speaker_out(struct hda_codec *codec)
18589{
18590 struct alc_spec *spec = codec->spec;
18591 return alc_auto_create_extra_out(codec, spec->autocfg.speaker_pins[0],
18592 spec->multiout.extra_out_nid[0],
18593 "Speaker");
18594}
18595
Takashi Iwai343a04b2011-07-06 14:28:39 +020018596static void alc_auto_set_output_and_unmute(struct hda_codec *codec,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018597 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018598 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018599{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018600 int i, num;
Takashi Iwai343a04b2011-07-06 14:28:39 +020018601 hda_nid_t mix = 0;
Takashi Iwaice503f32010-07-30 10:37:29 +020018602 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018603
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018604 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaicd511552011-07-06 13:10:42 +020018605 nid = alc_go_down_to_selector(codec, nid);
Takashi Iwai7085ec12009-10-02 09:03:58 +020018606 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
Takashi Iwai7085ec12009-10-02 09:03:58 +020018607 for (i = 0; i < num; i++) {
Takashi Iwai604401a2011-04-27 15:14:23 +020018608 if (alc_auto_mix_to_dac(codec, srcs[i]) != dac)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018609 continue;
Takashi Iwaicd511552011-07-06 13:10:42 +020018610 mix = srcs[i];
18611 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018612 }
Takashi Iwaicd511552011-07-06 13:10:42 +020018613 if (!mix)
18614 return;
18615
18616 /* need the manual connection? */
18617 if (num > 1)
18618 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
18619 /* unmute mixer widget inputs */
18620 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
18621 AMP_IN_UNMUTE(0));
18622 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
18623 AMP_IN_UNMUTE(1));
18624 /* initialize volume */
18625 if (query_amp_caps(codec, dac, HDA_OUTPUT) & AC_AMPCAP_NUM_STEPS)
18626 nid = dac;
18627 else if (query_amp_caps(codec, mix, HDA_OUTPUT) & AC_AMPCAP_NUM_STEPS)
18628 nid = mix;
18629 else
18630 return;
18631 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
18632 AMP_OUT_ZERO);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018633}
18634
Takashi Iwai343a04b2011-07-06 14:28:39 +020018635static void alc_auto_init_multi_out(struct hda_codec *codec)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018636{
18637 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018638 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018639 int i;
18640
18641 for (i = 0; i <= HDA_SIDE; i++) {
18642 hda_nid_t nid = spec->autocfg.line_out_pins[i];
18643 if (nid)
Takashi Iwai343a04b2011-07-06 14:28:39 +020018644 alc_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018645 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018646 }
18647}
18648
Takashi Iwai343a04b2011-07-06 14:28:39 +020018649static void alc_auto_init_extra_out(struct hda_codec *codec)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018650{
18651 struct alc_spec *spec = codec->spec;
18652 hda_nid_t pin;
18653
18654 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018655 if (pin)
Takashi Iwai343a04b2011-07-06 14:28:39 +020018656 alc_auto_set_output_and_unmute(codec, pin, PIN_HP,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018657 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018658 pin = spec->autocfg.speaker_pins[0];
18659 if (pin)
Takashi Iwai343a04b2011-07-06 14:28:39 +020018660 alc_auto_set_output_and_unmute(codec, pin, PIN_OUT,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018661 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018662}
18663
Takashi Iwaice764ab2011-04-27 16:35:23 +020018664/*
18665 * multi-io helper
18666 */
18667static int alc_auto_fill_multi_ios(struct hda_codec *codec,
18668 unsigned int location)
18669{
18670 struct alc_spec *spec = codec->spec;
18671 struct auto_pin_cfg *cfg = &spec->autocfg;
18672 int type, i, num_pins = 0;
18673
18674 for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) {
18675 for (i = 0; i < cfg->num_inputs; i++) {
18676 hda_nid_t nid = cfg->inputs[i].pin;
18677 hda_nid_t dac;
18678 unsigned int defcfg, caps;
18679 if (cfg->inputs[i].type != type)
18680 continue;
18681 defcfg = snd_hda_codec_get_pincfg(codec, nid);
18682 if (get_defcfg_connect(defcfg) != AC_JACK_PORT_COMPLEX)
18683 continue;
18684 if (location && get_defcfg_location(defcfg) != location)
18685 continue;
18686 caps = snd_hda_query_pin_caps(codec, nid);
18687 if (!(caps & AC_PINCAP_OUT))
18688 continue;
18689 dac = alc_auto_look_for_dac(codec, nid);
18690 if (!dac)
18691 continue;
18692 spec->multi_io[num_pins].pin = nid;
18693 spec->multi_io[num_pins].dac = dac;
18694 num_pins++;
Takashi Iwaidda14412011-05-02 11:29:30 +020018695 spec->private_dac_nids[spec->multiout.num_dacs++] = dac;
Takashi Iwaice764ab2011-04-27 16:35:23 +020018696 }
18697 }
18698 spec->multiout.num_dacs = 1;
18699 if (num_pins < 2)
18700 return 0;
18701 return num_pins;
18702}
18703
18704static int alc_auto_ch_mode_info(struct snd_kcontrol *kcontrol,
18705 struct snd_ctl_elem_info *uinfo)
18706{
18707 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
18708 struct alc_spec *spec = codec->spec;
18709
18710 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
18711 uinfo->count = 1;
18712 uinfo->value.enumerated.items = spec->multi_ios + 1;
18713 if (uinfo->value.enumerated.item > spec->multi_ios)
18714 uinfo->value.enumerated.item = spec->multi_ios;
18715 sprintf(uinfo->value.enumerated.name, "%dch",
18716 (uinfo->value.enumerated.item + 1) * 2);
18717 return 0;
18718}
18719
18720static int alc_auto_ch_mode_get(struct snd_kcontrol *kcontrol,
18721 struct snd_ctl_elem_value *ucontrol)
18722{
18723 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
18724 struct alc_spec *spec = codec->spec;
18725 ucontrol->value.enumerated.item[0] = (spec->ext_channel_count - 1) / 2;
18726 return 0;
18727}
18728
18729static int alc_set_multi_io(struct hda_codec *codec, int idx, bool output)
18730{
18731 struct alc_spec *spec = codec->spec;
18732 hda_nid_t nid = spec->multi_io[idx].pin;
18733
18734 if (!spec->multi_io[idx].ctl_in)
18735 spec->multi_io[idx].ctl_in =
18736 snd_hda_codec_read(codec, nid, 0,
18737 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
18738 if (output) {
18739 snd_hda_codec_update_cache(codec, nid, 0,
18740 AC_VERB_SET_PIN_WIDGET_CONTROL,
18741 PIN_OUT);
18742 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
18743 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
18744 HDA_AMP_MUTE, 0);
18745 alc_auto_select_dac(codec, nid, spec->multi_io[idx].dac);
18746 } else {
18747 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
18748 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
18749 HDA_AMP_MUTE, HDA_AMP_MUTE);
18750 snd_hda_codec_update_cache(codec, nid, 0,
18751 AC_VERB_SET_PIN_WIDGET_CONTROL,
18752 spec->multi_io[idx].ctl_in);
18753 }
18754 return 0;
18755}
18756
18757static int alc_auto_ch_mode_put(struct snd_kcontrol *kcontrol,
18758 struct snd_ctl_elem_value *ucontrol)
18759{
18760 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
18761 struct alc_spec *spec = codec->spec;
18762 int i, ch;
18763
18764 ch = ucontrol->value.enumerated.item[0];
18765 if (ch < 0 || ch > spec->multi_ios)
18766 return -EINVAL;
18767 if (ch == (spec->ext_channel_count - 1) / 2)
18768 return 0;
18769 spec->ext_channel_count = (ch + 1) * 2;
18770 for (i = 0; i < spec->multi_ios; i++)
18771 alc_set_multi_io(codec, i, i < ch);
18772 spec->multiout.max_channels = spec->ext_channel_count;
18773 return 1;
18774}
18775
Takashi Iwaia9111322011-05-02 11:30:18 +020018776static const struct snd_kcontrol_new alc_auto_channel_mode_enum = {
Takashi Iwaice764ab2011-04-27 16:35:23 +020018777 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
18778 .name = "Channel Mode",
18779 .info = alc_auto_ch_mode_info,
18780 .get = alc_auto_ch_mode_get,
18781 .put = alc_auto_ch_mode_put,
18782};
18783
Takashi Iwaicb053a82011-06-27 11:32:07 +020018784static int alc_auto_add_multi_channel_mode(struct hda_codec *codec,
18785 int (*fill_dac)(struct hda_codec *))
Takashi Iwaice764ab2011-04-27 16:35:23 +020018786{
18787 struct alc_spec *spec = codec->spec;
18788 struct auto_pin_cfg *cfg = &spec->autocfg;
18789 unsigned int location, defcfg;
18790 int num_pins;
18791
Takashi Iwai3fccdfd2011-06-24 10:35:05 +020018792 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT && cfg->hp_outs == 1) {
18793 /* use HP as primary out */
18794 cfg->speaker_outs = cfg->line_outs;
18795 memcpy(cfg->speaker_pins, cfg->line_out_pins,
18796 sizeof(cfg->speaker_pins));
18797 cfg->line_outs = cfg->hp_outs;
18798 memcpy(cfg->line_out_pins, cfg->hp_pins, sizeof(cfg->hp_pins));
18799 cfg->hp_outs = 0;
18800 memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins));
18801 cfg->line_out_type = AUTO_PIN_HP_OUT;
Takashi Iwaicb053a82011-06-27 11:32:07 +020018802 if (fill_dac)
18803 fill_dac(codec);
Takashi Iwai3fccdfd2011-06-24 10:35:05 +020018804 }
Takashi Iwaice764ab2011-04-27 16:35:23 +020018805 if (cfg->line_outs != 1 ||
Takashi Iwai3fccdfd2011-06-24 10:35:05 +020018806 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
Takashi Iwaice764ab2011-04-27 16:35:23 +020018807 return 0;
18808
18809 defcfg = snd_hda_codec_get_pincfg(codec, cfg->line_out_pins[0]);
18810 location = get_defcfg_location(defcfg);
18811
18812 num_pins = alc_auto_fill_multi_ios(codec, location);
18813 if (num_pins > 0) {
18814 struct snd_kcontrol_new *knew;
18815
18816 knew = alc_kcontrol_new(spec);
18817 if (!knew)
18818 return -ENOMEM;
18819 *knew = alc_auto_channel_mode_enum;
18820 knew->name = kstrdup("Channel Mode", GFP_KERNEL);
18821 if (!knew->name)
18822 return -ENOMEM;
18823
18824 spec->multi_ios = num_pins;
18825 spec->ext_channel_count = 2;
18826 spec->multiout.num_dacs = num_pins + 1;
18827 }
18828 return 0;
18829}
18830
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018831static int alc662_parse_auto_config(struct hda_codec *codec)
18832{
18833 struct alc_spec *spec = codec->spec;
18834 int err;
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020018835 static const hda_nid_t alc662_ignore[] = { 0x1d, 0 };
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018836
18837 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
18838 alc662_ignore);
18839 if (err < 0)
18840 return err;
18841 if (!spec->autocfg.line_outs)
18842 return 0; /* can't find valid BIOS pin config */
18843
Takashi Iwai343a04b2011-07-06 14:28:39 +020018844 err = alc_auto_fill_dac_nids(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018845 if (err < 0)
18846 return err;
Takashi Iwai343a04b2011-07-06 14:28:39 +020018847 err = alc_auto_add_multi_channel_mode(codec, alc_auto_fill_dac_nids);
Takashi Iwaice764ab2011-04-27 16:35:23 +020018848 if (err < 0)
18849 return err;
Takashi Iwai343a04b2011-07-06 14:28:39 +020018850 err = alc_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018851 if (err < 0)
18852 return err;
Takashi Iwai343a04b2011-07-06 14:28:39 +020018853 err = alc_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018854 spec->autocfg.speaker_pins[0],
Takashi Iwai3af9ee62011-06-27 12:34:01 +020018855 spec->multiout.extra_out_nid[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018856 "Speaker");
18857 if (err < 0)
18858 return err;
Takashi Iwai343a04b2011-07-06 14:28:39 +020018859 err = alc_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwai3af9ee62011-06-27 12:34:01 +020018860 spec->multiout.hp_nid,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018861 "Headphone");
18862 if (err < 0)
18863 return err;
Takashi Iwaib7821702011-07-06 15:12:46 +020018864 err = alc_auto_create_input_ctls(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018865 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018866 return err;
18867
18868 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
18869
Takashi Iwai757899a2010-07-30 10:48:14 +020018870 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018871
Takashi Iwai603c4012008-07-30 15:01:44 +020018872 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010018873 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018874
18875 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020018876 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020018877
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +020018878 if (!spec->dual_adc_switch)
18879 alc_remove_invalid_adc_nids(codec);
18880
Takashi Iwaiee979a142008-09-02 15:42:20 +020018881 err = alc_auto_add_mic_boost(codec);
18882 if (err < 0)
18883 return err;
18884
Kailang Yang6227cdc2010-02-25 08:36:52 +010018885 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18886 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
18887 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
18888 else
18889 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020018890
Takashi Iwai8c87286f2007-06-19 12:11:16 +020018891 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018892}
18893
18894/* additional initialization for auto-configuration model */
18895static void alc662_auto_init(struct hda_codec *codec)
18896{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018897 struct alc_spec *spec = codec->spec;
Takashi Iwai343a04b2011-07-06 14:28:39 +020018898 alc_auto_init_multi_out(codec);
18899 alc_auto_init_extra_out(codec);
Takashi Iwai0a7f5322011-07-06 15:15:12 +020018900 alc_auto_init_analog_input(codec);
Takashi Iwaif970de22011-07-06 17:39:59 +020018901 alc_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020018902 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018903 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020018904 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018905}
18906
Todd Broch6be79482010-12-07 16:51:05 -080018907static void alc272_fixup_mario(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010018908 const struct alc_fixup *fix, int action)
Takashi Iwai6fc398c2011-01-13 14:36:37 +010018909{
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010018910 if (action != ALC_FIXUP_ACT_PROBE)
Takashi Iwai6fc398c2011-01-13 14:36:37 +010018911 return;
Todd Broch6be79482010-12-07 16:51:05 -080018912 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
18913 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
18914 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
18915 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
18916 (0 << AC_AMPCAP_MUTE_SHIFT)))
18917 printk(KERN_WARNING
18918 "hda_codec: failed to override amp caps for NID 0x2\n");
18919}
18920
David Henningsson6cb3b702010-09-09 08:51:44 +020018921enum {
Daniel T Chen2df03512010-10-10 22:39:28 -040018922 ALC662_FIXUP_ASPIRE,
David Henningsson6cb3b702010-09-09 08:51:44 +020018923 ALC662_FIXUP_IDEAPAD,
Todd Broch6be79482010-12-07 16:51:05 -080018924 ALC272_FIXUP_MARIO,
Anisse Astierd2ebd472011-01-20 12:36:21 +010018925 ALC662_FIXUP_CZC_P10T,
David Henningsson94024cd2011-04-29 14:10:55 +020018926 ALC662_FIXUP_SKU_IGNORE,
David Henningsson6cb3b702010-09-09 08:51:44 +020018927};
18928
18929static const struct alc_fixup alc662_fixups[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -040018930 [ALC662_FIXUP_ASPIRE] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010018931 .type = ALC_FIXUP_PINS,
18932 .v.pins = (const struct alc_pincfg[]) {
Daniel T Chen2df03512010-10-10 22:39:28 -040018933 { 0x15, 0x99130112 }, /* subwoofer */
18934 { }
18935 }
18936 },
David Henningsson6cb3b702010-09-09 08:51:44 +020018937 [ALC662_FIXUP_IDEAPAD] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010018938 .type = ALC_FIXUP_PINS,
18939 .v.pins = (const struct alc_pincfg[]) {
David Henningsson6cb3b702010-09-09 08:51:44 +020018940 { 0x17, 0x99130112 }, /* subwoofer */
18941 { }
18942 }
18943 },
Todd Broch6be79482010-12-07 16:51:05 -080018944 [ALC272_FIXUP_MARIO] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010018945 .type = ALC_FIXUP_FUNC,
18946 .v.func = alc272_fixup_mario,
Anisse Astierd2ebd472011-01-20 12:36:21 +010018947 },
18948 [ALC662_FIXUP_CZC_P10T] = {
18949 .type = ALC_FIXUP_VERBS,
18950 .v.verbs = (const struct hda_verb[]) {
18951 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
18952 {}
18953 }
18954 },
David Henningsson94024cd2011-04-29 14:10:55 +020018955 [ALC662_FIXUP_SKU_IGNORE] = {
18956 .type = ALC_FIXUP_SKU,
18957 .v.sku = ALC_FIXUP_SKU_IGNORE,
Takashi Iwaic6b35872011-03-28 12:05:31 +020018958 },
David Henningsson6cb3b702010-09-09 08:51:44 +020018959};
18960
Takashi Iwaia9111322011-05-02 11:30:18 +020018961static const struct snd_pci_quirk alc662_fixup_tbl[] = {
David Henningssona6c47a82011-02-10 15:39:19 +010018962 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
David Henningsson94024cd2011-04-29 14:10:55 +020018963 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
Daniel T Chen2df03512010-10-10 22:39:28 -040018964 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
Daniel T Chena0e90ac2010-11-20 10:20:35 -050018965 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
Valentine Sinitsynd4118582010-10-01 22:24:08 +060018966 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
David Henningsson6cb3b702010-09-09 08:51:44 +020018967 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
Anisse Astierd2ebd472011-01-20 12:36:21 +010018968 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
David Henningsson6cb3b702010-09-09 08:51:44 +020018969 {}
18970};
18971
Todd Broch6be79482010-12-07 16:51:05 -080018972static const struct alc_model_fixup alc662_fixup_models[] = {
18973 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
18974 {}
18975};
David Henningsson6cb3b702010-09-09 08:51:44 +020018976
18977
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018978static int patch_alc662(struct hda_codec *codec)
18979{
18980 struct alc_spec *spec;
18981 int err, board_config;
Kailang Yang693194f2010-10-21 08:51:48 +020018982 int coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018983
18984 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
18985 if (!spec)
18986 return -ENOMEM;
18987
18988 codec->spec = spec;
18989
Takashi Iwai1f0f4b82011-06-27 10:52:59 +020018990 spec->mixer_nid = 0x0b;
18991
Kailang Yangda00c242010-03-19 11:23:45 +010018992 alc_auto_parse_customize_define(codec);
18993
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020018994 alc_fix_pll_init(codec, 0x20, 0x04, 15);
18995
Kailang Yang693194f2010-10-21 08:51:48 +020018996 coef = alc_read_coef_idx(codec, 0);
18997 if (coef == 0x8020 || coef == 0x8011)
Kailang Yangc027ddc2010-03-19 11:33:06 +010018998 alc_codec_rename(codec, "ALC661");
Kailang Yang693194f2010-10-21 08:51:48 +020018999 else if (coef & (1 << 14) &&
19000 codec->bus->pci->subsystem_vendor == 0x1025 &&
19001 spec->cdefine.platform_type == 1)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019002 alc_codec_rename(codec, "ALC272X");
Kailang Yang693194f2010-10-21 08:51:48 +020019003 else if (coef == 0x4011)
19004 alc_codec_rename(codec, "ALC656");
Kailang Yang274693f2009-12-03 10:07:50 +010019005
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019006 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
19007 alc662_models,
19008 alc662_cfg_tbl);
19009 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020019010 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19011 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019012 board_config = ALC662_AUTO;
19013 }
19014
19015 if (board_config == ALC662_AUTO) {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019016 alc_pick_fixup(codec, alc662_fixup_models,
19017 alc662_fixup_tbl, alc662_fixups);
19018 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019019 /* automatic parse from the BIOS config */
19020 err = alc662_parse_auto_config(codec);
19021 if (err < 0) {
19022 alc_free(codec);
19023 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019024 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019025 printk(KERN_INFO
19026 "hda_codec: Cannot set up configuration "
19027 "from BIOS. Using base mode...\n");
19028 board_config = ALC662_3ST_2ch_DIG;
19029 }
19030 }
19031
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019032 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020019033 err = snd_hda_attach_beep_device(codec, 0x1);
19034 if (err < 0) {
19035 alc_free(codec);
19036 return err;
19037 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090019038 }
19039
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019040 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020019041 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019042
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019043 spec->stream_analog_playback = &alc662_pcm_analog_playback;
19044 spec->stream_analog_capture = &alc662_pcm_analog_capture;
19045
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019046 spec->stream_digital_playback = &alc662_pcm_digital_playback;
19047 spec->stream_digital_capture = &alc662_pcm_digital_capture;
19048
Takashi Iwaidd704692009-08-11 08:45:11 +020019049 if (!spec->adc_nids) {
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +020019050 alc_auto_fill_adc_caps(codec);
19051 alc_remove_invalid_adc_nids(codec);
Takashi Iwaidd704692009-08-11 08:45:11 +020019052 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019053
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019054 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019055 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019056
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019057 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010019058 switch (codec->vendor_id) {
19059 case 0x10ec0662:
19060 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
19061 break;
19062 case 0x10ec0272:
19063 case 0x10ec0663:
19064 case 0x10ec0665:
19065 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
19066 break;
19067 case 0x10ec0273:
19068 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
19069 break;
19070 }
Kailang Yangcec27c82010-02-04 14:18:18 +010019071 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010019072 spec->vmaster_nid = 0x02;
19073
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019074 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
19075
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019076 codec->patch_ops = alc_patch_ops;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019077 if (board_config == ALC662_AUTO)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019078 spec->init_hook = alc662_auto_init;
Takashi Iwai1c7161532011-04-07 10:37:16 +020019079 spec->shutup = alc_eapd_shutup;
David Henningsson6cb3b702010-09-09 08:51:44 +020019080
Kailang Yangbf1b0222010-10-21 08:49:56 +020019081 alc_init_jacks(codec);
19082
Takashi Iwaicb53c622007-08-10 17:21:45 +020019083#ifdef CONFIG_SND_HDA_POWER_SAVE
19084 if (!spec->loopback.amplist)
19085 spec->loopback.amplist = alc662_loopbacks;
19086#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019087
19088 return 0;
19089}
19090
Kailang Yang274693f2009-12-03 10:07:50 +010019091static int patch_alc888(struct hda_codec *codec)
19092{
19093 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19094 kfree(codec->chip_name);
Kailang Yang01e0f132010-11-22 10:59:36 +010019095 if (codec->vendor_id == 0x10ec0887)
19096 codec->chip_name = kstrdup("ALC887-VD", GFP_KERNEL);
19097 else
19098 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019099 if (!codec->chip_name) {
19100 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019101 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019102 }
19103 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019104 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019105 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019106}
19107
Kailang Yangb478b992011-05-18 11:51:15 +020019108static int patch_alc899(struct hda_codec *codec)
19109{
19110 if ((alc_read_coef_idx(codec, 0) & 0x2000) != 0x2000) {
19111 kfree(codec->chip_name);
19112 codec->chip_name = kstrdup("ALC898", GFP_KERNEL);
19113 }
19114 return patch_alc882(codec);
19115}
19116
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019117/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019118 * ALC680 support
19119 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019120#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019121#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19122#define alc680_modes alc260_modes
19123
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020019124static const hda_nid_t alc680_dac_nids[3] = {
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019125 /* Lout1, Lout2, hp */
19126 0x02, 0x03, 0x04
19127};
19128
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020019129static const hda_nid_t alc680_adc_nids[3] = {
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019130 /* ADC0-2 */
19131 /* DMIC, MIC, Line-in*/
19132 0x07, 0x08, 0x09
19133};
19134
Kailang Yangc69aefa2010-08-17 10:39:22 +020019135/*
19136 * Analog capture ADC cgange
19137 */
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019138static void alc680_rec_autoswitch(struct hda_codec *codec)
19139{
19140 struct alc_spec *spec = codec->spec;
19141 struct auto_pin_cfg *cfg = &spec->autocfg;
19142 int pin_found = 0;
19143 int type_found = AUTO_PIN_LAST;
19144 hda_nid_t nid;
19145 int i;
19146
19147 for (i = 0; i < cfg->num_inputs; i++) {
19148 nid = cfg->inputs[i].pin;
Takashi Iwai06dec222011-05-17 10:00:16 +020019149 if (!is_jack_detectable(codec, nid))
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019150 continue;
19151 if (snd_hda_jack_detect(codec, nid)) {
19152 if (cfg->inputs[i].type < type_found) {
19153 type_found = cfg->inputs[i].type;
19154 pin_found = nid;
19155 }
19156 }
19157 }
19158
19159 nid = 0x07;
19160 if (pin_found)
19161 snd_hda_get_connections(codec, pin_found, &nid, 1);
19162
19163 if (nid != spec->cur_adc)
19164 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
19165 spec->cur_adc = nid;
19166 snd_hda_codec_setup_stream(codec, nid, spec->cur_adc_stream_tag, 0,
19167 spec->cur_adc_format);
19168}
19169
Kailang Yangc69aefa2010-08-17 10:39:22 +020019170static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19171 struct hda_codec *codec,
19172 unsigned int stream_tag,
19173 unsigned int format,
19174 struct snd_pcm_substream *substream)
19175{
19176 struct alc_spec *spec = codec->spec;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019177
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019178 spec->cur_adc = 0x07;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019179 spec->cur_adc_stream_tag = stream_tag;
19180 spec->cur_adc_format = format;
19181
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019182 alc680_rec_autoswitch(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019183 return 0;
19184}
19185
19186static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19187 struct hda_codec *codec,
19188 struct snd_pcm_substream *substream)
19189{
19190 snd_hda_codec_cleanup_stream(codec, 0x07);
19191 snd_hda_codec_cleanup_stream(codec, 0x08);
19192 snd_hda_codec_cleanup_stream(codec, 0x09);
19193 return 0;
19194}
19195
Takashi Iwaia9111322011-05-02 11:30:18 +020019196static const struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019197 .substreams = 1, /* can be overridden */
19198 .channels_min = 2,
19199 .channels_max = 2,
19200 /* NID is set in alc_build_pcms */
19201 .ops = {
19202 .prepare = alc680_capture_pcm_prepare,
19203 .cleanup = alc680_capture_pcm_cleanup
19204 },
19205};
19206
Takashi Iwaia9111322011-05-02 11:30:18 +020019207static const struct snd_kcontrol_new alc680_base_mixer[] = {
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019208 /* output mixer control */
19209 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19210 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19211 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19212 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010019213 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x12, 0, HDA_INPUT),
19214 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
19215 HDA_CODEC_VOLUME("Line In Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019216 { }
19217};
19218
Takashi Iwaia9111322011-05-02 11:30:18 +020019219static const struct hda_bind_ctls alc680_bind_cap_vol = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019220 .ops = &snd_hda_bind_vol,
19221 .values = {
19222 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19223 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19224 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19225 0
19226 },
19227};
19228
Takashi Iwaia9111322011-05-02 11:30:18 +020019229static const struct hda_bind_ctls alc680_bind_cap_switch = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019230 .ops = &snd_hda_bind_sw,
19231 .values = {
19232 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19233 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19234 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19235 0
19236 },
19237};
19238
Takashi Iwaia9111322011-05-02 11:30:18 +020019239static const struct snd_kcontrol_new alc680_master_capture_mixer[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019240 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19241 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019242 { } /* end */
19243};
19244
19245/*
19246 * generic initialization of ADC, input mixers and output mixers
19247 */
Takashi Iwaia9111322011-05-02 11:30:18 +020019248static const struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019249 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19250 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19251 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019252
Kailang Yangc69aefa2010-08-17 10:39:22 +020019253 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19254 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19255 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19256 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19257 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19258 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019259
19260 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19261 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19262 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19263 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19264 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019265
19266 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19267 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019268 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019269
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019270 { }
19271};
19272
Kailang Yangc69aefa2010-08-17 10:39:22 +020019273/* toggle speaker-output according to the hp-jack state */
19274static void alc680_base_setup(struct hda_codec *codec)
19275{
19276 struct alc_spec *spec = codec->spec;
19277
19278 spec->autocfg.hp_pins[0] = 0x16;
19279 spec->autocfg.speaker_pins[0] = 0x14;
19280 spec->autocfg.speaker_pins[1] = 0x15;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019281 spec->autocfg.num_inputs = 2;
19282 spec->autocfg.inputs[0].pin = 0x18;
19283 spec->autocfg.inputs[0].type = AUTO_PIN_MIC;
19284 spec->autocfg.inputs[1].pin = 0x19;
Takashi Iwai86e29592010-09-09 14:50:17 +020019285 spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN;
Takashi Iwaid922b512011-04-28 12:18:53 +020019286 spec->automute = 1;
19287 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019288}
19289
19290static void alc680_unsol_event(struct hda_codec *codec,
19291 unsigned int res)
19292{
19293 if ((res >> 26) == ALC880_HP_EVENT)
Takashi Iwaid922b512011-04-28 12:18:53 +020019294 alc_hp_automute(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019295 if ((res >> 26) == ALC880_MIC_EVENT)
19296 alc680_rec_autoswitch(codec);
19297}
19298
19299static void alc680_inithook(struct hda_codec *codec)
19300{
Takashi Iwaid922b512011-04-28 12:18:53 +020019301 alc_hp_automute(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019302 alc680_rec_autoswitch(codec);
19303}
19304
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019305/* create input playback/capture controls for the given pin */
19306static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19307 const char *ctlname, int idx)
19308{
19309 hda_nid_t dac;
19310 int err;
19311
19312 switch (nid) {
19313 case 0x14:
19314 dac = 0x02;
19315 break;
19316 case 0x15:
19317 dac = 0x03;
19318 break;
19319 case 0x16:
19320 dac = 0x04;
19321 break;
19322 default:
19323 return 0;
19324 }
19325 if (spec->multiout.dac_nids[0] != dac &&
19326 spec->multiout.dac_nids[1] != dac) {
19327 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19328 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19329 HDA_OUTPUT));
19330 if (err < 0)
19331 return err;
19332
19333 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19334 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19335
19336 if (err < 0)
19337 return err;
Takashi Iwaidda14412011-05-02 11:29:30 +020019338 spec->private_dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019339 }
19340
19341 return 0;
19342}
19343
19344/* add playback controls from the parsed DAC table */
19345static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19346 const struct auto_pin_cfg *cfg)
19347{
19348 hda_nid_t nid;
19349 int err;
19350
19351 spec->multiout.dac_nids = spec->private_dac_nids;
19352
19353 nid = cfg->line_out_pins[0];
19354 if (nid) {
19355 const char *name;
Takashi Iwai2e925dd2011-06-24 11:27:22 +020019356 int index;
19357 name = alc_get_line_out_pfx(spec, 0, true, &index);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019358 err = alc680_new_analog_output(spec, nid, name, 0);
19359 if (err < 0)
19360 return err;
19361 }
19362
19363 nid = cfg->speaker_pins[0];
19364 if (nid) {
19365 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19366 if (err < 0)
19367 return err;
19368 }
19369 nid = cfg->hp_pins[0];
19370 if (nid) {
19371 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19372 if (err < 0)
19373 return err;
19374 }
19375
19376 return 0;
19377}
19378
19379static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19380 hda_nid_t nid, int pin_type)
19381{
19382 alc_set_pin_output(codec, nid, pin_type);
19383}
19384
19385static void alc680_auto_init_multi_out(struct hda_codec *codec)
19386{
19387 struct alc_spec *spec = codec->spec;
19388 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19389 if (nid) {
19390 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19391 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19392 }
19393}
19394
19395static void alc680_auto_init_hp_out(struct hda_codec *codec)
19396{
19397 struct alc_spec *spec = codec->spec;
19398 hda_nid_t pin;
19399
19400 pin = spec->autocfg.hp_pins[0];
19401 if (pin)
19402 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
19403 pin = spec->autocfg.speaker_pins[0];
19404 if (pin)
19405 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
19406}
19407
19408/* pcm configuration: identical with ALC880 */
19409#define alc680_pcm_analog_playback alc880_pcm_analog_playback
19410#define alc680_pcm_analog_capture alc880_pcm_analog_capture
19411#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
19412#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020019413#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019414
19415/*
19416 * BIOS auto configuration
19417 */
19418static int alc680_parse_auto_config(struct hda_codec *codec)
19419{
19420 struct alc_spec *spec = codec->spec;
19421 int err;
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020019422 static const hda_nid_t alc680_ignore[] = { 0 };
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019423
19424 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19425 alc680_ignore);
19426 if (err < 0)
19427 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019428
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019429 if (!spec->autocfg.line_outs) {
19430 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
19431 spec->multiout.max_channels = 2;
19432 spec->no_analog = 1;
19433 goto dig_only;
19434 }
19435 return 0; /* can't find valid BIOS pin config */
19436 }
19437 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
19438 if (err < 0)
19439 return err;
19440
19441 spec->multiout.max_channels = 2;
19442
19443 dig_only:
19444 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020019445 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019446 if (spec->kctls.list)
19447 add_mixer(spec, spec->kctls.list);
19448
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019449 err = alc_auto_add_mic_boost(codec);
19450 if (err < 0)
19451 return err;
19452
19453 return 1;
19454}
19455
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019456/* init callback for auto-configuration model -- overriding the default init */
19457static void alc680_auto_init(struct hda_codec *codec)
19458{
19459 struct alc_spec *spec = codec->spec;
19460 alc680_auto_init_multi_out(codec);
19461 alc680_auto_init_hp_out(codec);
Takashi Iwai0a7f5322011-07-06 15:15:12 +020019462 alc_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019463 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019464 if (spec->unsol_event)
19465 alc_inithook(codec);
19466}
19467
19468/*
19469 * configuration and preset
19470 */
Takashi Iwaiea734962011-01-17 11:29:34 +010019471static const char * const alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020019472 [ALC680_BASE] = "base",
19473 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019474};
19475
Takashi Iwaia9111322011-05-02 11:30:18 +020019476static const struct snd_pci_quirk alc680_cfg_tbl[] = {
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019477 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
19478 {}
19479};
19480
Takashi Iwaia9111322011-05-02 11:30:18 +020019481static const struct alc_config_preset alc680_presets[] = {
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019482 [ALC680_BASE] = {
19483 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020019484 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019485 .init_verbs = { alc680_init_verbs },
19486 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
19487 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019488 .dig_out_nid = ALC680_DIGOUT_NID,
19489 .num_channel_mode = ARRAY_SIZE(alc680_modes),
19490 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020019491 .unsol_event = alc680_unsol_event,
19492 .setup = alc680_base_setup,
19493 .init_hook = alc680_inithook,
19494
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019495 },
19496};
19497
19498static int patch_alc680(struct hda_codec *codec)
19499{
19500 struct alc_spec *spec;
19501 int board_config;
19502 int err;
19503
19504 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19505 if (spec == NULL)
19506 return -ENOMEM;
19507
19508 codec->spec = spec;
19509
Takashi Iwai1f0f4b82011-06-27 10:52:59 +020019510 /* ALC680 has no aa-loopback mixer */
19511
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019512 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
19513 alc680_models,
19514 alc680_cfg_tbl);
19515
19516 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
19517 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19518 codec->chip_name);
19519 board_config = ALC680_AUTO;
19520 }
19521
19522 if (board_config == ALC680_AUTO) {
19523 /* automatic parse from the BIOS config */
19524 err = alc680_parse_auto_config(codec);
19525 if (err < 0) {
19526 alc_free(codec);
19527 return err;
19528 } else if (!err) {
19529 printk(KERN_INFO
19530 "hda_codec: Cannot set up configuration "
19531 "from BIOS. Using base mode...\n");
19532 board_config = ALC680_BASE;
19533 }
19534 }
19535
19536 if (board_config != ALC680_AUTO)
19537 setup_preset(codec, &alc680_presets[board_config]);
19538
19539 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019540 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019541 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019542 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019543
19544 if (!spec->adc_nids) {
Takashi Iwaid6cc9fab2011-07-06 16:38:42 +020019545 alc_auto_fill_adc_caps(codec);
19546 alc_remove_invalid_adc_nids(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019547 }
19548
19549 if (!spec->cap_mixer)
19550 set_capture_mixer(codec);
19551
19552 spec->vmaster_nid = 0x02;
19553
19554 codec->patch_ops = alc_patch_ops;
19555 if (board_config == ALC680_AUTO)
19556 spec->init_hook = alc680_auto_init;
19557
19558 return 0;
19559}
19560
19561/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070019562 * patch entries
19563 */
Takashi Iwaia9111322011-05-02 11:30:18 +020019564static const struct hda_codec_preset snd_hda_preset_realtek[] = {
Kailang Yang296f0332011-05-18 11:52:36 +020019565 { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019566 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019567 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019568 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020019569 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019570 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019571 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020019572 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019573 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Kailang Yang296f0332011-05-18 11:52:36 +020019574 { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019575 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019576 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019577 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
19578 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
19579 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019580 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019581 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019582 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
19583 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020019584 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010019585 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010019586 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019587 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019588 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019589 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019590 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020019591 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019592 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020019593 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019594 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019595 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yang01e0f132010-11-22 10:59:36 +010019596 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc888 },
Kailang Yang44426082008-10-15 11:18:05 +020019597 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019598 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019599 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019600 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019601 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Kailang Yangb478b992011-05-18 11:51:15 +020019602 { .id = 0x10ec0899, .name = "ALC899", .patch = patch_alc899 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019603 {} /* terminator */
19604};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019605
19606MODULE_ALIAS("snd-hda-codec-id:10ec*");
19607
19608MODULE_LICENSE("GPL");
19609MODULE_DESCRIPTION("Realtek HD-audio codec");
19610
19611static struct hda_codec_preset_list realtek_list = {
19612 .preset = snd_hda_preset_realtek,
19613 .owner = THIS_MODULE,
19614};
19615
19616static int __init patch_realtek_init(void)
19617{
19618 return snd_hda_add_codec_preset(&realtek_list);
19619}
19620
19621static void __exit patch_realtek_exit(void)
19622{
19623 snd_hda_delete_codec_preset(&realtek_list);
19624}
19625
19626module_init(patch_realtek_init)
19627module_exit(patch_realtek_exit)