blob: ca211c1cba03bd0d401be79e3dd10ae72e80a04a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
Kailang Yang9ad0e492010-09-14 23:22:00 +020031#include <sound/jack.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include "hda_codec.h"
33#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090034#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
Kailang Yangccc656c2006-10-17 12:32:26 +020036#define ALC880_FRONT_EVENT 0x01
37#define ALC880_DCVOL_EVENT 0x02
38#define ALC880_HP_EVENT 0x04
39#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
41/* ALC880 board config type */
42enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 ALC880_3ST,
44 ALC880_3ST_DIG,
45 ALC880_5ST,
46 ALC880_5ST_DIG,
47 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020048 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020049 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020050 ALC880_6ST_DIG,
51 ALC880_F1734,
52 ALC880_ASUS,
53 ALC880_ASUS_DIG,
54 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010055 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010056 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020057 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020058 ALC880_UNIWILL,
59 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010060 ALC880_CLEVO,
61 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010062 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010063 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020064 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020065#ifdef CONFIG_SND_DEBUG
66 ALC880_TEST,
67#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010068 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020069 ALC880_MODEL_LAST /* last tag */
70};
71
72/* ALC260 models */
73enum {
74 ALC260_BASIC,
75 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020076 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010077 ALC260_HP_3013,
78 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010079 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020080 ALC260_WILL,
81 ALC260_REPLACER_672V,
Michael Schwingencc959482009-02-22 18:58:45 +010082 ALC260_FAVORIT100,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010083#ifdef CONFIG_SND_DEBUG
84 ALC260_TEST,
85#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010086 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020087 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070088};
89
Kailang Yangdf694da2005-12-05 19:42:22 +010090/* ALC262 models */
91enum {
92 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020093 ALC262_HIPPO,
94 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010095 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020096 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010097 ALC262_HP_BPC_D7000_WL,
98 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010099 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +0100100 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +0200101 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200102 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200103 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200104 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100105 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200106 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200107 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200108 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000109 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100110 ALC262_AUTO,
111 ALC262_MODEL_LAST /* last tag */
112};
113
Kailang Yanga361d842007-06-05 12:30:55 +0200114/* ALC268 models */
115enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200116 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200117 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200118 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200119 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100120 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200121 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100122 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100123 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100124#ifdef CONFIG_SND_DEBUG
125 ALC268_TEST,
126#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200127 ALC268_AUTO,
128 ALC268_MODEL_LAST /* last tag */
129};
130
Kailang Yangf6a92242007-12-13 16:52:54 +0100131/* ALC269 models */
132enum {
133 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200134 ALC269_QUANTA_FL1,
Kailang Yang84898e82010-02-04 14:16:14 +0100135 ALC269_AMIC,
136 ALC269_DMIC,
137 ALC269VB_AMIC,
138 ALC269VB_DMIC,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100139 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000140 ALC269_LIFEBOOK,
Kailang Yangfe3eb0a2010-08-06 10:02:57 +0200141 ALC271_ACER,
Kailang Yangf6a92242007-12-13 16:52:54 +0100142 ALC269_AUTO,
143 ALC269_MODEL_LAST /* last tag */
144};
145
Kailang Yangdf694da2005-12-05 19:42:22 +0100146/* ALC861 models */
147enum {
148 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200149 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100150 ALC861_3ST_DIG,
151 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200152 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200153 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200154 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100155 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100156 ALC861_AUTO,
157 ALC861_MODEL_LAST,
158};
159
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100160/* ALC861-VD models */
161enum {
162 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200163 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100164 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100165 ALC861VD_3ST,
166 ALC861VD_3ST_DIG,
167 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200168 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200169 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200170 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100171 ALC861VD_AUTO,
172 ALC861VD_MODEL_LAST,
173};
174
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200175/* ALC662 models */
176enum {
177 ALC662_3ST_2ch_DIG,
178 ALC662_3ST_6ch_DIG,
179 ALC662_3ST_6ch,
180 ALC662_5ST_DIG,
181 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200182 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100183 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200184 ALC663_ASUS_M51VA,
185 ALC663_ASUS_G71V,
186 ALC663_ASUS_H13,
187 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200188 ALC662_ECS,
189 ALC663_ASUS_MODE1,
190 ALC662_ASUS_MODE2,
191 ALC663_ASUS_MODE3,
192 ALC663_ASUS_MODE4,
193 ALC663_ASUS_MODE5,
194 ALC663_ASUS_MODE6,
Kailang Yangebb83ee2009-12-17 12:23:00 +0100195 ALC663_ASUS_MODE7,
196 ALC663_ASUS_MODE8,
Kailang Yang622e84c2009-04-21 07:39:04 +0200197 ALC272_DELL,
198 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200199 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200200 ALC662_AUTO,
201 ALC662_MODEL_LAST,
202};
203
Kailang Yangdf694da2005-12-05 19:42:22 +0100204/* ALC882 models */
205enum {
206 ALC882_3ST_DIG,
207 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200208 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200209 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200210 ALC882_TARGA,
211 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200212 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100213 ALC885_MACPRO,
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -0800214 ALC885_MBA21,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200215 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200216 ALC885_MB5,
Luke Yelaviche458b1f2010-02-12 16:28:29 +1100217 ALC885_MACMINI3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200218 ALC885_IMAC24,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -0800219 ALC885_IMAC91,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200220 ALC883_3ST_2ch_DIG,
221 ALC883_3ST_6ch_DIG,
222 ALC883_3ST_6ch,
223 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200224 ALC883_TARGA_DIG,
225 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200226 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200227 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200228 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800229 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100230 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200231 ALC888_ACER_ASPIRE_8930G,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200232 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200233 ALC883_MEDION,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +0200234 ALC883_MEDION_WIM2160,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100235 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200236 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200237 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200238 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200239 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200240 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200241 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100242 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100243 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430244 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100245 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100246 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800247 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200248 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200249 ALC889A_INTEL,
250 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200251 ALC888_ASUS_M90V,
252 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200253 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100254 ALC1200_ASUS_P5Q,
Guido Günther3e1647c52009-06-05 00:47:26 +0200255 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200256 ALC882_AUTO,
257 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200258};
259
Takashi Iwaid4a86d82010-06-23 17:51:26 +0200260/* ALC680 models */
261enum {
262 ALC680_BASE,
263 ALC680_AUTO,
264 ALC680_MODEL_LAST,
265};
266
Kailang Yangdf694da2005-12-05 19:42:22 +0100267/* for GPIO Poll */
268#define GPIO_MASK 0x03
269
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200270/* extra amp-initialization sequence types */
271enum {
272 ALC_INIT_NONE,
273 ALC_INIT_DEFAULT,
274 ALC_INIT_GPIO1,
275 ALC_INIT_GPIO2,
276 ALC_INIT_GPIO3,
277};
278
Takashi Iwai6c819492009-08-10 18:47:44 +0200279struct alc_mic_route {
280 hda_nid_t pin;
281 unsigned char mux_idx;
282 unsigned char amix_idx;
283};
284
285#define MUX_IDX_UNDEF ((unsigned char)-1)
286
Kailang Yangda00c242010-03-19 11:23:45 +0100287struct alc_customize_define {
288 unsigned int sku_cfg;
289 unsigned char port_connectivity;
290 unsigned char check_sum;
291 unsigned char customization;
292 unsigned char external_amp;
293 unsigned int enable_pcbeep:1;
294 unsigned int platform_type:1;
295 unsigned int swap:1;
296 unsigned int override:1;
David Henningsson90622912010-10-14 14:50:18 +0200297 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
Kailang Yangda00c242010-03-19 11:23:45 +0100298};
299
Takashi Iwaib5bfbc62011-01-13 14:22:32 +0100300struct alc_fixup;
301
Takashi Iwaice764ab2011-04-27 16:35:23 +0200302struct alc_multi_io {
303 hda_nid_t pin; /* multi-io widget pin NID */
304 hda_nid_t dac; /* DAC to be connected */
305 unsigned int ctl_in; /* cached input-pin control value */
306};
307
Takashi Iwaid922b512011-04-28 12:18:53 +0200308enum {
Takashi Iwai3b8510c2011-04-28 14:03:24 +0200309 ALC_AUTOMUTE_PIN, /* change the pin control */
310 ALC_AUTOMUTE_AMP, /* mute/unmute the pin AMP */
311 ALC_AUTOMUTE_MIXER, /* mute/unmute mixer widget AMP */
Takashi Iwaid922b512011-04-28 12:18:53 +0200312};
313
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314struct alc_spec {
315 /* codec parameterization */
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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351
Takashi Iwai840b64c2010-07-13 22:49:01 +0200352 /* capture setup for dynamic dual-adc switch */
353 unsigned int cur_adc_idx;
354 hda_nid_t cur_adc;
355 unsigned int cur_adc_stream_tag;
356 unsigned int cur_adc_format;
357
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200359 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360 const struct hda_input_mux *input_mux;
361 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200362 struct alc_mic_route ext_mic;
Takashi Iwai8ed99d92011-05-17 12:05:02 +0200363 struct alc_mic_route dock_mic;
Takashi Iwai6c819492009-08-10 18:47:44 +0200364 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365
366 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100367 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200369 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200370 int const_channel_count;
371 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372
373 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100374 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200375
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200376 /* dynamic controls, init_verbs and input_mux */
377 struct auto_pin_cfg autocfg;
Kailang Yangda00c242010-03-19 11:23:45 +0100378 struct alc_customize_define cdefine;
Takashi Iwai603c4012008-07-30 15:01:44 +0200379 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200380 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200381 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200382 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
383 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100384
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100385 /* hooks */
386 void (*init_hook)(struct hda_codec *codec);
387 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
Hector Martinf5de24b2009-12-20 22:51:31 +0100388#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -0500389 void (*power_hook)(struct hda_codec *codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100390#endif
Takashi Iwai1c7161532011-04-07 10:37:16 +0200391 void (*shutup)(struct hda_codec *codec);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100392
Takashi Iwai834be882006-03-01 14:16:17 +0100393 /* for pin sensing */
Takashi Iwai834be882006-03-01 14:16:17 +0100394 unsigned int jack_present: 1;
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +0200395 unsigned int line_jack_present:1;
Takashi Iwaie9427962011-04-28 15:46:07 +0200396 unsigned int master_mute:1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200397 unsigned int auto_mic:1;
Takashi Iwaid922b512011-04-28 12:18:53 +0200398 unsigned int automute:1; /* HP automute enabled */
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +0200399 unsigned int detect_line:1; /* Line-out detection enabled */
400 unsigned int automute_lines:1; /* automute line-out as well */
Takashi Iwaiae8a60a2011-04-28 18:09:52 +0200401 unsigned int automute_hp_lo:1; /* both HP and LO available */
Takashi Iwaicb53c622007-08-10 17:21:45 +0200402
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100403 /* other flags */
404 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai840b64c2010-07-13 22:49:01 +0200405 unsigned int dual_adc_switch:1; /* switch ADCs (for ALC275) */
Takashi Iwai584c0c42011-03-10 12:51:11 +0100406 unsigned int single_input_src:1;
Takashi Iwaid922b512011-04-28 12:18:53 +0200407
408 /* auto-mute control */
409 int automute_mode;
Takashi Iwai3b8510c2011-04-28 14:03:24 +0200410 hda_nid_t automute_mixer_nid[AUTO_CFG_MAX_OUTS];
Takashi Iwaid922b512011-04-28 12:18:53 +0200411
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200412 int init_amp;
Takashi Iwaid433a672010-09-20 15:11:54 +0200413 int codec_variant; /* flag for other variants */
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100414
Takashi Iwai2134ea42008-01-10 16:53:55 +0100415 /* for virtual master */
416 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200417#ifdef CONFIG_SND_HDA_POWER_SAVE
418 struct hda_loopback_check loopback;
419#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200420
421 /* for PLL fix */
422 hda_nid_t pll_nid;
423 unsigned int pll_coef_idx, pll_coef_bit;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +0100424
425 /* fix-up list */
426 int fixup_id;
427 const struct alc_fixup *fixup_list;
428 const char *fixup_name;
Takashi Iwaice764ab2011-04-27 16:35:23 +0200429
430 /* multi-io */
431 int multi_ios;
432 struct alc_multi_io multi_io[4];
Kailang Yangdf694da2005-12-05 19:42:22 +0100433};
434
435/*
436 * configuration template - to be copied to the spec instance
437 */
438struct alc_config_preset {
Takashi Iwaia9111322011-05-02 11:30:18 +0200439 const struct snd_kcontrol_new *mixers[5]; /* should be identical size
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200440 * with spec
441 */
Takashi Iwaia9111322011-05-02 11:30:18 +0200442 const struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100443 const struct hda_verb *init_verbs[5];
444 unsigned int num_dacs;
Takashi Iwai4c6d72d2011-05-02 11:30:18 +0200445 const hda_nid_t *dac_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100446 hda_nid_t dig_out_nid; /* optional */
447 hda_nid_t hp_nid; /* optional */
Takashi Iwai4c6d72d2011-05-02 11:30:18 +0200448 const hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100449 unsigned int num_adc_nids;
Takashi Iwai4c6d72d2011-05-02 11:30:18 +0200450 const hda_nid_t *adc_nids;
451 const hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100452 hda_nid_t dig_in_nid;
453 unsigned int num_channel_mode;
454 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200455 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200456 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200457 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100458 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100459 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200460 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100461 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200462#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaia9111322011-05-02 11:30:18 +0200463 const struct hda_amp_list *loopbacks;
Daniel T Chenc97259d2009-12-27 18:52:08 -0500464 void (*power_hook)(struct hda_codec *codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200465#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466};
467
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468
469/*
470 * input MUX handling
471 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200472static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
473 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474{
475 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
476 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200477 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
478 if (mux_idx >= spec->num_mux_defs)
479 mux_idx = 0;
Takashi Iwai53111142010-03-08 12:13:07 +0100480 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
481 mux_idx = 0;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200482 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483}
484
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200485static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
486 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487{
488 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
489 struct alc_spec *spec = codec->spec;
490 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
491
492 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
493 return 0;
494}
495
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200496static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
497 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498{
499 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
500 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100501 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100503 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100504 hda_nid_t nid = spec->capsrc_nids ?
505 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200506 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507
Takashi Iwaicd896c32008-11-18 12:36:33 +0100508 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
509 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +0100510 if (!imux->num_items && mux_idx > 0)
511 imux = &spec->input_mux[0];
Takashi Iwaicd896c32008-11-18 12:36:33 +0100512
Takashi Iwaia22d5432009-07-27 12:54:26 +0200513 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200514 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100515 /* Matrix-mixer style (e.g. ALC882) */
516 unsigned int *cur_val = &spec->cur_mux[adc_idx];
517 unsigned int i, idx;
518
519 idx = ucontrol->value.enumerated.item[0];
520 if (idx >= imux->num_items)
521 idx = imux->num_items - 1;
522 if (*cur_val == idx)
523 return 0;
524 for (i = 0; i < imux->num_items; i++) {
525 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
526 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
527 imux->items[i].index,
528 HDA_AMP_MUTE, v);
529 }
530 *cur_val = idx;
531 return 1;
532 } else {
533 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100534 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100535 &spec->cur_mux[adc_idx]);
536 }
537}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200538
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539/*
540 * channel mode setting
541 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200542static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
543 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544{
545 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
546 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100547 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
548 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549}
550
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200551static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
552 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553{
554 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
555 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100556 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200557 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200558 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559}
560
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200561static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
562 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563{
564 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
565 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200566 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
567 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200568 &spec->ext_channel_count);
569 if (err >= 0 && !spec->const_channel_count) {
570 spec->multiout.max_channels = spec->ext_channel_count;
571 if (spec->need_dac_fix)
572 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
573 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200574 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575}
576
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100578 * Control the mode of pin widget settings via the mixer. "pc" is used
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300579 * instead of "%" to avoid consequences of accidentally treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100580 * being part of a format specifier. Maximum allowed length of a value is
581 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100582 *
583 * Note: some retasking pin complexes seem to ignore requests for input
584 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
585 * are requested. Therefore order this list so that this behaviour will not
586 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200587 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
588 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200589 */
Takashi Iwaia9111322011-05-02 11:30:18 +0200590static const char * const alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100591 "Mic 50pc bias", "Mic 80pc bias",
592 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100593};
Takashi Iwaia9111322011-05-02 11:30:18 +0200594static const unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100595 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100596};
597/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200598 * in the pin being assumed to be exclusively an input or an output pin. In
599 * addition, "input" pins may or may not process the mic bias option
600 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
601 * accept requests for bias as of chip versions up to March 2006) and/or
602 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100603 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200604#define ALC_PIN_DIR_IN 0x00
605#define ALC_PIN_DIR_OUT 0x01
606#define ALC_PIN_DIR_INOUT 0x02
607#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
608#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100609
Kailang Yangea1fb292008-08-26 12:58:38 +0200610/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100611 * For each direction the minimum and maximum values are given.
612 */
Takashi Iwaia9111322011-05-02 11:30:18 +0200613static const signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100614 { 0, 2 }, /* ALC_PIN_DIR_IN */
615 { 3, 4 }, /* ALC_PIN_DIR_OUT */
616 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200617 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
618 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100619};
620#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
621#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
622#define alc_pin_mode_n_items(_dir) \
623 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
624
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200625static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
626 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200627{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100628 unsigned int item_num = uinfo->value.enumerated.item;
629 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
630
631 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200632 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100633 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
634
635 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
636 item_num = alc_pin_mode_min(dir);
637 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200638 return 0;
639}
640
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200641static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
642 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200643{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100644 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200645 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
646 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100647 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200648 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200649 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
650 AC_VERB_GET_PIN_WIDGET_CONTROL,
651 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200652
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100653 /* Find enumerated value for current pinctl setting */
654 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200655 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100656 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200657 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100658 return 0;
659}
660
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200661static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
662 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100663{
664 signed int change;
665 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
666 hda_nid_t nid = kcontrol->private_value & 0xffff;
667 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
668 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200669 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
670 AC_VERB_GET_PIN_WIDGET_CONTROL,
671 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100672
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200673 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100674 val = alc_pin_mode_min(dir);
675
676 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100677 if (change) {
678 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200679 snd_hda_codec_write_cache(codec, nid, 0,
680 AC_VERB_SET_PIN_WIDGET_CONTROL,
681 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100682
Kailang Yangea1fb292008-08-26 12:58:38 +0200683 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100684 * for the requested pin mode. Enum values of 2 or less are
685 * input modes.
686 *
687 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200688 * reduces noise slightly (particularly on input) so we'll
689 * do it. However, having both input and output buffers
690 * enabled simultaneously doesn't seem to be problematic if
691 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100692 */
693 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200694 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
695 HDA_AMP_MUTE, HDA_AMP_MUTE);
696 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
697 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100698 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200699 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
700 HDA_AMP_MUTE, HDA_AMP_MUTE);
701 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
702 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100703 }
704 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200705 return change;
706}
707
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100708#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200709 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100710 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100711 .info = alc_pin_mode_info, \
712 .get = alc_pin_mode_get, \
713 .put = alc_pin_mode_put, \
714 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100715
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100716/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
717 * together using a mask with more than one bit set. This control is
718 * currently used only by the ALC260 test model. At this stage they are not
719 * needed for any "production" models.
720 */
721#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200722#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200723
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200724static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
725 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100726{
727 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
728 hda_nid_t nid = kcontrol->private_value & 0xffff;
729 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
730 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200731 unsigned int val = snd_hda_codec_read(codec, nid, 0,
732 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100733
734 *valp = (val & mask) != 0;
735 return 0;
736}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200737static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
738 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100739{
740 signed int change;
741 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
742 hda_nid_t nid = kcontrol->private_value & 0xffff;
743 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
744 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200745 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
746 AC_VERB_GET_GPIO_DATA,
747 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100748
749 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200750 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
751 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100752 gpio_data &= ~mask;
753 else
754 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200755 snd_hda_codec_write_cache(codec, nid, 0,
756 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100757
758 return change;
759}
760#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
761 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100762 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100763 .info = alc_gpio_data_info, \
764 .get = alc_gpio_data_get, \
765 .put = alc_gpio_data_put, \
766 .private_value = nid | (mask<<16) }
767#endif /* CONFIG_SND_DEBUG */
768
Jonathan Woithe92621f12006-02-28 11:47:47 +0100769/* A switch control to allow the enabling of the digital IO pins on the
770 * ALC260. This is incredibly simplistic; the intention of this control is
771 * to provide something in the test model allowing digital outputs to be
772 * identified if present. If models are found which can utilise these
773 * outputs a more complete mixer control can be devised for those models if
774 * necessary.
775 */
776#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200777#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200778
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200779static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
780 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100781{
782 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
783 hda_nid_t nid = kcontrol->private_value & 0xffff;
784 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
785 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200786 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100787 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100788
789 *valp = (val & mask) != 0;
790 return 0;
791}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200792static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
793 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100794{
795 signed int change;
796 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
797 hda_nid_t nid = kcontrol->private_value & 0xffff;
798 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
799 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200800 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100801 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200802 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100803
804 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200805 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100806 if (val==0)
807 ctrl_data &= ~mask;
808 else
809 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200810 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
811 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100812
813 return change;
814}
815#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
816 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100817 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100818 .info = alc_spdif_ctrl_info, \
819 .get = alc_spdif_ctrl_get, \
820 .put = alc_spdif_ctrl_put, \
821 .private_value = nid | (mask<<16) }
822#endif /* CONFIG_SND_DEBUG */
823
Jonathan Woithef8225f62008-01-08 12:16:54 +0100824/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
825 * Again, this is only used in the ALC26x test models to help identify when
826 * the EAPD line must be asserted for features to work.
827 */
828#ifdef CONFIG_SND_DEBUG
829#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
830
831static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
832 struct snd_ctl_elem_value *ucontrol)
833{
834 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
835 hda_nid_t nid = kcontrol->private_value & 0xffff;
836 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
837 long *valp = ucontrol->value.integer.value;
838 unsigned int val = snd_hda_codec_read(codec, nid, 0,
839 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
840
841 *valp = (val & mask) != 0;
842 return 0;
843}
844
845static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
846 struct snd_ctl_elem_value *ucontrol)
847{
848 int change;
849 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
850 hda_nid_t nid = kcontrol->private_value & 0xffff;
851 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
852 long val = *ucontrol->value.integer.value;
853 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
854 AC_VERB_GET_EAPD_BTLENABLE,
855 0x00);
856
857 /* Set/unset the masked control bit(s) as needed */
858 change = (!val ? 0 : mask) != (ctrl_data & mask);
859 if (!val)
860 ctrl_data &= ~mask;
861 else
862 ctrl_data |= mask;
863 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
864 ctrl_data);
865
866 return change;
867}
868
869#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
870 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100871 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100872 .info = alc_eapd_ctrl_info, \
873 .get = alc_eapd_ctrl_get, \
874 .put = alc_eapd_ctrl_put, \
875 .private_value = nid | (mask<<16) }
876#endif /* CONFIG_SND_DEBUG */
877
Kailang Yangdf694da2005-12-05 19:42:22 +0100878/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100879 * set up the input pin config (depending on the given auto-pin type)
880 */
881static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
882 int auto_pin_type)
883{
884 unsigned int val = PIN_IN;
885
Takashi Iwai86e29592010-09-09 14:50:17 +0200886 if (auto_pin_type == AUTO_PIN_MIC) {
Takashi Iwai23f0c042009-02-26 13:03:58 +0100887 unsigned int pincap;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200888 unsigned int oldval;
889 oldval = snd_hda_codec_read(codec, nid, 0,
890 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Takashi Iwai1327a322009-03-23 13:07:47 +0100891 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100892 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200893 /* if the default pin setup is vref50, we give it priority */
894 if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50)
Takashi Iwai23f0c042009-02-26 13:03:58 +0100895 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200896 else if (pincap & AC_PINCAP_VREF_50)
897 val = PIN_VREF50;
898 else if (pincap & AC_PINCAP_VREF_100)
899 val = PIN_VREF100;
900 else if (pincap & AC_PINCAP_VREF_GRD)
901 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100902 }
903 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
904}
905
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200906static void alc_fixup_autocfg_pin_nums(struct hda_codec *codec)
907{
908 struct alc_spec *spec = codec->spec;
909 struct auto_pin_cfg *cfg = &spec->autocfg;
910
911 if (!cfg->line_outs) {
912 while (cfg->line_outs < AUTO_CFG_MAX_OUTS &&
913 cfg->line_out_pins[cfg->line_outs])
914 cfg->line_outs++;
915 }
916 if (!cfg->speaker_outs) {
917 while (cfg->speaker_outs < AUTO_CFG_MAX_OUTS &&
918 cfg->speaker_pins[cfg->speaker_outs])
919 cfg->speaker_outs++;
920 }
921 if (!cfg->hp_outs) {
922 while (cfg->hp_outs < AUTO_CFG_MAX_OUTS &&
923 cfg->hp_pins[cfg->hp_outs])
924 cfg->hp_outs++;
925 }
926}
927
Takashi Iwai23f0c042009-02-26 13:03:58 +0100928/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100929 */
Takashi Iwaia9111322011-05-02 11:30:18 +0200930static void add_mixer(struct alc_spec *spec, const struct snd_kcontrol_new *mix)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100931{
932 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
933 return;
934 spec->mixers[spec->num_mixers++] = mix;
935}
936
937static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
938{
939 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
940 return;
941 spec->init_verbs[spec->num_init_verbs++] = verb;
942}
943
944/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100945 * set up from the preset table
946 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200947static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200948 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100949{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200950 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100951 int i;
952
953 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100954 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100955 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200956 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
957 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100958 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200959
Kailang Yangdf694da2005-12-05 19:42:22 +0100960 spec->channel_mode = preset->channel_mode;
961 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200962 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200963 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100964
Hector Martin3b315d72009-06-02 10:54:19 +0200965 if (preset->const_channel_count)
966 spec->multiout.max_channels = preset->const_channel_count;
967 else
968 spec->multiout.max_channels = spec->channel_mode[0].channels;
969 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100970
971 spec->multiout.num_dacs = preset->num_dacs;
972 spec->multiout.dac_nids = preset->dac_nids;
973 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800974 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100975 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200976
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200977 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200978 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200979 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100980 spec->input_mux = preset->input_mux;
981
982 spec->num_adc_nids = preset->num_adc_nids;
983 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100984 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100985 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100986
987 spec->unsol_event = preset->unsol_event;
988 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200989#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100990 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200991 spec->loopback.amplist = preset->loopbacks;
992#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200993
994 if (preset->setup)
995 preset->setup(codec);
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200996
997 alc_fixup_autocfg_pin_nums(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100998}
999
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001000/* Enable GPIO mask and set output */
Takashi Iwaia9111322011-05-02 11:30:18 +02001001static const struct hda_verb alc_gpio1_init_verbs[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001002 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
1003 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1004 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
1005 { }
1006};
1007
Takashi Iwaia9111322011-05-02 11:30:18 +02001008static const struct hda_verb alc_gpio2_init_verbs[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001009 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1010 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1011 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
1012 { }
1013};
1014
Takashi Iwaia9111322011-05-02 11:30:18 +02001015static const struct hda_verb alc_gpio3_init_verbs[] = {
Kailang Yangbdd148a2007-05-08 15:19:08 +02001016 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
1017 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
1018 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
1019 { }
1020};
1021
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02001022/*
1023 * Fix hardware PLL issue
1024 * On some codecs, the analog PLL gating control must be off while
1025 * the default value is 1.
1026 */
1027static void alc_fix_pll(struct hda_codec *codec)
1028{
1029 struct alc_spec *spec = codec->spec;
1030 unsigned int val;
1031
1032 if (!spec->pll_nid)
1033 return;
1034 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1035 spec->pll_coef_idx);
1036 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
1037 AC_VERB_GET_PROC_COEF, 0);
1038 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1039 spec->pll_coef_idx);
1040 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
1041 val & ~(1 << spec->pll_coef_bit));
1042}
1043
1044static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
1045 unsigned int coef_idx, unsigned int coef_bit)
1046{
1047 struct alc_spec *spec = codec->spec;
1048 spec->pll_nid = nid;
1049 spec->pll_coef_idx = coef_idx;
1050 spec->pll_coef_bit = coef_bit;
1051 alc_fix_pll(codec);
1052}
1053
Kailang Yang9ad0e492010-09-14 23:22:00 +02001054static int alc_init_jacks(struct hda_codec *codec)
1055{
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001056#ifdef CONFIG_SND_HDA_INPUT_JACK
Kailang Yang9ad0e492010-09-14 23:22:00 +02001057 struct alc_spec *spec = codec->spec;
1058 int err;
1059 unsigned int hp_nid = spec->autocfg.hp_pins[0];
1060 unsigned int mic_nid = spec->ext_mic.pin;
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001061 unsigned int dock_nid = spec->dock_mic.pin;
Kailang Yang9ad0e492010-09-14 23:22:00 +02001062
Takashi Iwai265a0242010-09-21 11:26:21 +02001063 if (hp_nid) {
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001064 err = snd_hda_input_jack_add(codec, hp_nid,
1065 SND_JACK_HEADPHONE, NULL);
Takashi Iwai265a0242010-09-21 11:26:21 +02001066 if (err < 0)
1067 return err;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001068 snd_hda_input_jack_report(codec, hp_nid);
Takashi Iwai265a0242010-09-21 11:26:21 +02001069 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001070
Takashi Iwai265a0242010-09-21 11:26:21 +02001071 if (mic_nid) {
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001072 err = snd_hda_input_jack_add(codec, mic_nid,
1073 SND_JACK_MICROPHONE, NULL);
Takashi Iwai265a0242010-09-21 11:26:21 +02001074 if (err < 0)
1075 return err;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001076 snd_hda_input_jack_report(codec, mic_nid);
Takashi Iwai265a0242010-09-21 11:26:21 +02001077 }
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001078 if (dock_nid) {
1079 err = snd_hda_input_jack_add(codec, dock_nid,
1080 SND_JACK_MICROPHONE, NULL);
1081 if (err < 0)
1082 return err;
1083 snd_hda_input_jack_report(codec, dock_nid);
1084 }
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001085#endif /* CONFIG_SND_HDA_INPUT_JACK */
Kailang Yang9ad0e492010-09-14 23:22:00 +02001086 return 0;
1087}
Kailang Yang9ad0e492010-09-14 23:22:00 +02001088
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001089static int detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins)
Kailang Yangc9b58002007-10-16 14:30:01 +02001090{
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001091 int i, present = 0;
Kailang Yangc9b58002007-10-16 14:30:01 +02001092
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001093 for (i = 0; i < num_pins; i++) {
1094 hda_nid_t nid = pins[i];
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001095 if (!nid)
1096 break;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001097 snd_hda_input_jack_report(codec, nid);
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001098 present |= snd_hda_jack_detect(codec, nid);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001099 }
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001100 return present;
1101}
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001102
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001103static void do_automute(struct hda_codec *codec, int num_pins, hda_nid_t *pins,
Takashi Iwaie9427962011-04-28 15:46:07 +02001104 bool mute, bool hp_out)
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001105{
1106 struct alc_spec *spec = codec->spec;
1107 unsigned int mute_bits = mute ? HDA_AMP_MUTE : 0;
Takashi Iwaie9427962011-04-28 15:46:07 +02001108 unsigned int pin_bits = mute ? 0 : (hp_out ? PIN_HP : PIN_OUT);
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001109 int i;
1110
1111 for (i = 0; i < num_pins; i++) {
1112 hda_nid_t nid = pins[i];
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001113 if (!nid)
1114 break;
Takashi Iwai3b8510c2011-04-28 14:03:24 +02001115 switch (spec->automute_mode) {
1116 case ALC_AUTOMUTE_PIN:
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001117 snd_hda_codec_write(codec, nid, 0,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001118 AC_VERB_SET_PIN_WIDGET_CONTROL,
1119 pin_bits);
Takashi Iwai3b8510c2011-04-28 14:03:24 +02001120 break;
1121 case ALC_AUTOMUTE_AMP:
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001122 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001123 HDA_AMP_MUTE, mute_bits);
Takashi Iwai3b8510c2011-04-28 14:03:24 +02001124 break;
1125 case ALC_AUTOMUTE_MIXER:
1126 nid = spec->automute_mixer_nid[i];
1127 if (!nid)
1128 break;
1129 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001130 HDA_AMP_MUTE, mute_bits);
Takashi Iwai3b8510c2011-04-28 14:03:24 +02001131 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 1,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001132 HDA_AMP_MUTE, mute_bits);
Takashi Iwai3b8510c2011-04-28 14:03:24 +02001133 break;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001134 }
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001135 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001136}
1137
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001138/* Toggle internal speakers muting */
1139static void update_speakers(struct hda_codec *codec)
1140{
1141 struct alc_spec *spec = codec->spec;
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001142 int on;
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001143
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001144 if (!spec->automute)
1145 on = 0;
1146 else
1147 on = spec->jack_present | spec->line_jack_present;
1148 on |= spec->master_mute;
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001149 do_automute(codec, ARRAY_SIZE(spec->autocfg.speaker_pins),
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001150 spec->autocfg.speaker_pins, on, false);
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001151
1152 /* toggle line-out mutes if needed, too */
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001153 /* if LO is a copy of either HP or Speaker, don't need to handle it */
1154 if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0] ||
1155 spec->autocfg.line_out_pins[0] == spec->autocfg.speaker_pins[0])
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001156 return;
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001157 if (!spec->automute_lines || !spec->automute)
1158 on = 0;
1159 else
1160 on = spec->jack_present;
1161 on |= spec->master_mute;
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001162 do_automute(codec, ARRAY_SIZE(spec->autocfg.line_out_pins),
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001163 spec->autocfg.line_out_pins, on, false);
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001164}
1165
1166static void alc_hp_automute(struct hda_codec *codec)
1167{
1168 struct alc_spec *spec = codec->spec;
1169
1170 if (!spec->automute)
1171 return;
1172 spec->jack_present =
1173 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.hp_pins),
1174 spec->autocfg.hp_pins);
1175 update_speakers(codec);
1176}
1177
1178static void alc_line_automute(struct hda_codec *codec)
1179{
1180 struct alc_spec *spec = codec->spec;
1181
1182 if (!spec->automute || !spec->detect_line)
1183 return;
1184 spec->line_jack_present =
1185 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.line_out_pins),
1186 spec->autocfg.line_out_pins);
1187 update_speakers(codec);
1188}
1189
Takashi Iwai6c819492009-08-10 18:47:44 +02001190static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1191 hda_nid_t nid)
1192{
1193 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1194 int i, nums;
1195
1196 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1197 for (i = 0; i < nums; i++)
1198 if (conn[i] == nid)
1199 return i;
1200 return -1;
1201}
1202
Takashi Iwai840b64c2010-07-13 22:49:01 +02001203/* switch the current ADC according to the jack state */
1204static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1205{
1206 struct alc_spec *spec = codec->spec;
1207 unsigned int present;
1208 hda_nid_t new_adc;
1209
1210 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1211 if (present)
1212 spec->cur_adc_idx = 1;
1213 else
1214 spec->cur_adc_idx = 0;
1215 new_adc = spec->adc_nids[spec->cur_adc_idx];
1216 if (spec->cur_adc && spec->cur_adc != new_adc) {
1217 /* stream is running, let's swap the current ADC */
Takashi Iwaif0cea792010-08-13 11:56:53 +02001218 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
Takashi Iwai840b64c2010-07-13 22:49:01 +02001219 spec->cur_adc = new_adc;
1220 snd_hda_codec_setup_stream(codec, new_adc,
1221 spec->cur_adc_stream_tag, 0,
1222 spec->cur_adc_format);
1223 }
1224}
1225
Kailang Yang7fb0d782008-10-15 11:12:35 +02001226static void alc_mic_automute(struct hda_codec *codec)
1227{
1228 struct alc_spec *spec = codec->spec;
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001229 struct alc_mic_route *dead1, *dead2, *alive;
Takashi Iwai6c819492009-08-10 18:47:44 +02001230 unsigned int present, type;
1231 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001232
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001233 if (!spec->auto_mic)
1234 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001235 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1236 return;
1237 if (snd_BUG_ON(!spec->adc_nids))
1238 return;
1239
Takashi Iwai840b64c2010-07-13 22:49:01 +02001240 if (spec->dual_adc_switch) {
1241 alc_dual_mic_adc_auto_switch(codec);
1242 return;
1243 }
1244
Takashi Iwai6c819492009-08-10 18:47:44 +02001245 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1246
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001247 alive = &spec->int_mic;
1248 dead1 = &spec->ext_mic;
1249 dead2 = &spec->dock_mic;
1250
Wu Fengguang864f92b2009-11-18 12:38:02 +08001251 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001252 if (present) {
1253 alive = &spec->ext_mic;
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001254 dead1 = &spec->int_mic;
1255 dead2 = &spec->dock_mic;
1256 }
1257 if (!present && spec->dock_mic.pin > 0) {
1258 present = snd_hda_jack_detect(codec, spec->dock_mic.pin);
1259 if (present) {
1260 alive = &spec->dock_mic;
1261 dead1 = &spec->int_mic;
1262 dead2 = &spec->ext_mic;
1263 }
1264 snd_hda_input_jack_report(codec, spec->dock_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001265 }
1266
Takashi Iwai6c819492009-08-10 18:47:44 +02001267 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1268 if (type == AC_WID_AUD_MIX) {
1269 /* Matrix-mixer style (e.g. ALC882) */
1270 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1271 alive->mux_idx,
1272 HDA_AMP_MUTE, 0);
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001273 if (dead1->pin > 0)
1274 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1275 dead1->mux_idx,
1276 HDA_AMP_MUTE, HDA_AMP_MUTE);
1277 if (dead2->pin > 0)
1278 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1279 dead2->mux_idx,
1280 HDA_AMP_MUTE, HDA_AMP_MUTE);
Takashi Iwai6c819492009-08-10 18:47:44 +02001281 } else {
1282 /* MUX style (e.g. ALC880) */
1283 snd_hda_codec_write_cache(codec, cap_nid, 0,
1284 AC_VERB_SET_CONNECT_SEL,
1285 alive->mux_idx);
1286 }
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001287 snd_hda_input_jack_report(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001288
1289 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001290}
1291
Kailang Yangc9b58002007-10-16 14:30:01 +02001292/* unsolicited event for HP jack sensing */
1293static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1294{
1295 if (codec->vendor_id == 0x10ec0880)
1296 res >>= 28;
1297 else
1298 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001299 switch (res) {
1300 case ALC880_HP_EVENT:
Takashi Iwaid922b512011-04-28 12:18:53 +02001301 alc_hp_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001302 break;
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001303 case ALC880_FRONT_EVENT:
1304 alc_line_automute(codec);
1305 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001306 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001307 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001308 break;
1309 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001310}
1311
1312static void alc_inithook(struct hda_codec *codec)
1313{
Takashi Iwaid922b512011-04-28 12:18:53 +02001314 alc_hp_automute(codec);
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02001315 alc_line_automute(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001316 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001317}
1318
Kailang Yangf9423e72008-05-27 12:32:25 +02001319/* additional initialization for ALC888 variants */
1320static void alc888_coef_init(struct hda_codec *codec)
1321{
1322 unsigned int tmp;
1323
1324 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1325 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1326 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001327 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001328 /* alc888S-VC */
1329 snd_hda_codec_read(codec, 0x20, 0,
1330 AC_VERB_SET_PROC_COEF, 0x830);
1331 else
1332 /* alc888-VB */
1333 snd_hda_codec_read(codec, 0x20, 0,
1334 AC_VERB_SET_PROC_COEF, 0x3030);
1335}
1336
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001337static void alc889_coef_init(struct hda_codec *codec)
1338{
1339 unsigned int tmp;
1340
1341 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1342 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1343 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1344 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1345}
1346
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001347/* turn on/off EAPD control (only if available) */
1348static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1349{
1350 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1351 return;
1352 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1353 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1354 on ? 2 : 0);
1355}
1356
Takashi Iwai691f1fc2011-04-07 10:31:43 +02001357/* turn on/off EAPD controls of the codec */
1358static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
1359{
1360 /* We currently only handle front, HP */
1361 switch (codec->vendor_id) {
1362 case 0x10ec0260:
1363 set_eapd(codec, 0x0f, on);
1364 set_eapd(codec, 0x10, on);
1365 break;
1366 case 0x10ec0262:
1367 case 0x10ec0267:
1368 case 0x10ec0268:
1369 case 0x10ec0269:
1370 case 0x10ec0270:
1371 case 0x10ec0272:
1372 case 0x10ec0660:
1373 case 0x10ec0662:
1374 case 0x10ec0663:
1375 case 0x10ec0665:
1376 case 0x10ec0862:
1377 case 0x10ec0889:
1378 case 0x10ec0892:
1379 set_eapd(codec, 0x14, on);
1380 set_eapd(codec, 0x15, on);
1381 break;
1382 }
1383}
1384
Takashi Iwai1c7161532011-04-07 10:37:16 +02001385/* generic shutup callback;
1386 * just turning off EPAD and a little pause for avoiding pop-noise
1387 */
1388static void alc_eapd_shutup(struct hda_codec *codec)
1389{
1390 alc_auto_setup_eapd(codec, false);
1391 msleep(200);
1392}
1393
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001394static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001395{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001396 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001397
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001398 switch (type) {
1399 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001400 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1401 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001402 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001403 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1404 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001405 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001406 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1407 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001408 case ALC_INIT_DEFAULT:
Takashi Iwai691f1fc2011-04-07 10:31:43 +02001409 alc_auto_setup_eapd(codec, true);
Kailang Yangc9b58002007-10-16 14:30:01 +02001410 switch (codec->vendor_id) {
1411 case 0x10ec0260:
1412 snd_hda_codec_write(codec, 0x1a, 0,
1413 AC_VERB_SET_COEF_INDEX, 7);
1414 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1415 AC_VERB_GET_PROC_COEF, 0);
1416 snd_hda_codec_write(codec, 0x1a, 0,
1417 AC_VERB_SET_COEF_INDEX, 7);
1418 snd_hda_codec_write(codec, 0x1a, 0,
1419 AC_VERB_SET_PROC_COEF,
1420 tmp | 0x2010);
1421 break;
1422 case 0x10ec0262:
1423 case 0x10ec0880:
1424 case 0x10ec0882:
1425 case 0x10ec0883:
1426 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001427 case 0x10ec0887:
Takashi Iwai20b67dd2011-03-23 22:54:32 +01001428 /*case 0x10ec0889:*/ /* this causes an SPDIF problem */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001429 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001430 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001431 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001432 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001433 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001434#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001435 case 0x10ec0267:
1436 case 0x10ec0268:
1437 snd_hda_codec_write(codec, 0x20, 0,
1438 AC_VERB_SET_COEF_INDEX, 7);
1439 tmp = snd_hda_codec_read(codec, 0x20, 0,
1440 AC_VERB_GET_PROC_COEF, 0);
1441 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001442 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001443 snd_hda_codec_write(codec, 0x20, 0,
1444 AC_VERB_SET_PROC_COEF,
1445 tmp | 0x3000);
1446 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001447#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001448 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001449 break;
1450 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001451}
Kailang Yangea1fb292008-08-26 12:58:38 +02001452
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001453static int alc_automute_mode_info(struct snd_kcontrol *kcontrol,
1454 struct snd_ctl_elem_info *uinfo)
1455{
Takashi Iwaiae8a60a2011-04-28 18:09:52 +02001456 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1457 struct alc_spec *spec = codec->spec;
1458 static const char * const texts2[] = {
1459 "Disabled", "Enabled"
1460 };
1461 static const char * const texts3[] = {
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001462 "Disabled", "Speaker Only", "Line-Out+Speaker"
1463 };
Takashi Iwaiae8a60a2011-04-28 18:09:52 +02001464 const char * const *texts;
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001465
1466 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1467 uinfo->count = 1;
Takashi Iwaiae8a60a2011-04-28 18:09:52 +02001468 if (spec->automute_hp_lo) {
1469 uinfo->value.enumerated.items = 3;
1470 texts = texts3;
1471 } else {
1472 uinfo->value.enumerated.items = 2;
1473 texts = texts2;
1474 }
1475 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
1476 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001477 strcpy(uinfo->value.enumerated.name,
1478 texts[uinfo->value.enumerated.item]);
1479 return 0;
1480}
1481
1482static int alc_automute_mode_get(struct snd_kcontrol *kcontrol,
1483 struct snd_ctl_elem_value *ucontrol)
1484{
1485 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1486 struct alc_spec *spec = codec->spec;
1487 unsigned int val;
1488 if (!spec->automute)
1489 val = 0;
1490 else if (!spec->automute_lines)
1491 val = 1;
1492 else
1493 val = 2;
1494 ucontrol->value.enumerated.item[0] = val;
1495 return 0;
1496}
1497
1498static int alc_automute_mode_put(struct snd_kcontrol *kcontrol,
1499 struct snd_ctl_elem_value *ucontrol)
1500{
1501 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1502 struct alc_spec *spec = codec->spec;
1503
1504 switch (ucontrol->value.enumerated.item[0]) {
1505 case 0:
1506 if (!spec->automute)
1507 return 0;
1508 spec->automute = 0;
1509 break;
1510 case 1:
1511 if (spec->automute && !spec->automute_lines)
1512 return 0;
1513 spec->automute = 1;
1514 spec->automute_lines = 0;
1515 break;
1516 case 2:
Takashi Iwaiae8a60a2011-04-28 18:09:52 +02001517 if (!spec->automute_hp_lo)
1518 return -EINVAL;
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001519 if (spec->automute && spec->automute_lines)
1520 return 0;
1521 spec->automute = 1;
1522 spec->automute_lines = 1;
1523 break;
1524 default:
1525 return -EINVAL;
1526 }
1527 update_speakers(codec);
1528 return 1;
1529}
1530
Takashi Iwaia9111322011-05-02 11:30:18 +02001531static const struct snd_kcontrol_new alc_automute_mode_enum = {
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001532 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1533 .name = "Auto-Mute Mode",
1534 .info = alc_automute_mode_info,
1535 .get = alc_automute_mode_get,
1536 .put = alc_automute_mode_put,
1537};
1538
1539static struct snd_kcontrol_new *alc_kcontrol_new(struct alc_spec *spec);
1540
1541static int alc_add_automute_mode_enum(struct hda_codec *codec)
1542{
1543 struct alc_spec *spec = codec->spec;
1544 struct snd_kcontrol_new *knew;
1545
1546 knew = alc_kcontrol_new(spec);
1547 if (!knew)
1548 return -ENOMEM;
1549 *knew = alc_automute_mode_enum;
1550 knew->name = kstrdup("Auto-Mute Mode", GFP_KERNEL);
1551 if (!knew->name)
1552 return -ENOMEM;
1553 return 0;
1554}
1555
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001556static void alc_init_auto_hp(struct hda_codec *codec)
1557{
1558 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001559 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai1daf5f42011-04-28 17:57:46 +02001560 int present = 0;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001561 int i;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001562
Takashi Iwai1daf5f42011-04-28 17:57:46 +02001563 if (cfg->hp_pins[0])
1564 present++;
1565 if (cfg->line_out_pins[0])
1566 present++;
1567 if (cfg->speaker_pins[0])
1568 present++;
1569 if (present < 2) /* need two different output types */
1570 return;
Takashi Iwaiae8a60a2011-04-28 18:09:52 +02001571 if (present == 3)
1572 spec->automute_hp_lo = 1; /* both HP and LO automute */
Kailang Yangc9b58002007-10-16 14:30:01 +02001573
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001574 if (!cfg->speaker_pins[0]) {
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001575 memcpy(cfg->speaker_pins, cfg->line_out_pins,
1576 sizeof(cfg->speaker_pins));
1577 cfg->speaker_outs = cfg->line_outs;
1578 }
1579
1580 if (!cfg->hp_pins[0]) {
1581 memcpy(cfg->hp_pins, cfg->line_out_pins,
1582 sizeof(cfg->hp_pins));
1583 cfg->hp_outs = cfg->line_outs;
1584 }
1585
1586 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001587 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwai06dec222011-05-17 10:00:16 +02001588 if (!is_jack_detectable(codec, nid))
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001589 continue;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001590 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001591 nid);
1592 snd_hda_codec_write_cache(codec, nid, 0,
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001593 AC_VERB_SET_UNSOLICITED_ENABLE,
1594 AC_USRSP_EN | ALC880_HP_EVENT);
Takashi Iwaid922b512011-04-28 12:18:53 +02001595 spec->automute = 1;
1596 spec->automute_mode = ALC_AUTOMUTE_PIN;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001597 }
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001598 if (spec->automute && cfg->line_out_pins[0] &&
1599 cfg->line_out_pins[0] != cfg->hp_pins[0] &&
1600 cfg->line_out_pins[0] != cfg->speaker_pins[0]) {
1601 for (i = 0; i < cfg->line_outs; i++) {
1602 hda_nid_t nid = cfg->line_out_pins[i];
Takashi Iwai06dec222011-05-17 10:00:16 +02001603 if (!is_jack_detectable(codec, nid))
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001604 continue;
1605 snd_printdd("realtek: Enable Line-Out auto-muting "
1606 "on NID 0x%x\n", nid);
1607 snd_hda_codec_write_cache(codec, nid, 0,
1608 AC_VERB_SET_UNSOLICITED_ENABLE,
1609 AC_USRSP_EN | ALC880_FRONT_EVENT);
1610 spec->detect_line = 1;
1611 }
Takashi Iwai52d3cb82011-05-17 10:04:08 +02001612 spec->automute_lines = spec->detect_line;
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001613 }
Takashi Iwaiae8a60a2011-04-28 18:09:52 +02001614
1615 if (spec->automute) {
1616 /* create a control for automute mode */
1617 alc_add_automute_mode_enum(codec);
1618 spec->unsol_event = alc_sku_unsol_event;
1619 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001620}
1621
Takashi Iwai6c819492009-08-10 18:47:44 +02001622static void alc_init_auto_mic(struct hda_codec *codec)
1623{
1624 struct alc_spec *spec = codec->spec;
1625 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001626 hda_nid_t fixed, ext, dock;
Takashi Iwai6c819492009-08-10 18:47:44 +02001627 int i;
1628
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001629 fixed = ext = dock = 0;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001630 for (i = 0; i < cfg->num_inputs; i++) {
1631 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai6c819492009-08-10 18:47:44 +02001632 unsigned int defcfg;
Takashi Iwai6c819492009-08-10 18:47:44 +02001633 defcfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001634 switch (snd_hda_get_input_pin_attr(defcfg)) {
1635 case INPUT_PIN_ATTR_INT:
Takashi Iwai6c819492009-08-10 18:47:44 +02001636 if (fixed)
1637 return; /* already occupied */
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001638 if (cfg->inputs[i].type != AUTO_PIN_MIC)
1639 return; /* invalid type */
Takashi Iwai6c819492009-08-10 18:47:44 +02001640 fixed = nid;
1641 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001642 case INPUT_PIN_ATTR_UNUSED:
1643 return; /* invalid entry */
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001644 case INPUT_PIN_ATTR_DOCK:
1645 if (dock)
1646 return; /* already occupied */
1647 if (cfg->inputs[i].type > AUTO_PIN_LINE_IN)
1648 return; /* invalid type */
1649 dock = nid;
1650 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001651 default:
Takashi Iwai6c819492009-08-10 18:47:44 +02001652 if (ext)
1653 return; /* already occupied */
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001654 if (cfg->inputs[i].type != AUTO_PIN_MIC)
1655 return; /* invalid type */
Takashi Iwai6c819492009-08-10 18:47:44 +02001656 ext = nid;
1657 break;
Takashi Iwai6c819492009-08-10 18:47:44 +02001658 }
1659 }
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001660 if (!ext && dock) {
1661 ext = dock;
1662 dock = 0;
1663 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001664 if (!ext || !fixed)
1665 return;
Takashi Iwaie35d9d62011-05-17 11:28:16 +02001666 if (!is_jack_detectable(codec, ext))
Takashi Iwai6c819492009-08-10 18:47:44 +02001667 return; /* no unsol support */
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001668 if (dock && !is_jack_detectable(codec, dock))
1669 return; /* no unsol support */
1670 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n",
1671 ext, fixed, dock);
Takashi Iwai6c819492009-08-10 18:47:44 +02001672 spec->ext_mic.pin = ext;
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001673 spec->dock_mic.pin = dock;
Takashi Iwai6c819492009-08-10 18:47:44 +02001674 spec->int_mic.pin = fixed;
1675 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
Takashi Iwai8ed99d92011-05-17 12:05:02 +02001676 spec->dock_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
Takashi Iwai6c819492009-08-10 18:47:44 +02001677 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1678 spec->auto_mic = 1;
1679 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1680 AC_VERB_SET_UNSOLICITED_ENABLE,
1681 AC_USRSP_EN | ALC880_MIC_EVENT);
1682 spec->unsol_event = alc_sku_unsol_event;
1683}
1684
David Henningsson90622912010-10-14 14:50:18 +02001685/* Could be any non-zero and even value. When used as fixup, tells
1686 * the driver to ignore any present sku defines.
1687 */
1688#define ALC_FIXUP_SKU_IGNORE (2)
1689
Kailang Yangda00c242010-03-19 11:23:45 +01001690static int alc_auto_parse_customize_define(struct hda_codec *codec)
1691{
1692 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +01001693 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +01001694 struct alc_spec *spec = codec->spec;
1695
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001696 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1697
David Henningsson90622912010-10-14 14:50:18 +02001698 if (spec->cdefine.fixup) {
1699 ass = spec->cdefine.sku_cfg;
1700 if (ass == ALC_FIXUP_SKU_IGNORE)
1701 return -1;
1702 goto do_sku;
1703 }
1704
Kailang Yangda00c242010-03-19 11:23:45 +01001705 ass = codec->subsystem_id & 0xffff;
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001706 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
Kailang Yangda00c242010-03-19 11:23:45 +01001707 goto do_sku;
1708
1709 nid = 0x1d;
1710 if (codec->vendor_id == 0x10ec0260)
1711 nid = 0x17;
1712 ass = snd_hda_codec_get_pincfg(codec, nid);
1713
1714 if (!(ass & 1)) {
1715 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1716 codec->chip_name, ass);
1717 return -1;
1718 }
1719
1720 /* check sum */
1721 tmp = 0;
1722 for (i = 1; i < 16; i++) {
1723 if ((ass >> i) & 1)
1724 tmp++;
1725 }
1726 if (((ass >> 16) & 0xf) != tmp)
1727 return -1;
1728
1729 spec->cdefine.port_connectivity = ass >> 30;
1730 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1731 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1732 spec->cdefine.customization = ass >> 8;
1733do_sku:
1734 spec->cdefine.sku_cfg = ass;
1735 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1736 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1737 spec->cdefine.swap = (ass & 0x2) >> 1;
1738 spec->cdefine.override = ass & 0x1;
1739
1740 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1741 nid, spec->cdefine.sku_cfg);
1742 snd_printd("SKU: port_connectivity=0x%x\n",
1743 spec->cdefine.port_connectivity);
1744 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1745 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1746 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1747 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1748 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1749 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1750 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1751
1752 return 0;
1753}
1754
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001755/* check subsystem ID and set up device-specific initialization;
1756 * return 1 if initialized, 0 if invalid SSID
1757 */
1758/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1759 * 31 ~ 16 : Manufacture ID
1760 * 15 ~ 8 : SKU ID
1761 * 7 ~ 0 : Assembly ID
1762 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1763 */
1764static int alc_subsystem_id(struct hda_codec *codec,
1765 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001766 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001767{
1768 unsigned int ass, tmp, i;
1769 unsigned nid;
1770 struct alc_spec *spec = codec->spec;
1771
David Henningsson90622912010-10-14 14:50:18 +02001772 if (spec->cdefine.fixup) {
1773 ass = spec->cdefine.sku_cfg;
1774 if (ass == ALC_FIXUP_SKU_IGNORE)
1775 return 0;
1776 goto do_sku;
1777 }
1778
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001779 ass = codec->subsystem_id & 0xffff;
1780 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1781 goto do_sku;
1782
1783 /* invalid SSID, check the special NID pin defcfg instead */
1784 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001785 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001786 * 29~21 : reserve
1787 * 20 : PCBEEP input
1788 * 19~16 : Check sum (15:1)
1789 * 15~1 : Custom
1790 * 0 : override
1791 */
1792 nid = 0x1d;
1793 if (codec->vendor_id == 0x10ec0260)
1794 nid = 0x17;
1795 ass = snd_hda_codec_get_pincfg(codec, nid);
1796 snd_printd("realtek: No valid SSID, "
1797 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001798 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001799 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001800 return 0;
1801 if ((ass >> 30) != 1) /* no physical connection */
1802 return 0;
1803
1804 /* check sum */
1805 tmp = 0;
1806 for (i = 1; i < 16; i++) {
1807 if ((ass >> i) & 1)
1808 tmp++;
1809 }
1810 if (((ass >> 16) & 0xf) != tmp)
1811 return 0;
1812do_sku:
1813 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1814 ass & 0xffff, codec->vendor_id);
1815 /*
1816 * 0 : override
1817 * 1 : Swap Jack
1818 * 2 : 0 --> Desktop, 1 --> Laptop
1819 * 3~5 : External Amplifier control
1820 * 7~6 : Reserved
1821 */
1822 tmp = (ass & 0x38) >> 3; /* external Amp control */
1823 switch (tmp) {
1824 case 1:
1825 spec->init_amp = ALC_INIT_GPIO1;
1826 break;
1827 case 3:
1828 spec->init_amp = ALC_INIT_GPIO2;
1829 break;
1830 case 7:
1831 spec->init_amp = ALC_INIT_GPIO3;
1832 break;
1833 case 5:
Takashi Iwai5a8cfb42010-11-26 17:11:18 +01001834 default:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001835 spec->init_amp = ALC_INIT_DEFAULT;
1836 break;
1837 }
1838
1839 /* is laptop or Desktop and enable the function "Mute internal speaker
1840 * when the external headphone out jack is plugged"
1841 */
1842 if (!(ass & 0x8000))
1843 return 1;
1844 /*
1845 * 10~8 : Jack location
1846 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1847 * 14~13: Resvered
1848 * 15 : 1 --> enable the function "Mute internal speaker
1849 * when the external headphone out jack is plugged"
1850 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001851 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001852 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001853 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1854 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001855 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001856 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001857 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001858 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001859 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001860 else if (tmp == 3)
1861 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001862 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001863 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001864 for (i = 0; i < spec->autocfg.line_outs; i++)
1865 if (spec->autocfg.line_out_pins[i] == nid)
1866 return 1;
1867 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001868 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001869 return 1;
1870}
Kailang Yangea1fb292008-08-26 12:58:38 +02001871
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001872static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001873 hda_nid_t porta, hda_nid_t porte,
1874 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001875{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001876 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001877 struct alc_spec *spec = codec->spec;
1878 snd_printd("realtek: "
1879 "Enable default setup for auto mode as fallback\n");
1880 spec->init_amp = ALC_INIT_DEFAULT;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001881 }
Takashi Iwai1a1455d2011-04-28 17:36:18 +02001882
1883 alc_init_auto_hp(codec);
1884 alc_init_auto_mic(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001885}
1886
Takashi Iwai41e41f12005-06-08 14:48:49 +02001887/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001888 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001889 */
1890
1891struct alc_pincfg {
1892 hda_nid_t nid;
1893 u32 val;
1894};
1895
Todd Broche1eb5f12010-12-06 11:19:51 -08001896struct alc_model_fixup {
1897 const int id;
1898 const char *name;
1899};
1900
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001901struct alc_fixup {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001902 int type;
Takashi Iwai361fe6e2011-01-14 09:55:32 +01001903 bool chained;
1904 int chain_id;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001905 union {
1906 unsigned int sku;
1907 const struct alc_pincfg *pins;
1908 const struct hda_verb *verbs;
1909 void (*func)(struct hda_codec *codec,
1910 const struct alc_fixup *fix,
1911 int action);
1912 } v;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001913};
1914
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001915enum {
1916 ALC_FIXUP_INVALID,
1917 ALC_FIXUP_SKU,
1918 ALC_FIXUP_PINS,
1919 ALC_FIXUP_VERBS,
1920 ALC_FIXUP_FUNC,
1921};
Takashi Iwaif95474e2007-07-10 00:47:43 +02001922
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001923enum {
1924 ALC_FIXUP_ACT_PRE_PROBE,
1925 ALC_FIXUP_ACT_PROBE,
Takashi Iwai58701122011-01-13 15:41:45 +01001926 ALC_FIXUP_ACT_INIT,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001927};
1928
1929static void alc_apply_fixup(struct hda_codec *codec, int action)
1930{
1931 struct alc_spec *spec = codec->spec;
1932 int id = spec->fixup_id;
Takashi Iwaiaa1d0c52011-01-19 17:27:58 +01001933#ifdef CONFIG_SND_DEBUG_VERBOSE
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001934 const char *modelname = spec->fixup_name;
Takashi Iwaiaa1d0c52011-01-19 17:27:58 +01001935#endif
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001936 int depth = 0;
1937
1938 if (!spec->fixup_list)
1939 return;
1940
1941 while (id >= 0) {
1942 const struct alc_fixup *fix = spec->fixup_list + id;
1943 const struct alc_pincfg *cfg;
1944
1945 switch (fix->type) {
1946 case ALC_FIXUP_SKU:
1947 if (action != ALC_FIXUP_ACT_PRE_PROBE || !fix->v.sku)
1948 break;;
1949 snd_printdd(KERN_INFO "hda_codec: %s: "
1950 "Apply sku override for %s\n",
1951 codec->chip_name, modelname);
1952 spec->cdefine.sku_cfg = fix->v.sku;
1953 spec->cdefine.fixup = 1;
1954 break;
1955 case ALC_FIXUP_PINS:
1956 cfg = fix->v.pins;
1957 if (action != ALC_FIXUP_ACT_PRE_PROBE || !cfg)
1958 break;
1959 snd_printdd(KERN_INFO "hda_codec: %s: "
1960 "Apply pincfg for %s\n",
1961 codec->chip_name, modelname);
1962 for (; cfg->nid; cfg++)
1963 snd_hda_codec_set_pincfg(codec, cfg->nid,
1964 cfg->val);
1965 break;
1966 case ALC_FIXUP_VERBS:
1967 if (action != ALC_FIXUP_ACT_PROBE || !fix->v.verbs)
1968 break;
1969 snd_printdd(KERN_INFO "hda_codec: %s: "
1970 "Apply fix-verbs for %s\n",
1971 codec->chip_name, modelname);
1972 add_verb(codec->spec, fix->v.verbs);
1973 break;
1974 case ALC_FIXUP_FUNC:
1975 if (!fix->v.func)
1976 break;
1977 snd_printdd(KERN_INFO "hda_codec: %s: "
1978 "Apply fix-func for %s\n",
1979 codec->chip_name, modelname);
1980 fix->v.func(codec, fix, action);
1981 break;
1982 default:
1983 snd_printk(KERN_ERR "hda_codec: %s: "
1984 "Invalid fixup type %d\n",
1985 codec->chip_name, fix->type);
1986 break;
1987 }
Takashi Iwai24af2b12011-05-02 13:55:36 +02001988 if (!fix->chained)
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001989 break;
1990 if (++depth > 10)
1991 break;
Takashi Iwai24af2b12011-05-02 13:55:36 +02001992 id = fix->chain_id;
Takashi Iwai9d578832010-11-22 13:29:19 +01001993 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001994}
1995
Todd Broche1eb5f12010-12-06 11:19:51 -08001996static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001997 const struct alc_model_fixup *models,
1998 const struct snd_pci_quirk *quirk,
1999 const struct alc_fixup *fixlist)
Todd Broche1eb5f12010-12-06 11:19:51 -08002000{
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01002001 struct alc_spec *spec = codec->spec;
2002 int id = -1;
2003 const char *name = NULL;
Todd Broche1eb5f12010-12-06 11:19:51 -08002004
Todd Broche1eb5f12010-12-06 11:19:51 -08002005 if (codec->modelname && models) {
2006 while (models->name) {
2007 if (!strcmp(codec->modelname, models->name)) {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01002008 id = models->id;
2009 name = models->name;
Todd Broche1eb5f12010-12-06 11:19:51 -08002010 break;
2011 }
2012 models++;
2013 }
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01002014 }
2015 if (id < 0) {
2016 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
2017 if (quirk) {
2018 id = quirk->value;
2019#ifdef CONFIG_SND_DEBUG_VERBOSE
2020 name = quirk->name;
2021#endif
2022 }
2023 }
2024
2025 spec->fixup_id = id;
2026 if (id >= 0) {
2027 spec->fixup_list = fixlist;
2028 spec->fixup_name = name;
Todd Broche1eb5f12010-12-06 11:19:51 -08002029 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02002030}
2031
Kailang Yang274693f2009-12-03 10:07:50 +01002032static int alc_read_coef_idx(struct hda_codec *codec,
2033 unsigned int coef_idx)
2034{
2035 unsigned int val;
2036 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
2037 coef_idx);
2038 val = snd_hda_codec_read(codec, 0x20, 0,
2039 AC_VERB_GET_PROC_COEF, 0);
2040 return val;
2041}
2042
Kailang Yang977ddd62010-09-15 10:02:29 +02002043static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
2044 unsigned int coef_val)
2045{
2046 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
2047 coef_idx);
2048 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
2049 coef_val);
2050}
2051
Takashi Iwai757899a2010-07-30 10:48:14 +02002052/* set right pin controls for digital I/O */
2053static void alc_auto_init_digital(struct hda_codec *codec)
2054{
2055 struct alc_spec *spec = codec->spec;
2056 int i;
2057 hda_nid_t pin;
2058
2059 for (i = 0; i < spec->autocfg.dig_outs; i++) {
2060 pin = spec->autocfg.dig_out_pins[i];
2061 if (pin) {
2062 snd_hda_codec_write(codec, pin, 0,
2063 AC_VERB_SET_PIN_WIDGET_CONTROL,
2064 PIN_OUT);
2065 }
2066 }
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;
2681 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002682
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002683 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002684 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2685 HDA_INPUT);
2686 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002687 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002688 return err;
2689}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002690
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002691static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2692 unsigned int size, unsigned int __user *tlv)
2693{
2694 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2695 struct alc_spec *spec = codec->spec;
2696 int err;
2697
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002698 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002699 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2700 HDA_INPUT);
2701 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002702 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002703 return err;
2704}
2705
2706typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2707 struct snd_ctl_elem_value *ucontrol);
2708
2709static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2710 struct snd_ctl_elem_value *ucontrol,
2711 getput_call_t func)
2712{
2713 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2714 struct alc_spec *spec = codec->spec;
2715 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2716 int err;
2717
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002718 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002719 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2720 3, 0, HDA_INPUT);
2721 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002722 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002723 return err;
2724}
2725
2726static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2727 struct snd_ctl_elem_value *ucontrol)
2728{
2729 return alc_cap_getput_caller(kcontrol, ucontrol,
2730 snd_hda_mixer_amp_volume_get);
2731}
2732
2733static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2734 struct snd_ctl_elem_value *ucontrol)
2735{
2736 return alc_cap_getput_caller(kcontrol, ucontrol,
2737 snd_hda_mixer_amp_volume_put);
2738}
2739
2740/* capture mixer elements */
2741#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2742
2743static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2744 struct snd_ctl_elem_value *ucontrol)
2745{
2746 return alc_cap_getput_caller(kcontrol, ucontrol,
2747 snd_hda_mixer_amp_switch_get);
2748}
2749
2750static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2751 struct snd_ctl_elem_value *ucontrol)
2752{
2753 return alc_cap_getput_caller(kcontrol, ucontrol,
2754 snd_hda_mixer_amp_switch_put);
2755}
2756
Takashi Iwaia23b6882009-03-23 15:21:36 +01002757#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002758 { \
2759 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2760 .name = "Capture Switch", \
2761 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2762 .count = num, \
2763 .info = alc_cap_sw_info, \
2764 .get = alc_cap_sw_get, \
2765 .put = alc_cap_sw_put, \
2766 }, \
2767 { \
2768 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2769 .name = "Capture Volume", \
2770 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2771 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2772 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2773 .count = num, \
2774 .info = alc_cap_vol_info, \
2775 .get = alc_cap_vol_get, \
2776 .put = alc_cap_vol_put, \
2777 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002778 }
2779
2780#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002781 { \
2782 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2783 /* .name = "Capture Source", */ \
2784 .name = "Input Source", \
2785 .count = num, \
2786 .info = alc_mux_enum_info, \
2787 .get = alc_mux_enum_get, \
2788 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002789 }
2790
2791#define DEFINE_CAPMIX(num) \
Takashi Iwaia9111322011-05-02 11:30:18 +02002792static const struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002793 _DEFINE_CAPMIX(num), \
2794 _DEFINE_CAPSRC(num), \
2795 { } /* end */ \
2796}
2797
2798#define DEFINE_CAPMIX_NOSRC(num) \
Takashi Iwaia9111322011-05-02 11:30:18 +02002799static const struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002800 _DEFINE_CAPMIX(num), \
2801 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002802}
2803
2804/* up to three ADCs */
2805DEFINE_CAPMIX(1);
2806DEFINE_CAPMIX(2);
2807DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002808DEFINE_CAPMIX_NOSRC(1);
2809DEFINE_CAPMIX_NOSRC(2);
2810DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002811
2812/*
2813 * ALC880 5-stack model
2814 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002815 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2816 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002817 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2818 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2819 */
2820
2821/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaia9111322011-05-02 11:30:18 +02002822static const struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002823 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002824 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002825 { } /* end */
2826};
2827
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002828/* channel source setting (6/8 channel selection for 5-stack) */
2829/* 6ch mode */
Takashi Iwaia9111322011-05-02 11:30:18 +02002830static const struct hda_verb alc880_fivestack_ch6_init[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002831 /* set line-in to input, mute it */
2832 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2833 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002834 { } /* end */
2835};
2836
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002837/* 8ch mode */
Takashi Iwaia9111322011-05-02 11:30:18 +02002838static const struct hda_verb alc880_fivestack_ch8_init[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002839 /* set line-in to output, unmute it */
2840 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2841 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2842 { } /* end */
2843};
2844
Takashi Iwaia9111322011-05-02 11:30:18 +02002845static const struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002846 { 6, alc880_fivestack_ch6_init },
2847 { 8, alc880_fivestack_ch8_init },
2848};
2849
2850
2851/*
2852 * ALC880 6-stack model
2853 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002854 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2855 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002856 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2857 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2858 */
2859
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02002860static const hda_nid_t alc880_6st_dac_nids[4] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002861 /* front, rear, clfe, rear_surr */
2862 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002863};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002864
Takashi Iwaia9111322011-05-02 11:30:18 +02002865static const struct hda_input_mux alc880_6stack_capture_source = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002866 .num_items = 4,
2867 .items = {
2868 { "Mic", 0x0 },
2869 { "Front Mic", 0x1 },
2870 { "Line", 0x2 },
2871 { "CD", 0x4 },
2872 },
2873};
2874
2875/* fixed 8-channels */
Takashi Iwaia9111322011-05-02 11:30:18 +02002876static const struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002877 { 8, NULL },
2878};
2879
Takashi Iwaia9111322011-05-02 11:30:18 +02002880static const struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002881 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002882 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002883 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002884 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002885 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2886 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002887 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2888 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002889 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002890 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002891 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2892 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2893 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2894 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2895 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2896 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2897 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2898 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002899 {
2900 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2901 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002902 .info = alc_ch_mode_info,
2903 .get = alc_ch_mode_get,
2904 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002905 },
2906 { } /* end */
2907};
2908
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002909
2910/*
2911 * ALC880 W810 model
2912 *
2913 * W810 has rear IO for:
2914 * Front (DAC 02)
2915 * Surround (DAC 03)
2916 * Center/LFE (DAC 04)
2917 * Digital out (06)
2918 *
2919 * The system also has a pair of internal speakers, and a headphone jack.
2920 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002921 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002922 * There is a variable resistor to control the speaker or headphone
2923 * volume. This is a hardware-only device without a software API.
2924 *
2925 * Plugging headphones in will disable the internal speakers. This is
2926 * implemented in hardware, not via the driver using jack sense. In
2927 * a similar fashion, plugging into the rear socket marked "front" will
2928 * disable both the speakers and headphones.
2929 *
2930 * For input, there's a microphone jack, and an "audio in" jack.
2931 * These may not do anything useful with this driver yet, because I
2932 * haven't setup any initialization verbs for these yet...
2933 */
2934
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02002935static const hda_nid_t alc880_w810_dac_nids[3] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002936 /* front, rear/surround, clfe */
2937 0x02, 0x03, 0x04
2938};
2939
2940/* fixed 6 channels */
Takashi Iwaia9111322011-05-02 11:30:18 +02002941static const struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002942 { 6, NULL }
2943};
2944
2945/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaia9111322011-05-02 11:30:18 +02002946static const struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002947 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002948 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002949 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002950 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002951 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2952 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002953 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2954 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002955 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2956 { } /* end */
2957};
2958
2959
2960/*
2961 * Z710V model
2962 *
2963 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002964 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2965 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002966 */
2967
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02002968static const hda_nid_t alc880_z71v_dac_nids[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002969 0x02
2970};
2971#define ALC880_Z71V_HP_DAC 0x03
2972
2973/* fixed 2 channels */
Takashi Iwaia9111322011-05-02 11:30:18 +02002974static const struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002975 { 2, NULL }
2976};
2977
Takashi Iwaia9111322011-05-02 11:30:18 +02002978static const struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002979 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002980 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002981 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002982 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002983 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2984 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2985 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2986 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2987 { } /* end */
2988};
2989
2990
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002991/*
2992 * ALC880 F1734 model
2993 *
2994 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2995 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2996 */
2997
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02002998static const hda_nid_t alc880_f1734_dac_nids[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002999 0x03
3000};
3001#define ALC880_F1734_HP_DAC 0x02
3002
Takashi Iwaia9111322011-05-02 11:30:18 +02003003static const struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02003004 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003005 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01003006 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3007 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003008 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
3009 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01003010 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3011 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003012 { } /* end */
3013};
3014
Takashi Iwaia9111322011-05-02 11:30:18 +02003015static const struct hda_input_mux alc880_f1734_capture_source = {
Takashi Iwai937b4162008-02-11 14:52:36 +01003016 .num_items = 2,
3017 .items = {
3018 { "Mic", 0x1 },
3019 { "CD", 0x4 },
3020 },
3021};
3022
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003023
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003024/*
3025 * ALC880 ASUS model
3026 *
3027 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
3028 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
3029 * Mic = 0x18, Line = 0x1a
3030 */
3031
3032#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
3033#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
3034
Takashi Iwaia9111322011-05-02 11:30:18 +02003035static const struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02003036 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003037 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003038 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003039 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003040 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3041 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003042 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3043 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003044 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
3045 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
3046 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3047 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
3048 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3049 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003050 {
3051 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3052 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003053 .info = alc_ch_mode_info,
3054 .get = alc_ch_mode_get,
3055 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02003056 },
3057 { } /* end */
3058};
3059
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003060/*
3061 * ALC880 ASUS W1V model
3062 *
3063 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
3064 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
3065 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
3066 */
3067
3068/* additional mixers to alc880_asus_mixer */
Takashi Iwaia9111322011-05-02 11:30:18 +02003069static const struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02003070 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
3071 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003072 { } /* end */
3073};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003074
Kailang Yangdf694da2005-12-05 19:42:22 +01003075/* TCL S700 */
Takashi Iwaia9111322011-05-02 11:30:18 +02003076static const struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01003077 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3078 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
3079 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
3080 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
3081 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
3082 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
3083 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
3084 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
3085 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003086 { } /* end */
3087};
3088
Kailang Yangccc656c2006-10-17 12:32:26 +02003089/* Uniwill */
Takashi Iwaia9111322011-05-02 11:30:18 +02003090static const struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003091 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3092 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
3093 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3094 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02003095 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3096 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3097 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3098 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3099 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
3100 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
3101 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3102 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
3103 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3104 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3105 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3106 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02003107 {
3108 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3109 .name = "Channel Mode",
3110 .info = alc_ch_mode_info,
3111 .get = alc_ch_mode_get,
3112 .put = alc_ch_mode_put,
3113 },
3114 { } /* end */
3115};
3116
Takashi Iwaia9111322011-05-02 11:30:18 +02003117static const struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003118 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3119 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
3120 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3121 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
3122 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
3123 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson8607f7c2010-12-20 14:43:54 +01003124 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3125 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01003126 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3127 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003128 { } /* end */
3129};
3130
Takashi Iwaia9111322011-05-02 11:30:18 +02003131static const struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003132 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3133 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
3134 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3135 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02003136 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3137 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3138 { } /* end */
3139};
3140
Linus Torvalds1da177e2005-04-16 15:20:36 -07003141/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01003142 * virtual master controls
3143 */
3144
3145/*
3146 * slave controls for virtual master
3147 */
Takashi Iwaiea734962011-01-17 11:29:34 +01003148static const char * const alc_slave_vols[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003149 "Front Playback Volume",
3150 "Surround Playback Volume",
3151 "Center Playback Volume",
3152 "LFE Playback Volume",
3153 "Side Playback Volume",
3154 "Headphone Playback Volume",
3155 "Speaker Playback Volume",
3156 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01003157 "Line-Out Playback Volume",
3158 NULL,
3159};
3160
Takashi Iwaiea734962011-01-17 11:29:34 +01003161static const char * const alc_slave_sws[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003162 "Front Playback Switch",
3163 "Surround Playback Switch",
3164 "Center Playback Switch",
3165 "LFE Playback Switch",
3166 "Side Playback Switch",
3167 "Headphone Playback Switch",
3168 "Speaker Playback Switch",
3169 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01003170 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01003171 "Line-Out Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01003172 NULL,
3173};
3174
3175/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003176 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07003177 */
Takashi Iwai603c4012008-07-30 15:01:44 +02003178
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003179#define NID_MAPPING (-1)
3180
3181#define SUBDEV_SPEAKER_ (0 << 6)
3182#define SUBDEV_HP_ (1 << 6)
3183#define SUBDEV_LINE_ (2 << 6)
3184#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
3185#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
3186#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
3187
Takashi Iwai603c4012008-07-30 15:01:44 +02003188static void alc_free_kctls(struct hda_codec *codec);
3189
Takashi Iwai67d634c2009-11-16 15:35:59 +01003190#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003191/* additional beep mixers; the actual parameters are overwritten at build */
Takashi Iwaia9111322011-05-02 11:30:18 +02003192static const struct snd_kcontrol_new alc_beep_mixer[] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003193 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003194 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003195 { } /* end */
3196};
Takashi Iwai67d634c2009-11-16 15:35:59 +01003197#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003198
Linus Torvalds1da177e2005-04-16 15:20:36 -07003199static int alc_build_controls(struct hda_codec *codec)
3200{
3201 struct alc_spec *spec = codec->spec;
Takashi Iwai2f44f842010-06-22 11:12:32 +02003202 struct snd_kcontrol *kctl = NULL;
Takashi Iwaia9111322011-05-02 11:30:18 +02003203 const struct snd_kcontrol_new *knew;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003204 int i, j, err;
3205 unsigned int u;
3206 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003207
3208 for (i = 0; i < spec->num_mixers; i++) {
3209 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
3210 if (err < 0)
3211 return err;
3212 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003213 if (spec->cap_mixer) {
3214 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
3215 if (err < 0)
3216 return err;
3217 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003218 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003219 err = snd_hda_create_spdif_out_ctls(codec,
3220 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003221 if (err < 0)
3222 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003223 if (!spec->no_analog) {
3224 err = snd_hda_create_spdif_share_sw(codec,
3225 &spec->multiout);
3226 if (err < 0)
3227 return err;
3228 spec->multiout.share_spdif = 1;
3229 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003230 }
3231 if (spec->dig_in_nid) {
3232 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
3233 if (err < 0)
3234 return err;
3235 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01003236
Takashi Iwai67d634c2009-11-16 15:35:59 +01003237#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003238 /* create beep controls if needed */
3239 if (spec->beep_amp) {
Takashi Iwaia9111322011-05-02 11:30:18 +02003240 const struct snd_kcontrol_new *knew;
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003241 for (knew = alc_beep_mixer; knew->name; knew++) {
3242 struct snd_kcontrol *kctl;
3243 kctl = snd_ctl_new1(knew, codec);
3244 if (!kctl)
3245 return -ENOMEM;
3246 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01003247 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003248 if (err < 0)
3249 return err;
3250 }
3251 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01003252#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003253
Takashi Iwai2134ea42008-01-10 16:53:55 +01003254 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003255 if (!spec->no_analog &&
3256 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01003257 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01003258 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01003259 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01003260 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01003261 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01003262 if (err < 0)
3263 return err;
3264 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003265 if (!spec->no_analog &&
3266 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003267 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
3268 NULL, alc_slave_sws);
3269 if (err < 0)
3270 return err;
3271 }
3272
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003273 /* assign Capture Source enums to NID */
Takashi Iwaifbe618f2010-06-11 11:24:58 +02003274 if (spec->capsrc_nids || spec->adc_nids) {
3275 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
3276 if (!kctl)
3277 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
3278 for (i = 0; kctl && i < kctl->count; i++) {
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02003279 const hda_nid_t *nids = spec->capsrc_nids;
Takashi Iwaifbe618f2010-06-11 11:24:58 +02003280 if (!nids)
3281 nids = spec->adc_nids;
3282 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
3283 if (err < 0)
3284 return err;
3285 }
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003286 }
3287 if (spec->cap_mixer) {
3288 const char *kname = kctl ? kctl->id.name : NULL;
3289 for (knew = spec->cap_mixer; knew->name; knew++) {
3290 if (kname && strcmp(knew->name, kname) == 0)
3291 continue;
3292 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3293 for (i = 0; kctl && i < kctl->count; i++) {
3294 err = snd_hda_add_nid(codec, kctl, i,
3295 spec->adc_nids[i]);
3296 if (err < 0)
3297 return err;
3298 }
3299 }
3300 }
3301
3302 /* other nid->control mapping */
3303 for (i = 0; i < spec->num_mixers; i++) {
3304 for (knew = spec->mixers[i]; knew->name; knew++) {
3305 if (knew->iface != NID_MAPPING)
3306 continue;
3307 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3308 if (kctl == NULL)
3309 continue;
3310 u = knew->subdevice;
3311 for (j = 0; j < 4; j++, u >>= 8) {
3312 nid = u & 0x3f;
3313 if (nid == 0)
3314 continue;
3315 switch (u & 0xc0) {
3316 case SUBDEV_SPEAKER_:
3317 nid = spec->autocfg.speaker_pins[nid];
3318 break;
3319 case SUBDEV_LINE_:
3320 nid = spec->autocfg.line_out_pins[nid];
3321 break;
3322 case SUBDEV_HP_:
3323 nid = spec->autocfg.hp_pins[nid];
3324 break;
3325 default:
3326 continue;
3327 }
3328 err = snd_hda_add_nid(codec, kctl, 0, nid);
3329 if (err < 0)
3330 return err;
3331 }
3332 u = knew->private_value;
3333 for (j = 0; j < 4; j++, u >>= 8) {
3334 nid = u & 0xff;
3335 if (nid == 0)
3336 continue;
3337 err = snd_hda_add_nid(codec, kctl, 0, nid);
3338 if (err < 0)
3339 return err;
3340 }
3341 }
3342 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01003343
3344 alc_free_kctls(codec); /* no longer needed */
3345
Linus Torvalds1da177e2005-04-16 15:20:36 -07003346 return 0;
3347}
3348
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003349
Linus Torvalds1da177e2005-04-16 15:20:36 -07003350/*
3351 * initialize the codec volumes, etc
3352 */
3353
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003354/*
3355 * generic initialization of ADC, input mixers and output mixers
3356 */
Takashi Iwaia9111322011-05-02 11:30:18 +02003357static const struct hda_verb alc880_volume_init_verbs[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003358 /*
3359 * Unmute ADC0-2 and set the default input to mic-in
3360 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003361 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003362 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003363 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003364 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003365 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003366 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003367
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003368 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3369 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003370 * Note: PASD motherboards uses the Line In 2 as the input for front
3371 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003372 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003373 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003374 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3375 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3376 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3377 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3378 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3379 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3380 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003381
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003382 /*
3383 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003384 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003385 /* set vol=0 to output mixers */
3386 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3387 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3388 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3389 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3390 /* set up input amps for analog loopback */
3391 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003392 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3393 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003394 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3395 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003396 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3397 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003398 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3399 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003400
3401 { }
3402};
3403
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003404/*
3405 * 3-stack pin configuration:
3406 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
3407 */
Takashi Iwaia9111322011-05-02 11:30:18 +02003408static const struct hda_verb alc880_pin_3stack_init_verbs[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003409 /*
3410 * preset connection lists of input pins
3411 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3412 */
3413 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3414 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3415 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3416
3417 /*
3418 * Set pin mode and muting
3419 */
3420 /* set front pin widgets 0x14 for output */
3421 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3422 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3423 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3424 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3425 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3426 /* Mic2 (as headphone out) for HP output */
3427 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3428 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3429 /* Line In pin widget for input */
3430 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3431 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3432 /* Line2 (as front mic) pin widget for input and vref at 80% */
3433 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3434 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3435 /* CD pin widget for input */
3436 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3437
3438 { }
3439};
3440
3441/*
3442 * 5-stack pin configuration:
3443 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
3444 * line-in/side = 0x1a, f-mic = 0x1b
3445 */
Takashi Iwaia9111322011-05-02 11:30:18 +02003446static const struct hda_verb alc880_pin_5stack_init_verbs[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003447 /*
3448 * preset connection lists of input pins
3449 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3450 */
3451 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3452 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
3453
3454 /*
3455 * Set pin mode and muting
3456 */
3457 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02003458 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3459 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3460 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3461 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003462 /* unmute pins for output (no gain on this amp) */
3463 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3464 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3465 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3466 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3467
Linus Torvalds1da177e2005-04-16 15:20:36 -07003468 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003469 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003470 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3471 /* Mic2 (as headphone out) for HP output */
3472 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003473 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003474 /* Line In pin widget for input */
3475 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3476 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3477 /* Line2 (as front mic) pin widget for input and vref at 80% */
3478 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3479 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3480 /* CD pin widget for input */
3481 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003482
3483 { }
3484};
3485
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003486/*
3487 * W810 pin configuration:
3488 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
3489 */
Takashi Iwaia9111322011-05-02 11:30:18 +02003490static const struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003491 /* hphone/speaker input selector: front DAC */
3492 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
3493
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003494 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3495 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3496 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3497 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3498 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3499 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3500
3501 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003502 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003503
Linus Torvalds1da177e2005-04-16 15:20:36 -07003504 { }
3505};
3506
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003507/*
3508 * Z71V pin configuration:
3509 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
3510 */
Takashi Iwaia9111322011-05-02 11:30:18 +02003511static const struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003512 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003513 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02003514 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003515 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003516
Takashi Iwai16ded522005-06-10 19:58:24 +02003517 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003518 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003519 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003520 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003521
3522 { }
3523};
3524
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003525/*
3526 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003527 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
3528 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003529 */
Takashi Iwaia9111322011-05-02 11:30:18 +02003530static const struct hda_verb alc880_pin_6stack_init_verbs[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003531 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3532
Takashi Iwai16ded522005-06-10 19:58:24 +02003533 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003534 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003535 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003536 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003537 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003538 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003539 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003540 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3541
Takashi Iwai16ded522005-06-10 19:58:24 +02003542 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003543 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003544 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003545 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003546 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003547 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003548 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02003549 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003550 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003551
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003552 { }
3553};
Takashi Iwai16ded522005-06-10 19:58:24 +02003554
Kailang Yangccc656c2006-10-17 12:32:26 +02003555/*
3556 * Uniwill pin configuration:
3557 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3558 * line = 0x1a
3559 */
Takashi Iwaia9111322011-05-02 11:30:18 +02003560static const struct hda_verb alc880_uniwill_init_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02003561 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3562
3563 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3564 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3565 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3566 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3567 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3568 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3569 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3570 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3571 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3572 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3573 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3574 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3575 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3576 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3577
3578 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3579 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3580 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3581 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3582 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3583 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3584 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3585 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3586 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3587
3588 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3589 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3590
3591 { }
3592};
3593
3594/*
3595* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02003596* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02003597 */
Takashi Iwaia9111322011-05-02 11:30:18 +02003598static const struct hda_verb alc880_uniwill_p53_init_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02003599 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3600
3601 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3602 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3603 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3604 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3605 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3606 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3607 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3608 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3609 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3610 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3611 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3612 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3613
3614 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3615 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3616 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3617 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3618 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3619 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3620
3621 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3622 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3623
3624 { }
3625};
3626
Takashi Iwaia9111322011-05-02 11:30:18 +02003627static const struct hda_verb alc880_beep_init_verbs[] = {
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003628 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3629 { }
3630};
3631
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003632/* auto-toggle front mic */
Anisse Astiereeb43382010-12-16 12:19:47 +01003633static void alc88x_simple_mic_automute(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003634{
3635 unsigned int present;
3636 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02003637
Wu Fengguang864f92b2009-11-18 12:38:02 +08003638 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003639 bits = present ? HDA_AMP_MUTE : 0;
3640 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003641}
3642
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003643static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003644{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003645 struct alc_spec *spec = codec->spec;
3646
3647 spec->autocfg.hp_pins[0] = 0x14;
3648 spec->autocfg.speaker_pins[0] = 0x15;
3649 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwaid922b512011-04-28 12:18:53 +02003650 spec->automute = 1;
3651 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003652}
3653
3654static void alc880_uniwill_init_hook(struct hda_codec *codec)
3655{
Takashi Iwaid922b512011-04-28 12:18:53 +02003656 alc_hp_automute(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +01003657 alc88x_simple_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02003658}
3659
3660static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3661 unsigned int res)
3662{
3663 /* Looks like the unsol event is incompatible with the standard
3664 * definition. 4bit tag is placed at 28 bit!
3665 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003666 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003667 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +01003668 alc88x_simple_mic_automute(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003669 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003670 default:
Takashi Iwaid922b512011-04-28 12:18:53 +02003671 alc_sku_unsol_event(codec, res);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003672 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003673 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003674}
3675
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003676static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003677{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003678 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003679
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003680 spec->autocfg.hp_pins[0] = 0x14;
3681 spec->autocfg.speaker_pins[0] = 0x15;
Takashi Iwaid922b512011-04-28 12:18:53 +02003682 spec->automute = 1;
3683 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yangccc656c2006-10-17 12:32:26 +02003684}
3685
3686static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3687{
3688 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003689
Kailang Yangccc656c2006-10-17 12:32:26 +02003690 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003691 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3692 present &= HDA_AMP_VOLMASK;
3693 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3694 HDA_AMP_VOLMASK, present);
3695 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3696 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003697}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003698
Kailang Yangccc656c2006-10-17 12:32:26 +02003699static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3700 unsigned int res)
3701{
3702 /* Looks like the unsol event is incompatible with the standard
3703 * definition. 4bit tag is placed at 28 bit!
3704 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003705 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003706 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003707 else
Takashi Iwaid922b512011-04-28 12:18:53 +02003708 alc_sku_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003709}
3710
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003711/*
3712 * F1734 pin configuration:
3713 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3714 */
Takashi Iwaia9111322011-05-02 11:30:18 +02003715static const struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003716 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003717 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3718 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3719 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3720 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3721
3722 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3723 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3724 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3725 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3726
3727 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3728 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003729 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003730 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3731 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3732 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3733 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3734 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3735 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003736
Takashi Iwai937b4162008-02-11 14:52:36 +01003737 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3738 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3739
Takashi Iwai16ded522005-06-10 19:58:24 +02003740 { }
3741};
3742
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003743/*
3744 * ASUS pin configuration:
3745 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3746 */
Takashi Iwaia9111322011-05-02 11:30:18 +02003747static const struct hda_verb alc880_pin_asus_init_verbs[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003748 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3749 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3750 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3751 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3752
3753 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3754 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3755 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3756 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3757 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3758 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3759 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3760 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3761
3762 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3763 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3764 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3765 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3766 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3767 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3768 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3769 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3770 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003771
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003772 { }
3773};
3774
3775/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003776#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3777#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003778#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003779
Kailang Yangdf694da2005-12-05 19:42:22 +01003780/* Clevo m520g init */
Takashi Iwaia9111322011-05-02 11:30:18 +02003781static const struct hda_verb alc880_pin_clevo_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01003782 /* headphone output */
3783 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3784 /* line-out */
3785 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3786 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3787 /* Line-in */
3788 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3789 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3790 /* CD */
3791 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3792 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3793 /* Mic1 (rear panel) */
3794 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3795 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3796 /* Mic2 (front panel) */
3797 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3798 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3799 /* headphone */
3800 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3801 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3802 /* change to EAPD mode */
3803 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3804 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3805
3806 { }
3807};
3808
Takashi Iwaia9111322011-05-02 11:30:18 +02003809static const struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003810 /* change to EAPD mode */
3811 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3812 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3813
Kailang Yangdf694da2005-12-05 19:42:22 +01003814 /* Headphone output */
3815 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3816 /* Front output*/
3817 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3818 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3819
3820 /* Line In pin widget for input */
3821 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3822 /* CD pin widget for input */
3823 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3824 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3825 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3826
3827 /* change to EAPD mode */
3828 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3829 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3830
3831 { }
3832};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003833
3834/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003835 * LG m1 express dual
3836 *
3837 * Pin assignment:
3838 * Rear Line-In/Out (blue): 0x14
3839 * Build-in Mic-In: 0x15
3840 * Speaker-out: 0x17
3841 * HP-Out (green): 0x1b
3842 * Mic-In/Out (red): 0x19
3843 * SPDIF-Out: 0x1e
3844 */
3845
3846/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02003847static const hda_nid_t alc880_lg_dac_nids[3] = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003848 0x05, 0x02, 0x03
3849};
3850
3851/* seems analog CD is not working */
Takashi Iwaia9111322011-05-02 11:30:18 +02003852static const struct hda_input_mux alc880_lg_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003853 .num_items = 3,
3854 .items = {
3855 { "Mic", 0x1 },
3856 { "Line", 0x5 },
3857 { "Internal Mic", 0x6 },
3858 },
3859};
3860
3861/* 2,4,6 channel modes */
Takashi Iwaia9111322011-05-02 11:30:18 +02003862static const struct hda_verb alc880_lg_ch2_init[] = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003863 /* set line-in and mic-in to input */
3864 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3865 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3866 { }
3867};
3868
Takashi Iwaia9111322011-05-02 11:30:18 +02003869static const struct hda_verb alc880_lg_ch4_init[] = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003870 /* set line-in to out and mic-in to input */
3871 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3872 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3873 { }
3874};
3875
Takashi Iwaia9111322011-05-02 11:30:18 +02003876static const struct hda_verb alc880_lg_ch6_init[] = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003877 /* set line-in and mic-in to output */
3878 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3879 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3880 { }
3881};
3882
Takashi Iwaia9111322011-05-02 11:30:18 +02003883static const struct hda_channel_mode alc880_lg_ch_modes[3] = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003884 { 2, alc880_lg_ch2_init },
3885 { 4, alc880_lg_ch4_init },
3886 { 6, alc880_lg_ch6_init },
3887};
3888
Takashi Iwaia9111322011-05-02 11:30:18 +02003889static const struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003890 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3891 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003892 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3893 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3894 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3895 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3896 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3897 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3898 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3899 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3900 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3901 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3902 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3903 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3904 {
3905 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3906 .name = "Channel Mode",
3907 .info = alc_ch_mode_info,
3908 .get = alc_ch_mode_get,
3909 .put = alc_ch_mode_put,
3910 },
3911 { } /* end */
3912};
3913
Takashi Iwaia9111322011-05-02 11:30:18 +02003914static const struct hda_verb alc880_lg_init_verbs[] = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003915 /* set capture source to mic-in */
3916 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3917 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3918 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3919 /* mute all amp mixer inputs */
3920 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003921 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3922 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003923 /* line-in to input */
3924 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3925 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3926 /* built-in mic */
3927 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3928 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3929 /* speaker-out */
3930 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3931 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3932 /* mic-in to input */
3933 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3934 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3935 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3936 /* HP-out */
3937 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3938 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3939 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3940 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003941 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003942 { }
3943};
3944
3945/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003946static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003947{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003948 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003949
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003950 spec->autocfg.hp_pins[0] = 0x1b;
3951 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02003952 spec->automute = 1;
3953 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003954}
3955
3956/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003957 * LG LW20
3958 *
3959 * Pin assignment:
3960 * Speaker-out: 0x14
3961 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003962 * Built-in Mic-In: 0x19
3963 * Line-In: 0x1b
3964 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003965 * SPDIF-Out: 0x1e
3966 */
3967
Takashi Iwaia9111322011-05-02 11:30:18 +02003968static const struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003969 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003970 .items = {
3971 { "Mic", 0x0 },
3972 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003973 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003974 },
3975};
3976
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003977#define alc880_lg_lw_modes alc880_threestack_modes
3978
Takashi Iwaia9111322011-05-02 11:30:18 +02003979static const struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003980 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3981 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3982 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3983 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3984 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3985 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3986 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3987 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3988 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3989 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003990 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3991 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3992 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3993 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003994 {
3995 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3996 .name = "Channel Mode",
3997 .info = alc_ch_mode_info,
3998 .get = alc_ch_mode_get,
3999 .put = alc_ch_mode_put,
4000 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004001 { } /* end */
4002};
4003
Takashi Iwaia9111322011-05-02 11:30:18 +02004004static const struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004005 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
4006 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
4007 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
4008
Takashi Iwaid6815182006-03-23 16:06:23 +01004009 /* set capture source to mic-in */
4010 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4011 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4012 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02004013 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01004014 /* speaker-out */
4015 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4016 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4017 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01004018 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4019 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4020 /* mic-in to input */
4021 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4022 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4023 /* built-in mic */
4024 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4025 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4026 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004027 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01004028 { }
4029};
4030
4031/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004032static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01004033{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004034 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01004035
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004036 spec->autocfg.hp_pins[0] = 0x1b;
4037 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +02004038 spec->automute = 1;
4039 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwaid6815182006-03-23 16:06:23 +01004040}
4041
Takashi Iwaia9111322011-05-02 11:30:18 +02004042static const struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004043 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4044 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
4045 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4046 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4047 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4048 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
4049 { } /* end */
4050};
4051
Takashi Iwaia9111322011-05-02 11:30:18 +02004052static const struct hda_input_mux alc880_medion_rim_capture_source = {
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004053 .num_items = 2,
4054 .items = {
4055 { "Mic", 0x0 },
4056 { "Internal Mic", 0x1 },
4057 },
4058};
4059
Takashi Iwaia9111322011-05-02 11:30:18 +02004060static const struct hda_verb alc880_medion_rim_init_verbs[] = {
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004061 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
4062
4063 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4064 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4065
4066 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4067 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4068 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4069 /* Mic2 (as headphone out) for HP output */
4070 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4071 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4072 /* Internal Speaker */
4073 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4074 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4075
4076 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
4077 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
4078
4079 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4080 { }
4081};
4082
4083/* toggle speaker-output according to the hp-jack state */
4084static void alc880_medion_rim_automute(struct hda_codec *codec)
4085{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004086 struct alc_spec *spec = codec->spec;
Takashi Iwaid922b512011-04-28 12:18:53 +02004087 alc_hp_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004088 /* toggle EAPD */
4089 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004090 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
4091 else
4092 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
4093}
4094
4095static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
4096 unsigned int res)
4097{
4098 /* Looks like the unsol event is incompatible with the standard
4099 * definition. 4bit tag is placed at 28 bit!
4100 */
4101 if ((res >> 28) == ALC880_HP_EVENT)
4102 alc880_medion_rim_automute(codec);
4103}
4104
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004105static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004106{
4107 struct alc_spec *spec = codec->spec;
4108
4109 spec->autocfg.hp_pins[0] = 0x14;
4110 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaid922b512011-04-28 12:18:53 +02004111 spec->automute = 1;
4112 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004113}
4114
Takashi Iwaicb53c622007-08-10 17:21:45 +02004115#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaia9111322011-05-02 11:30:18 +02004116static const struct hda_amp_list alc880_loopbacks[] = {
Takashi Iwaicb53c622007-08-10 17:21:45 +02004117 { 0x0b, HDA_INPUT, 0 },
4118 { 0x0b, HDA_INPUT, 1 },
4119 { 0x0b, HDA_INPUT, 2 },
4120 { 0x0b, HDA_INPUT, 3 },
4121 { 0x0b, HDA_INPUT, 4 },
4122 { } /* end */
4123};
4124
Takashi Iwaia9111322011-05-02 11:30:18 +02004125static const struct hda_amp_list alc880_lg_loopbacks[] = {
Takashi Iwaicb53c622007-08-10 17:21:45 +02004126 { 0x0b, HDA_INPUT, 1 },
4127 { 0x0b, HDA_INPUT, 6 },
4128 { 0x0b, HDA_INPUT, 7 },
4129 { } /* end */
4130};
4131#endif
4132
Takashi Iwaid6815182006-03-23 16:06:23 +01004133/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004134 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004135 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004136
Takashi Iwai584c0c42011-03-10 12:51:11 +01004137static void alc_init_special_input_src(struct hda_codec *codec);
4138
Linus Torvalds1da177e2005-04-16 15:20:36 -07004139static int alc_init(struct hda_codec *codec)
4140{
4141 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004142 unsigned int i;
4143
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02004144 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004145 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02004146
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004147 for (i = 0; i < spec->num_init_verbs; i++)
4148 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwai584c0c42011-03-10 12:51:11 +01004149 alc_init_special_input_src(codec);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004150
4151 if (spec->init_hook)
4152 spec->init_hook(codec);
4153
Takashi Iwai58701122011-01-13 15:41:45 +01004154 alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT);
4155
Takashi Iwai9e5341b2010-09-21 09:57:06 +02004156 hda_call_check_power_status(codec, 0x01);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004157 return 0;
4158}
4159
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004160static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
4161{
4162 struct alc_spec *spec = codec->spec;
4163
4164 if (spec->unsol_event)
4165 spec->unsol_event(codec, res);
4166}
4167
Takashi Iwaicb53c622007-08-10 17:21:45 +02004168#ifdef CONFIG_SND_HDA_POWER_SAVE
4169static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
4170{
4171 struct alc_spec *spec = codec->spec;
4172 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
4173}
4174#endif
4175
Linus Torvalds1da177e2005-04-16 15:20:36 -07004176/*
4177 * Analog playback callbacks
4178 */
4179static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
4180 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004181 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004182{
4183 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01004184 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
4185 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004186}
4187
4188static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
4189 struct hda_codec *codec,
4190 unsigned int stream_tag,
4191 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004192 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004193{
4194 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004195 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
4196 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004197}
4198
4199static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
4200 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004201 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004202{
4203 struct alc_spec *spec = codec->spec;
4204 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
4205}
4206
4207/*
4208 * Digital out
4209 */
4210static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
4211 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004212 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004213{
4214 struct alc_spec *spec = codec->spec;
4215 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
4216}
4217
Takashi Iwai6b97eb42007-04-05 14:51:48 +02004218static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
4219 struct hda_codec *codec,
4220 unsigned int stream_tag,
4221 unsigned int format,
4222 struct snd_pcm_substream *substream)
4223{
4224 struct alc_spec *spec = codec->spec;
4225 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
4226 stream_tag, format, substream);
4227}
4228
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01004229static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
4230 struct hda_codec *codec,
4231 struct snd_pcm_substream *substream)
4232{
4233 struct alc_spec *spec = codec->spec;
4234 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
4235}
4236
Linus Torvalds1da177e2005-04-16 15:20:36 -07004237static int alc880_dig_playback_pcm_close(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_close(codec, &spec->multiout);
4243}
4244
4245/*
4246 * Analog capture
4247 */
Takashi Iwai63300792008-01-24 15:31:36 +01004248static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004249 struct hda_codec *codec,
4250 unsigned int stream_tag,
4251 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004252 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004253{
4254 struct alc_spec *spec = codec->spec;
4255
Takashi Iwai63300792008-01-24 15:31:36 +01004256 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07004257 stream_tag, 0, format);
4258 return 0;
4259}
4260
Takashi Iwai63300792008-01-24 15:31:36 +01004261static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004262 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004263 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004264{
4265 struct alc_spec *spec = codec->spec;
4266
Takashi Iwai888afa12008-03-18 09:57:50 +01004267 snd_hda_codec_cleanup_stream(codec,
4268 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004269 return 0;
4270}
4271
Takashi Iwai840b64c2010-07-13 22:49:01 +02004272/* analog capture with dynamic dual-adc changes */
4273static int dualmic_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
4274 struct hda_codec *codec,
4275 unsigned int stream_tag,
4276 unsigned int format,
4277 struct snd_pcm_substream *substream)
4278{
4279 struct alc_spec *spec = codec->spec;
4280 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
4281 spec->cur_adc_stream_tag = stream_tag;
4282 spec->cur_adc_format = format;
4283 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
4284 return 0;
4285}
4286
4287static int dualmic_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
4288 struct hda_codec *codec,
4289 struct snd_pcm_substream *substream)
4290{
4291 struct alc_spec *spec = codec->spec;
4292 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
4293 spec->cur_adc = 0;
4294 return 0;
4295}
4296
Takashi Iwaia9111322011-05-02 11:30:18 +02004297static const struct hda_pcm_stream dualmic_pcm_analog_capture = {
Takashi Iwai840b64c2010-07-13 22:49:01 +02004298 .substreams = 1,
4299 .channels_min = 2,
4300 .channels_max = 2,
4301 .nid = 0, /* fill later */
4302 .ops = {
4303 .prepare = dualmic_capture_pcm_prepare,
4304 .cleanup = dualmic_capture_pcm_cleanup
4305 },
4306};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004307
4308/*
4309 */
Takashi Iwaia9111322011-05-02 11:30:18 +02004310static const struct hda_pcm_stream alc880_pcm_analog_playback = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004311 .substreams = 1,
4312 .channels_min = 2,
4313 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004314 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004315 .ops = {
4316 .open = alc880_playback_pcm_open,
4317 .prepare = alc880_playback_pcm_prepare,
4318 .cleanup = alc880_playback_pcm_cleanup
4319 },
4320};
4321
Takashi Iwaia9111322011-05-02 11:30:18 +02004322static const struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01004323 .substreams = 1,
4324 .channels_min = 2,
4325 .channels_max = 2,
4326 /* NID is set in alc_build_pcms */
4327};
4328
Takashi Iwaia9111322011-05-02 11:30:18 +02004329static const struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
Takashi Iwai63300792008-01-24 15:31:36 +01004330 .substreams = 1,
4331 .channels_min = 2,
4332 .channels_max = 2,
4333 /* NID is set in alc_build_pcms */
4334};
4335
Takashi Iwaia9111322011-05-02 11:30:18 +02004336static const struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01004337 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004338 .channels_min = 2,
4339 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004340 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004341 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01004342 .prepare = alc880_alt_capture_pcm_prepare,
4343 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004344 },
4345};
4346
Takashi Iwaia9111322011-05-02 11:30:18 +02004347static const struct hda_pcm_stream alc880_pcm_digital_playback = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004348 .substreams = 1,
4349 .channels_min = 2,
4350 .channels_max = 2,
4351 /* NID is set in alc_build_pcms */
4352 .ops = {
4353 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02004354 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01004355 .prepare = alc880_dig_playback_pcm_prepare,
4356 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004357 },
4358};
4359
Takashi Iwaia9111322011-05-02 11:30:18 +02004360static const struct hda_pcm_stream alc880_pcm_digital_capture = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004361 .substreams = 1,
4362 .channels_min = 2,
4363 .channels_max = 2,
4364 /* NID is set in alc_build_pcms */
4365};
4366
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004367/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwaia9111322011-05-02 11:30:18 +02004368static const struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004369 .substreams = 0,
4370 .channels_min = 0,
4371 .channels_max = 0,
4372};
4373
Linus Torvalds1da177e2005-04-16 15:20:36 -07004374static int alc_build_pcms(struct hda_codec *codec)
4375{
4376 struct alc_spec *spec = codec->spec;
4377 struct hda_pcm *info = spec->pcm_rec;
4378 int i;
4379
4380 codec->num_pcms = 1;
4381 codec->pcm_info = info;
4382
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004383 if (spec->no_analog)
4384 goto skip_analog;
4385
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004386 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
4387 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004388 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01004389
Takashi Iwai4a471b72005-12-07 13:56:29 +01004390 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004391 if (snd_BUG_ON(!spec->multiout.dac_nids))
4392 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004393 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
4394 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
4395 }
4396 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004397 if (snd_BUG_ON(!spec->adc_nids))
4398 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004399 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
4400 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
4401 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004402
Takashi Iwai4a471b72005-12-07 13:56:29 +01004403 if (spec->channel_mode) {
4404 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
4405 for (i = 0; i < spec->num_channel_mode; i++) {
4406 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
4407 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
4408 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004409 }
4410 }
4411
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004412 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02004413 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004414 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004415 snprintf(spec->stream_name_digital,
4416 sizeof(spec->stream_name_digital),
4417 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02004418 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08004419 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004420 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004421 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01004422 if (spec->dig_out_type)
4423 info->pcm_type = spec->dig_out_type;
4424 else
4425 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004426 if (spec->multiout.dig_out_nid &&
4427 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004428 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
4429 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
4430 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004431 if (spec->dig_in_nid &&
4432 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004433 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
4434 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
4435 }
Takashi Iwai963f8032008-08-11 10:04:40 +02004436 /* FIXME: do we need this for all Realtek codec models? */
4437 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004438 }
4439
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004440 if (spec->no_analog)
4441 return 0;
4442
Takashi Iwaie08a0072006-09-07 17:52:14 +02004443 /* If the use of more than one ADC is requested for the current
4444 * model, configure a second analog capture-only PCM.
4445 */
4446 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01004447 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
4448 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02004449 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004450 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004451 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01004452 if (spec->alt_dac_nid) {
4453 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4454 *spec->stream_analog_alt_playback;
4455 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
4456 spec->alt_dac_nid;
4457 } else {
4458 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4459 alc_pcm_null_stream;
4460 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
4461 }
Raymond Yauce85c9a2011-05-03 13:33:53 +08004462 if (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture) {
Takashi Iwai63300792008-01-24 15:31:36 +01004463 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4464 *spec->stream_analog_alt_capture;
4465 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
4466 spec->adc_nids[1];
4467 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
4468 spec->num_adc_nids - 1;
4469 } else {
4470 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4471 alc_pcm_null_stream;
4472 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004473 }
4474 }
4475
Linus Torvalds1da177e2005-04-16 15:20:36 -07004476 return 0;
4477}
4478
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004479static inline void alc_shutup(struct hda_codec *codec)
4480{
Takashi Iwai1c7161532011-04-07 10:37:16 +02004481 struct alc_spec *spec = codec->spec;
4482
4483 if (spec && spec->shutup)
4484 spec->shutup(codec);
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004485 snd_hda_shutup_pins(codec);
4486}
4487
Takashi Iwai603c4012008-07-30 15:01:44 +02004488static void alc_free_kctls(struct hda_codec *codec)
4489{
4490 struct alc_spec *spec = codec->spec;
4491
4492 if (spec->kctls.list) {
4493 struct snd_kcontrol_new *kctl = spec->kctls.list;
4494 int i;
4495 for (i = 0; i < spec->kctls.used; i++)
4496 kfree(kctl[i].name);
4497 }
4498 snd_array_free(&spec->kctls);
4499}
4500
Linus Torvalds1da177e2005-04-16 15:20:36 -07004501static void alc_free(struct hda_codec *codec)
4502{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004503 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004504
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004505 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004506 return;
4507
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004508 alc_shutup(codec);
Takashi Iwaicd372fb2011-03-03 14:40:14 +01004509 snd_hda_input_jack_free(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02004510 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004511 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004512 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004513}
4514
Hector Martinf5de24b2009-12-20 22:51:31 +01004515#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05004516static void alc_power_eapd(struct hda_codec *codec)
4517{
Takashi Iwai691f1fc2011-04-07 10:31:43 +02004518 alc_auto_setup_eapd(codec, false);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004519}
4520
Hector Martinf5de24b2009-12-20 22:51:31 +01004521static int alc_suspend(struct hda_codec *codec, pm_message_t state)
4522{
4523 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004524 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004525 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05004526 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004527 return 0;
4528}
4529#endif
4530
Takashi Iwaie044c392008-10-27 16:56:24 +01004531#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01004532static int alc_resume(struct hda_codec *codec)
4533{
Takashi Iwai1c7161532011-04-07 10:37:16 +02004534 msleep(150); /* to avoid pop noise */
Takashi Iwaie044c392008-10-27 16:56:24 +01004535 codec->patch_ops.init(codec);
4536 snd_hda_codec_resume_amp(codec);
4537 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +02004538 hda_call_check_power_status(codec, 0x01);
Takashi Iwaie044c392008-10-27 16:56:24 +01004539 return 0;
4540}
Takashi Iwaie044c392008-10-27 16:56:24 +01004541#endif
4542
Linus Torvalds1da177e2005-04-16 15:20:36 -07004543/*
4544 */
Takashi Iwaia9111322011-05-02 11:30:18 +02004545static const struct hda_codec_ops alc_patch_ops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004546 .build_controls = alc_build_controls,
4547 .build_pcms = alc_build_pcms,
4548 .init = alc_init,
4549 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004550 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01004551#ifdef SND_HDA_NEEDS_RESUME
4552 .resume = alc_resume,
4553#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02004554#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01004555 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004556 .check_power_status = alc_check_power_status,
4557#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05004558 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004559};
4560
Kailang Yangc027ddc2010-03-19 11:33:06 +01004561/* replace the codec chip_name with the given string */
4562static int alc_codec_rename(struct hda_codec *codec, const char *name)
4563{
4564 kfree(codec->chip_name);
4565 codec->chip_name = kstrdup(name, GFP_KERNEL);
4566 if (!codec->chip_name) {
4567 alc_free(codec);
4568 return -ENOMEM;
4569 }
4570 return 0;
4571}
4572
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004573/*
4574 * Test configuration for debugging
4575 *
4576 * Almost all inputs/outputs are enabled. I/O pins can be configured via
4577 * enum controls.
4578 */
4579#ifdef CONFIG_SND_DEBUG
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02004580static const hda_nid_t alc880_test_dac_nids[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004581 0x02, 0x03, 0x04, 0x05
4582};
4583
Takashi Iwaia9111322011-05-02 11:30:18 +02004584static const struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004585 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004586 .items = {
4587 { "In-1", 0x0 },
4588 { "In-2", 0x1 },
4589 { "In-3", 0x2 },
4590 { "In-4", 0x3 },
4591 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004592 { "Front", 0x5 },
4593 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004594 },
4595};
4596
Takashi Iwaia9111322011-05-02 11:30:18 +02004597static const struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004598 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004599 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004600 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004601 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004602};
4603
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004604static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
4605 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004606{
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02004607 static const char * const texts[] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004608 "N/A", "Line Out", "HP Out",
4609 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
4610 };
4611 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4612 uinfo->count = 1;
4613 uinfo->value.enumerated.items = 8;
4614 if (uinfo->value.enumerated.item >= 8)
4615 uinfo->value.enumerated.item = 7;
4616 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4617 return 0;
4618}
4619
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004620static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
4621 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004622{
4623 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4624 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4625 unsigned int pin_ctl, item = 0;
4626
4627 pin_ctl = snd_hda_codec_read(codec, nid, 0,
4628 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4629 if (pin_ctl & AC_PINCTL_OUT_EN) {
4630 if (pin_ctl & AC_PINCTL_HP_EN)
4631 item = 2;
4632 else
4633 item = 1;
4634 } else if (pin_ctl & AC_PINCTL_IN_EN) {
4635 switch (pin_ctl & AC_PINCTL_VREFEN) {
4636 case AC_PINCTL_VREF_HIZ: item = 3; break;
4637 case AC_PINCTL_VREF_50: item = 4; break;
4638 case AC_PINCTL_VREF_GRD: item = 5; break;
4639 case AC_PINCTL_VREF_80: item = 6; break;
4640 case AC_PINCTL_VREF_100: item = 7; break;
4641 }
4642 }
4643 ucontrol->value.enumerated.item[0] = item;
4644 return 0;
4645}
4646
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004647static int alc_test_pin_ctl_put(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;
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02004652 static const unsigned int ctls[] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004653 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
4654 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
4655 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
4656 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
4657 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
4658 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
4659 };
4660 unsigned int old_ctl, new_ctl;
4661
4662 old_ctl = snd_hda_codec_read(codec, nid, 0,
4663 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4664 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
4665 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004666 int val;
4667 snd_hda_codec_write_cache(codec, nid, 0,
4668 AC_VERB_SET_PIN_WIDGET_CONTROL,
4669 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02004670 val = ucontrol->value.enumerated.item[0] >= 3 ?
4671 HDA_AMP_MUTE : 0;
4672 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
4673 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004674 return 1;
4675 }
4676 return 0;
4677}
4678
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004679static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
4680 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004681{
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02004682 static const char * const texts[] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004683 "Front", "Surround", "CLFE", "Side"
4684 };
4685 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4686 uinfo->count = 1;
4687 uinfo->value.enumerated.items = 4;
4688 if (uinfo->value.enumerated.item >= 4)
4689 uinfo->value.enumerated.item = 3;
4690 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4691 return 0;
4692}
4693
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004694static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
4695 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004696{
4697 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4698 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4699 unsigned int sel;
4700
4701 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4702 ucontrol->value.enumerated.item[0] = sel & 3;
4703 return 0;
4704}
4705
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004706static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4707 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004708{
4709 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4710 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4711 unsigned int sel;
4712
4713 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4714 if (ucontrol->value.enumerated.item[0] != sel) {
4715 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004716 snd_hda_codec_write_cache(codec, nid, 0,
4717 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004718 return 1;
4719 }
4720 return 0;
4721}
4722
4723#define PIN_CTL_TEST(xname,nid) { \
4724 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4725 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004726 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004727 .info = alc_test_pin_ctl_info, \
4728 .get = alc_test_pin_ctl_get, \
4729 .put = alc_test_pin_ctl_put, \
4730 .private_value = nid \
4731 }
4732
4733#define PIN_SRC_TEST(xname,nid) { \
4734 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4735 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004736 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004737 .info = alc_test_pin_src_info, \
4738 .get = alc_test_pin_src_get, \
4739 .put = alc_test_pin_src_put, \
4740 .private_value = nid \
4741 }
4742
Takashi Iwaia9111322011-05-02 11:30:18 +02004743static const struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004744 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4745 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4746 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4747 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004748 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4749 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4750 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4751 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004752 PIN_CTL_TEST("Front Pin Mode", 0x14),
4753 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4754 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4755 PIN_CTL_TEST("Side Pin Mode", 0x17),
4756 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4757 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4758 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4759 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4760 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4761 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4762 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4763 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4764 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4765 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4766 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4767 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4768 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4769 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4770 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4771 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4772 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4773 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004774 {
4775 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4776 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004777 .info = alc_ch_mode_info,
4778 .get = alc_ch_mode_get,
4779 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004780 },
4781 { } /* end */
4782};
4783
Takashi Iwaia9111322011-05-02 11:30:18 +02004784static const struct hda_verb alc880_test_init_verbs[] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004785 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004786 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4787 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4788 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4789 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4790 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4791 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4792 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4793 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004794 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004795 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4796 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4797 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4798 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004799 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004800 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4801 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4802 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4803 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004804 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004805 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4806 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4807 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4808 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004809 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004810 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4811 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004812 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4813 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4814 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004815 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004816 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4817 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4818 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4819 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004820 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004821 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004822 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004823 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004824 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004825 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004826 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004827 /* Analog input/passthru */
4828 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4829 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4830 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4831 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4832 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004833 { }
4834};
4835#endif
4836
Linus Torvalds1da177e2005-04-16 15:20:36 -07004837/*
4838 */
4839
Takashi Iwaiea734962011-01-17 11:29:34 +01004840static const char * const alc880_models[ALC880_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004841 [ALC880_3ST] = "3stack",
4842 [ALC880_TCL_S700] = "tcl",
4843 [ALC880_3ST_DIG] = "3stack-digout",
4844 [ALC880_CLEVO] = "clevo",
4845 [ALC880_5ST] = "5stack",
4846 [ALC880_5ST_DIG] = "5stack-digout",
4847 [ALC880_W810] = "w810",
4848 [ALC880_Z71V] = "z71v",
4849 [ALC880_6ST] = "6stack",
4850 [ALC880_6ST_DIG] = "6stack-digout",
4851 [ALC880_ASUS] = "asus",
4852 [ALC880_ASUS_W1V] = "asus-w1v",
4853 [ALC880_ASUS_DIG] = "asus-dig",
4854 [ALC880_ASUS_DIG2] = "asus-dig2",
4855 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004856 [ALC880_UNIWILL_P53] = "uniwill-p53",
4857 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004858 [ALC880_F1734] = "F1734",
4859 [ALC880_LG] = "lg",
4860 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004861 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004862#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004863 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004864#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004865 [ALC880_AUTO] = "auto",
4866};
4867
Takashi Iwaia9111322011-05-02 11:30:18 +02004868static const struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004869 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004870 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4871 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4872 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4873 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4874 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4875 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4876 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4877 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004878 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4879 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004880 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4881 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4882 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4883 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4884 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4885 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4886 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4887 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4888 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4889 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004890 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004891 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4892 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4893 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004894 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004895 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004896 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4897 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004898 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4899 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004900 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4901 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4902 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4903 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004904 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4905 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004906 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004907 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004908 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Justin P. Mattocka2e2bc22011-02-24 22:16:02 -08004909 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004910 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4911 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004912 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004913 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004914 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004915 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004916 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004917 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Daniel T Chen33535412010-04-22 07:15:26 -04004918 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004919 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004920 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004921 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
Daniel T Chen77c4d5c2010-12-02 22:45:45 -05004922 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004923 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004924 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004925 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4926 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4927 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4928 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004929 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4930 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004931 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004932 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004933 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4934 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004935 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4936 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4937 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004938 /* default Intel */
4939 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004940 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4941 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004942 {}
4943};
4944
Takashi Iwai16ded522005-06-10 19:58:24 +02004945/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004946 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004947 */
Takashi Iwaia9111322011-05-02 11:30:18 +02004948static const struct alc_config_preset alc880_presets[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02004949 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004950 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004951 .init_verbs = { alc880_volume_init_verbs,
4952 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004953 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004954 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004955 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4956 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004957 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004958 .input_mux = &alc880_capture_source,
4959 },
4960 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004961 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004962 .init_verbs = { alc880_volume_init_verbs,
4963 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004964 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004965 .dac_nids = alc880_dac_nids,
4966 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004967 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4968 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004969 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004970 .input_mux = &alc880_capture_source,
4971 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004972 [ALC880_TCL_S700] = {
4973 .mixers = { alc880_tcl_s700_mixer },
4974 .init_verbs = { alc880_volume_init_verbs,
4975 alc880_pin_tcl_S700_init_verbs,
4976 alc880_gpio2_init_verbs },
4977 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4978 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004979 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4980 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004981 .hp_nid = 0x03,
4982 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4983 .channel_mode = alc880_2_jack_modes,
4984 .input_mux = &alc880_capture_source,
4985 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004986 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004987 .mixers = { alc880_three_stack_mixer,
4988 alc880_five_stack_mixer},
4989 .init_verbs = { alc880_volume_init_verbs,
4990 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004991 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4992 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004993 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4994 .channel_mode = alc880_fivestack_modes,
4995 .input_mux = &alc880_capture_source,
4996 },
4997 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004998 .mixers = { alc880_three_stack_mixer,
4999 alc880_five_stack_mixer },
5000 .init_verbs = { alc880_volume_init_verbs,
5001 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02005002 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
5003 .dac_nids = alc880_dac_nids,
5004 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02005005 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
5006 .channel_mode = alc880_fivestack_modes,
5007 .input_mux = &alc880_capture_source,
5008 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02005009 [ALC880_6ST] = {
5010 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005011 .init_verbs = { alc880_volume_init_verbs,
5012 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02005013 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
5014 .dac_nids = alc880_6st_dac_nids,
5015 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
5016 .channel_mode = alc880_sixstack_modes,
5017 .input_mux = &alc880_6stack_capture_source,
5018 },
Takashi Iwai16ded522005-06-10 19:58:24 +02005019 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005020 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005021 .init_verbs = { alc880_volume_init_verbs,
5022 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02005023 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
5024 .dac_nids = alc880_6st_dac_nids,
5025 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02005026 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
5027 .channel_mode = alc880_sixstack_modes,
5028 .input_mux = &alc880_6stack_capture_source,
5029 },
5030 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005031 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005032 .init_verbs = { alc880_volume_init_verbs,
5033 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02005034 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02005035 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
5036 .dac_nids = alc880_w810_dac_nids,
5037 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02005038 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
5039 .channel_mode = alc880_w810_modes,
5040 .input_mux = &alc880_capture_source,
5041 },
5042 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005043 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005044 .init_verbs = { alc880_volume_init_verbs,
5045 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02005046 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
5047 .dac_nids = alc880_z71v_dac_nids,
5048 .dig_out_nid = ALC880_DIGOUT_NID,
5049 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005050 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
5051 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02005052 .input_mux = &alc880_capture_source,
5053 },
5054 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005055 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005056 .init_verbs = { alc880_volume_init_verbs,
5057 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005058 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
5059 .dac_nids = alc880_f1734_dac_nids,
5060 .hp_nid = 0x02,
5061 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
5062 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01005063 .input_mux = &alc880_f1734_capture_source,
5064 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02005065 .setup = alc880_uniwill_p53_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +02005066 .init_hook = alc_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02005067 },
5068 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005069 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005070 .init_verbs = { alc880_volume_init_verbs,
5071 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005072 alc880_gpio1_init_verbs },
5073 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
5074 .dac_nids = alc880_asus_dac_nids,
5075 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
5076 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005077 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02005078 .input_mux = &alc880_capture_source,
5079 },
5080 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005081 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005082 .init_verbs = { alc880_volume_init_verbs,
5083 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005084 alc880_gpio1_init_verbs },
5085 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
5086 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02005087 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005088 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
5089 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005090 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02005091 .input_mux = &alc880_capture_source,
5092 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005093 [ALC880_ASUS_DIG2] = {
5094 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005095 .init_verbs = { alc880_volume_init_verbs,
5096 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01005097 alc880_gpio2_init_verbs }, /* use GPIO2 */
5098 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
5099 .dac_nids = alc880_asus_dac_nids,
5100 .dig_out_nid = ALC880_DIGOUT_NID,
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,
Kailang Yangdf694da2005-12-05 19:42:22 +01005104 .input_mux = &alc880_capture_source,
5105 },
Takashi Iwai16ded522005-06-10 19:58:24 +02005106 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005107 .mixers = { alc880_asus_mixer, alc880_asus_w1v_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 },
5119 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005120 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02005121 .init_verbs = { alc880_volume_init_verbs,
5122 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005123 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
5124 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02005125 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005126 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
5127 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005128 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02005129 .input_mux = &alc880_capture_source,
5130 },
Kailang Yangccc656c2006-10-17 12:32:26 +02005131 [ALC880_UNIWILL] = {
5132 .mixers = { alc880_uniwill_mixer },
5133 .init_verbs = { alc880_volume_init_verbs,
5134 alc880_uniwill_init_verbs },
5135 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
5136 .dac_nids = alc880_asus_dac_nids,
5137 .dig_out_nid = ALC880_DIGOUT_NID,
5138 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5139 .channel_mode = alc880_threestack_modes,
5140 .need_dac_fix = 1,
5141 .input_mux = &alc880_capture_source,
5142 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02005143 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02005144 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02005145 },
5146 [ALC880_UNIWILL_P53] = {
5147 .mixers = { alc880_uniwill_p53_mixer },
5148 .init_verbs = { alc880_volume_init_verbs,
5149 alc880_uniwill_p53_init_verbs },
5150 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
5151 .dac_nids = alc880_asus_dac_nids,
5152 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01005153 .channel_mode = alc880_threestack_modes,
5154 .input_mux = &alc880_capture_source,
5155 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02005156 .setup = alc880_uniwill_p53_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +02005157 .init_hook = alc_hp_automute,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01005158 },
5159 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005160 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01005161 .init_verbs = { alc880_volume_init_verbs,
5162 alc880_uniwill_p53_init_verbs,
5163 alc880_beep_init_verbs },
5164 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
5165 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02005166 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01005167 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
5168 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02005169 .input_mux = &alc880_capture_source,
5170 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02005171 .setup = alc880_uniwill_p53_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +02005172 .init_hook = alc_hp_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02005173 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005174 [ALC880_CLEVO] = {
5175 .mixers = { alc880_three_stack_mixer },
5176 .init_verbs = { alc880_volume_init_verbs,
5177 alc880_pin_clevo_init_verbs },
5178 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
5179 .dac_nids = alc880_dac_nids,
5180 .hp_nid = 0x03,
5181 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5182 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005183 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01005184 .input_mux = &alc880_capture_source,
5185 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005186 [ALC880_LG] = {
5187 .mixers = { alc880_lg_mixer },
5188 .init_verbs = { alc880_volume_init_verbs,
5189 alc880_lg_init_verbs },
5190 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
5191 .dac_nids = alc880_lg_dac_nids,
5192 .dig_out_nid = ALC880_DIGOUT_NID,
5193 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
5194 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005195 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005196 .input_mux = &alc880_lg_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +02005197 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02005198 .setup = alc880_lg_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +02005199 .init_hook = alc_hp_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02005200#ifdef CONFIG_SND_HDA_POWER_SAVE
5201 .loopbacks = alc880_lg_loopbacks,
5202#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005203 },
Takashi Iwaid6815182006-03-23 16:06:23 +01005204 [ALC880_LG_LW] = {
5205 .mixers = { alc880_lg_lw_mixer },
5206 .init_verbs = { alc880_volume_init_verbs,
5207 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02005208 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01005209 .dac_nids = alc880_dac_nids,
5210 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02005211 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
5212 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01005213 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +02005214 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02005215 .setup = alc880_lg_lw_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +02005216 .init_hook = alc_hp_automute,
Takashi Iwaid6815182006-03-23 16:06:23 +01005217 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02005218 [ALC880_MEDION_RIM] = {
5219 .mixers = { alc880_medion_rim_mixer },
5220 .init_verbs = { alc880_volume_init_verbs,
5221 alc880_medion_rim_init_verbs,
5222 alc_gpio2_init_verbs },
5223 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
5224 .dac_nids = alc880_dac_nids,
5225 .dig_out_nid = ALC880_DIGOUT_NID,
5226 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
5227 .channel_mode = alc880_2_jack_modes,
5228 .input_mux = &alc880_medion_rim_capture_source,
5229 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02005230 .setup = alc880_medion_rim_setup,
5231 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02005232 },
Takashi Iwai16ded522005-06-10 19:58:24 +02005233#ifdef CONFIG_SND_DEBUG
5234 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005235 .mixers = { alc880_test_mixer },
5236 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02005237 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
5238 .dac_nids = alc880_test_dac_nids,
5239 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02005240 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
5241 .channel_mode = alc880_test_modes,
5242 .input_mux = &alc880_test_capture_source,
5243 },
5244#endif
5245};
5246
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005247/*
5248 * Automatic parse of I/O pins from the BIOS configuration
5249 */
5250
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005251enum {
5252 ALC_CTL_WIDGET_VOL,
5253 ALC_CTL_WIDGET_MUTE,
5254 ALC_CTL_BIND_MUTE,
5255};
Takashi Iwaia9111322011-05-02 11:30:18 +02005256static const struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005257 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
5258 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01005259 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005260};
5261
Takashi Iwaice764ab2011-04-27 16:35:23 +02005262static struct snd_kcontrol_new *alc_kcontrol_new(struct alc_spec *spec)
5263{
5264 snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32);
5265 return snd_array_new(&spec->kctls);
5266}
5267
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005268/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005269static int add_control(struct alc_spec *spec, int type, const char *name,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005270 int cidx, unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005271{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005272 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005273
Takashi Iwaice764ab2011-04-27 16:35:23 +02005274 knew = alc_kcontrol_new(spec);
Takashi Iwai603c4012008-07-30 15:01:44 +02005275 if (!knew)
5276 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005277 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07005278 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005279 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005280 return -ENOMEM;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005281 knew->index = cidx;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01005282 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01005283 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005284 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005285 return 0;
5286}
5287
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005288static int add_control_with_pfx(struct alc_spec *spec, int type,
5289 const char *pfx, const char *dir,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005290 const char *sfx, int cidx, unsigned long val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005291{
5292 char name[32];
5293 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005294 return add_control(spec, type, name, cidx, val);
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005295}
5296
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005297#define add_pb_vol_ctrl(spec, type, pfx, val) \
5298 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
5299#define add_pb_sw_ctrl(spec, type, pfx, val) \
5300 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
5301#define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
5302 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
5303#define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
5304 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005305
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005306#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
5307#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
5308#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
5309#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005310#define alc880_idx_to_dac(nid) ((nid) + 0x02)
5311#define alc880_dac_to_idx(nid) ((nid) - 0x02)
5312#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
5313#define alc880_idx_to_selector(nid) ((nid) + 0x10)
5314#define ALC880_PIN_CD_NID 0x1c
5315
5316/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005317static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
5318 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005319{
5320 hda_nid_t nid;
5321 int assigned[4];
5322 int i, j;
5323
5324 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02005325 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005326
5327 /* check the pins hardwired to audio widget */
5328 for (i = 0; i < cfg->line_outs; i++) {
5329 nid = cfg->line_out_pins[i];
5330 if (alc880_is_fixed_pin(nid)) {
5331 int idx = alc880_fixed_pin_idx(nid);
Takashi Iwaidda14412011-05-02 11:29:30 +02005332 spec->private_dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005333 assigned[idx] = 1;
5334 }
5335 }
5336 /* left pins can be connect to any audio widget */
5337 for (i = 0; i < cfg->line_outs; i++) {
5338 nid = cfg->line_out_pins[i];
5339 if (alc880_is_fixed_pin(nid))
5340 continue;
5341 /* search for an empty channel */
5342 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005343 if (!assigned[j]) {
Takashi Iwaidda14412011-05-02 11:29:30 +02005344 spec->private_dac_nids[i] =
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005345 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005346 assigned[j] = 1;
5347 break;
5348 }
5349 }
5350 }
5351 spec->multiout.num_dacs = cfg->line_outs;
5352 return 0;
5353}
5354
Takashi Iwaice764ab2011-04-27 16:35:23 +02005355static const char *alc_get_line_out_pfx(struct alc_spec *spec,
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005356 bool can_be_master)
5357{
Takashi Iwaice764ab2011-04-27 16:35:23 +02005358 struct auto_pin_cfg *cfg = &spec->autocfg;
5359
5360 if (cfg->line_outs == 1 && !spec->multi_ios &&
5361 !cfg->hp_outs && !cfg->speaker_outs && can_be_master)
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005362 return "Master";
5363
5364 switch (cfg->line_out_type) {
5365 case AUTO_PIN_SPEAKER_OUT:
David Henningssonebbeb3d2011-03-04 14:08:30 +01005366 if (cfg->line_outs == 1)
5367 return "Speaker";
5368 break;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005369 case AUTO_PIN_HP_OUT:
5370 return "Headphone";
5371 default:
Takashi Iwaice764ab2011-04-27 16:35:23 +02005372 if (cfg->line_outs == 1 && !spec->multi_ios)
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005373 return "PCM";
5374 break;
5375 }
5376 return NULL;
5377}
5378
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005379/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01005380static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
5381 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005382{
Takashi Iwaiea734962011-01-17 11:29:34 +01005383 static const char * const chname[4] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005384 "Front", "Surround", NULL /*CLFE*/, "Side"
5385 };
Takashi Iwaice764ab2011-04-27 16:35:23 +02005386 const char *pfx = alc_get_line_out_pfx(spec, false);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005387 hda_nid_t nid;
Takashi Iwaice764ab2011-04-27 16:35:23 +02005388 int i, err, noutputs;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005389
Takashi Iwaice764ab2011-04-27 16:35:23 +02005390 noutputs = cfg->line_outs;
5391 if (spec->multi_ios > 0)
5392 noutputs += spec->multi_ios;
5393
5394 for (i = 0; i < noutputs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005395 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005396 continue;
5397 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005398 if (!pfx && i == 2) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005399 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005400 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5401 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005402 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
5403 HDA_OUTPUT));
5404 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005405 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005406 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5407 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005408 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
5409 HDA_OUTPUT));
5410 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005411 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005412 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5413 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005414 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
5415 HDA_INPUT));
5416 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005417 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005418 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5419 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005420 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
5421 HDA_INPUT));
5422 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005423 return err;
5424 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005425 const char *name = pfx;
David Henningsson7e59e092011-03-04 14:22:25 +01005426 int index = i;
5427 if (!name) {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005428 name = chname[i];
David Henningsson7e59e092011-03-04 14:22:25 +01005429 index = 0;
5430 }
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005431 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
David Henningsson7e59e092011-03-04 14:22:25 +01005432 name, index,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005433 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
5434 HDA_OUTPUT));
5435 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005436 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005437 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
David Henningsson7e59e092011-03-04 14:22:25 +01005438 name, index,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005439 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
5440 HDA_INPUT));
5441 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005442 return err;
5443 }
5444 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005445 return 0;
5446}
5447
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005448/* add playback controls for speaker and HP outputs */
5449static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
5450 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005451{
5452 hda_nid_t nid;
5453 int err;
5454
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005455 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005456 return 0;
5457
5458 if (alc880_is_fixed_pin(pin)) {
5459 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01005460 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005461 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005462 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005463 else
5464 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005465 /* control HP volume/switch on the output mixer amp */
5466 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005467 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005468 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
5469 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005470 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005471 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005472 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
5473 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005474 return err;
5475 } else if (alc880_is_multi_pin(pin)) {
5476 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005477 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005478 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005479 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
5480 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005481 return err;
5482 }
5483 return 0;
5484}
5485
5486/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005487static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005488 const char *ctlname, int ctlidx,
Kailang Yangdf694da2005-12-05 19:42:22 +01005489 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005490{
Kailang Yangdf694da2005-12-05 19:42:22 +01005491 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005492
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005493 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005494 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5495 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005496 return err;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005497 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005498 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5499 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005500 return err;
5501 return 0;
5502}
5503
Takashi Iwai05f5f472009-08-25 13:10:18 +02005504static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005505{
Takashi Iwai05f5f472009-08-25 13:10:18 +02005506 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
5507 return (pincap & AC_PINCAP_IN) != 0;
5508}
5509
5510/* create playback/capture controls for input pins */
5511static int alc_auto_create_input_ctls(struct hda_codec *codec,
5512 const struct auto_pin_cfg *cfg,
5513 hda_nid_t mixer,
5514 hda_nid_t cap1, hda_nid_t cap2)
5515{
5516 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005517 struct hda_input_mux *imux = &spec->private_imux[0];
David Henningsson5322bf22011-01-05 11:03:56 +01005518 int i, err, idx, type_idx = 0;
5519 const char *prev_label = NULL;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005520
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005521 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02005522 hda_nid_t pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005523 const char *label;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005524
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005525 pin = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005526 if (!alc_is_input_pin(codec, pin))
5527 continue;
5528
David Henningsson5322bf22011-01-05 11:03:56 +01005529 label = hda_get_autocfg_input_label(codec, cfg, i);
5530 if (prev_label && !strcmp(label, prev_label))
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005531 type_idx++;
5532 else
5533 type_idx = 0;
David Henningsson5322bf22011-01-05 11:03:56 +01005534 prev_label = label;
5535
Takashi Iwai05f5f472009-08-25 13:10:18 +02005536 if (mixer) {
5537 idx = get_connection_index(codec, mixer, pin);
5538 if (idx >= 0) {
5539 err = new_analog_input(spec, pin,
Takashi Iwai10a20af2010-09-09 16:28:02 +02005540 label, type_idx,
5541 idx, mixer);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005542 if (err < 0)
5543 return err;
5544 }
5545 }
5546
5547 if (!cap1)
5548 continue;
5549 idx = get_connection_index(codec, cap1, pin);
5550 if (idx < 0 && cap2)
5551 idx = get_connection_index(codec, cap2, pin);
Takashi Iwai10a20af2010-09-09 16:28:02 +02005552 if (idx >= 0)
5553 snd_hda_add_imux_item(imux, label, idx, NULL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005554 }
5555 return 0;
5556}
5557
Takashi Iwai05f5f472009-08-25 13:10:18 +02005558static int alc880_auto_create_input_ctls(struct hda_codec *codec,
5559 const struct auto_pin_cfg *cfg)
5560{
5561 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
5562}
5563
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005564static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
5565 unsigned int pin_type)
5566{
5567 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5568 pin_type);
5569 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01005570 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5571 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005572}
5573
Kailang Yangdf694da2005-12-05 19:42:22 +01005574static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
5575 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005576 int dac_idx)
5577{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005578 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005579 /* need the manual connection? */
5580 if (alc880_is_multi_pin(nid)) {
5581 struct alc_spec *spec = codec->spec;
5582 int idx = alc880_multi_pin_idx(nid);
5583 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
5584 AC_VERB_SET_CONNECT_SEL,
5585 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
5586 }
5587}
5588
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005589static int get_pin_type(int line_out_type)
5590{
5591 if (line_out_type == AUTO_PIN_HP_OUT)
5592 return PIN_HP;
5593 else
5594 return PIN_OUT;
5595}
5596
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005597static void alc880_auto_init_multi_out(struct hda_codec *codec)
5598{
5599 struct alc_spec *spec = codec->spec;
5600 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02005601
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005602 for (i = 0; i < spec->autocfg.line_outs; i++) {
5603 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005604 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5605 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005606 }
5607}
5608
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005609static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005610{
5611 struct alc_spec *spec = codec->spec;
5612 hda_nid_t pin;
5613
Takashi Iwai82bc9552006-03-21 11:24:42 +01005614 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005615 if (pin) /* connect to front */
5616 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005617 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005618 if (pin) /* connect to front */
5619 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5620}
5621
5622static void alc880_auto_init_analog_input(struct hda_codec *codec)
5623{
5624 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005625 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005626 int i;
5627
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005628 for (i = 0; i < cfg->num_inputs; i++) {
5629 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005630 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02005631 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005632 if (nid != ALC880_PIN_CD_NID &&
5633 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005634 snd_hda_codec_write(codec, nid, 0,
5635 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005636 AMP_OUT_MUTE);
5637 }
5638 }
5639}
5640
Takashi Iwai7f311a42010-04-09 17:32:23 +02005641static void alc880_auto_init_input_src(struct hda_codec *codec)
5642{
5643 struct alc_spec *spec = codec->spec;
5644 int c;
5645
5646 for (c = 0; c < spec->num_adc_nids; c++) {
5647 unsigned int mux_idx;
5648 const struct hda_input_mux *imux;
5649 mux_idx = c >= spec->num_mux_defs ? 0 : c;
5650 imux = &spec->input_mux[mux_idx];
5651 if (!imux->num_items && mux_idx > 0)
5652 imux = &spec->input_mux[0];
5653 if (imux)
5654 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
5655 AC_VERB_SET_CONNECT_SEL,
5656 imux->items[0].index);
5657 }
5658}
5659
Takashi Iwaice764ab2011-04-27 16:35:23 +02005660static int alc_auto_add_multi_channel_mode(struct hda_codec *codec);
5661
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005662/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005663/* return 1 if successful, 0 if the proper config is not found,
5664 * or a negative error code
5665 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005666static int alc880_parse_auto_config(struct hda_codec *codec)
5667{
5668 struct alc_spec *spec = codec->spec;
Takashi Iwai757899a2010-07-30 10:48:14 +02005669 int err;
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02005670 static const hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005671
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005672 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5673 alc880_ignore);
5674 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005675 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005676 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005677 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01005678
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005679 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
5680 if (err < 0)
5681 return err;
Takashi Iwaice764ab2011-04-27 16:35:23 +02005682 err = alc_auto_add_multi_channel_mode(codec);
5683 if (err < 0)
5684 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005685 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
5686 if (err < 0)
5687 return err;
5688 err = alc880_auto_create_extra_out(spec,
5689 spec->autocfg.speaker_pins[0],
5690 "Speaker");
5691 if (err < 0)
5692 return err;
5693 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
5694 "Headphone");
5695 if (err < 0)
5696 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005697 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005698 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005699 return err;
5700
5701 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5702
Takashi Iwai757899a2010-07-30 10:48:14 +02005703 alc_auto_parse_digital(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005704
Takashi Iwai603c4012008-07-30 15:01:44 +02005705 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005706 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005707
Takashi Iwaid88897e2008-10-31 15:01:37 +01005708 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005709
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005710 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005711 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005712
Kailang Yang6227cdc2010-02-25 08:36:52 +01005713 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005714
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005715 return 1;
5716}
5717
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005718/* additional initialization for auto-configuration model */
5719static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005720{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005721 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005722 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005723 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005724 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02005725 alc880_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02005726 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005727 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005728 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005729}
5730
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005731/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5732 * one of two digital mic pins, e.g. on ALC272
5733 */
5734static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005735{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005736 struct alc_spec *spec = codec->spec;
5737 int i;
5738
5739 for (i = 0; i < spec->num_adc_nids; i++) {
5740 hda_nid_t cap = spec->capsrc_nids ?
5741 spec->capsrc_nids[i] : spec->adc_nids[i];
5742 int iidx, eidx;
5743
5744 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5745 if (iidx < 0)
5746 continue;
5747 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5748 if (eidx < 0)
5749 continue;
5750 spec->int_mic.mux_idx = iidx;
5751 spec->ext_mic.mux_idx = eidx;
5752 if (spec->capsrc_nids)
5753 spec->capsrc_nids += i;
5754 spec->adc_nids += i;
5755 spec->num_adc_nids = 1;
Takashi Iwai8ed99d92011-05-17 12:05:02 +02005756 /* optional dock-mic */
5757 eidx = get_connection_index(codec, cap, spec->dock_mic.pin);
5758 if (eidx < 0)
5759 spec->dock_mic.pin = 0;
5760 else
5761 spec->dock_mic.mux_idx = eidx;
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005762 return;
5763 }
5764 snd_printd(KERN_INFO "hda_codec: %s: "
5765 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5766 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5767 spec->auto_mic = 0; /* disable auto-mic to be sure */
5768}
5769
Takashi Iwai748cce42010-08-04 07:37:39 +02005770/* select or unmute the given capsrc route */
5771static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
5772 int idx)
5773{
5774 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5775 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5776 HDA_AMP_MUTE, 0);
5777 } else {
5778 snd_hda_codec_write_cache(codec, cap, 0,
5779 AC_VERB_SET_CONNECT_SEL, idx);
5780 }
5781}
5782
Takashi Iwai840b64c2010-07-13 22:49:01 +02005783/* set the default connection to that pin */
5784static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
5785{
5786 struct alc_spec *spec = codec->spec;
5787 int i;
5788
Takashi Iwai8ed99d92011-05-17 12:05:02 +02005789 if (!pin)
5790 return 0;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005791 for (i = 0; i < spec->num_adc_nids; i++) {
5792 hda_nid_t cap = spec->capsrc_nids ?
5793 spec->capsrc_nids[i] : spec->adc_nids[i];
5794 int idx;
5795
5796 idx = get_connection_index(codec, cap, pin);
5797 if (idx < 0)
5798 continue;
Takashi Iwai748cce42010-08-04 07:37:39 +02005799 select_or_unmute_capsrc(codec, cap, idx);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005800 return i; /* return the found index */
5801 }
5802 return -1; /* not found */
5803}
5804
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005805/* choose the ADC/MUX containing the input pin and initialize the setup */
5806static void fixup_single_adc(struct hda_codec *codec)
5807{
5808 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005809 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005810 int i;
5811
5812 /* search for the input pin; there must be only one */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005813 if (cfg->num_inputs != 1)
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005814 return;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005815 i = init_capsrc_for_pin(codec, cfg->inputs[0].pin);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005816 if (i >= 0) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005817 /* use only this ADC */
5818 if (spec->capsrc_nids)
5819 spec->capsrc_nids += i;
5820 spec->adc_nids += i;
5821 spec->num_adc_nids = 1;
Takashi Iwai584c0c42011-03-10 12:51:11 +01005822 spec->single_input_src = 1;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005823 }
5824}
5825
Takashi Iwai840b64c2010-07-13 22:49:01 +02005826/* initialize dual adcs */
5827static void fixup_dual_adc_switch(struct hda_codec *codec)
5828{
5829 struct alc_spec *spec = codec->spec;
5830 init_capsrc_for_pin(codec, spec->ext_mic.pin);
Takashi Iwai8ed99d92011-05-17 12:05:02 +02005831 init_capsrc_for_pin(codec, spec->dock_mic.pin);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005832 init_capsrc_for_pin(codec, spec->int_mic.pin);
5833}
5834
Takashi Iwai584c0c42011-03-10 12:51:11 +01005835/* initialize some special cases for input sources */
5836static void alc_init_special_input_src(struct hda_codec *codec)
5837{
5838 struct alc_spec *spec = codec->spec;
5839 if (spec->dual_adc_switch)
5840 fixup_dual_adc_switch(codec);
5841 else if (spec->single_input_src)
5842 init_capsrc_for_pin(codec, spec->autocfg.inputs[0].pin);
5843}
5844
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005845static void set_capture_mixer(struct hda_codec *codec)
5846{
5847 struct alc_spec *spec = codec->spec;
Takashi Iwaia9111322011-05-02 11:30:18 +02005848 static const struct snd_kcontrol_new *caps[2][3] = {
Takashi Iwaia23b6882009-03-23 15:21:36 +01005849 { alc_capture_mixer_nosrc1,
5850 alc_capture_mixer_nosrc2,
5851 alc_capture_mixer_nosrc3 },
5852 { alc_capture_mixer1,
5853 alc_capture_mixer2,
5854 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005855 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005856 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005857 int mux = 0;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005858 int num_adcs = spec->num_adc_nids;
5859 if (spec->dual_adc_switch)
Takashi Iwai584c0c42011-03-10 12:51:11 +01005860 num_adcs = 1;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005861 else if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005862 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005863 else if (spec->input_mux) {
5864 if (spec->input_mux->num_items > 1)
5865 mux = 1;
5866 else if (spec->input_mux->num_items == 1)
5867 fixup_single_adc(codec);
5868 }
Takashi Iwai840b64c2010-07-13 22:49:01 +02005869 spec->cap_mixer = caps[mux][num_adcs - 1];
Takashi Iwaia23b6882009-03-23 15:21:36 +01005870 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005871}
5872
Takashi Iwai66946352010-03-29 17:21:45 +02005873/* fill adc_nids (and capsrc_nids) containing all active input pins */
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02005874static void fillup_priv_adc_nids(struct hda_codec *codec, const hda_nid_t *nids,
Takashi Iwai66946352010-03-29 17:21:45 +02005875 int num_nids)
5876{
5877 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005878 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai66946352010-03-29 17:21:45 +02005879 int n;
5880 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5881
5882 for (n = 0; n < num_nids; n++) {
5883 hda_nid_t adc, cap;
5884 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5885 int nconns, i, j;
5886
5887 adc = nids[n];
5888 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5889 continue;
5890 cap = adc;
5891 nconns = snd_hda_get_connections(codec, cap, conn,
5892 ARRAY_SIZE(conn));
5893 if (nconns == 1) {
5894 cap = conn[0];
5895 nconns = snd_hda_get_connections(codec, cap, conn,
5896 ARRAY_SIZE(conn));
5897 }
5898 if (nconns <= 0)
5899 continue;
5900 if (!fallback_adc) {
5901 fallback_adc = adc;
5902 fallback_cap = cap;
5903 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005904 for (i = 0; i < cfg->num_inputs; i++) {
5905 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai66946352010-03-29 17:21:45 +02005906 for (j = 0; j < nconns; j++) {
5907 if (conn[j] == nid)
5908 break;
5909 }
5910 if (j >= nconns)
5911 break;
5912 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005913 if (i >= cfg->num_inputs) {
Takashi Iwai66946352010-03-29 17:21:45 +02005914 int num_adcs = spec->num_adc_nids;
5915 spec->private_adc_nids[num_adcs] = adc;
5916 spec->private_capsrc_nids[num_adcs] = cap;
5917 spec->num_adc_nids++;
5918 spec->adc_nids = spec->private_adc_nids;
5919 if (adc != cap)
5920 spec->capsrc_nids = spec->private_capsrc_nids;
5921 }
5922 }
5923 if (!spec->num_adc_nids) {
5924 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005925 " using fallback 0x%x\n",
5926 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005927 spec->private_adc_nids[0] = fallback_adc;
5928 spec->adc_nids = spec->private_adc_nids;
5929 if (fallback_adc != fallback_cap) {
5930 spec->private_capsrc_nids[0] = fallback_cap;
5931 spec->capsrc_nids = spec->private_adc_nids;
5932 }
5933 }
5934}
5935
Takashi Iwai67d634c2009-11-16 15:35:59 +01005936#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005937#define set_beep_amp(spec, nid, idx, dir) \
5938 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005939
Takashi Iwaia9111322011-05-02 11:30:18 +02005940static const struct snd_pci_quirk beep_white_list[] = {
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005941 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai080dc7b2010-09-08 08:38:41 +02005942 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
Daniel Corderoa7e985e2011-04-29 08:18:06 +02005943 SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
Madis Janson39dfe132011-05-19 18:32:41 +02005944 SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
Takashi Iwaie096c8e2010-08-03 17:20:35 +02005945 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005946 {}
5947};
5948
5949static inline int has_cdefine_beep(struct hda_codec *codec)
5950{
5951 struct alc_spec *spec = codec->spec;
5952 const struct snd_pci_quirk *q;
5953 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5954 if (q)
5955 return q->value;
5956 return spec->cdefine.enable_pcbeep;
5957}
Takashi Iwai67d634c2009-11-16 15:35:59 +01005958#else
5959#define set_beep_amp(spec, nid, idx, dir) /* NOP */
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005960#define has_cdefine_beep(codec) 0
Takashi Iwai67d634c2009-11-16 15:35:59 +01005961#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005962
5963/*
5964 * OK, here we have finally the patch for ALC880
5965 */
5966
Linus Torvalds1da177e2005-04-16 15:20:36 -07005967static int patch_alc880(struct hda_codec *codec)
5968{
5969 struct alc_spec *spec;
5970 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005971 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005972
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005973 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005974 if (spec == NULL)
5975 return -ENOMEM;
5976
5977 codec->spec = spec;
5978
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005979 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5980 alc880_models,
5981 alc880_cfg_tbl);
5982 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005983 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5984 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005985 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005986 }
5987
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005988 if (board_config == ALC880_AUTO) {
5989 /* automatic parse from the BIOS config */
5990 err = alc880_parse_auto_config(codec);
5991 if (err < 0) {
5992 alc_free(codec);
5993 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005994 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005995 printk(KERN_INFO
5996 "hda_codec: Cannot set up configuration "
5997 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005998 board_config = ALC880_3ST;
5999 }
6000 }
6001
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006002 err = snd_hda_attach_beep_device(codec, 0x1);
6003 if (err < 0) {
6004 alc_free(codec);
6005 return err;
6006 }
6007
Kailang Yangdf694da2005-12-05 19:42:22 +01006008 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006009 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006010
Linus Torvalds1da177e2005-04-16 15:20:36 -07006011 spec->stream_analog_playback = &alc880_pcm_analog_playback;
6012 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01006013 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006014
Linus Torvalds1da177e2005-04-16 15:20:36 -07006015 spec->stream_digital_playback = &alc880_pcm_digital_playback;
6016 spec->stream_digital_capture = &alc880_pcm_digital_capture;
6017
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006018 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006019 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01006020 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006021 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02006022 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006023 if (wcap != AC_WID_AUD_IN) {
6024 spec->adc_nids = alc880_adc_nids_alt;
6025 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006026 } else {
6027 spec->adc_nids = alc880_adc_nids;
6028 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006029 }
6030 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006031 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006032 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006033
Takashi Iwai2134ea42008-01-10 16:53:55 +01006034 spec->vmaster_nid = 0x0c;
6035
Linus Torvalds1da177e2005-04-16 15:20:36 -07006036 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006037 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006038 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006039#ifdef CONFIG_SND_HDA_POWER_SAVE
6040 if (!spec->loopback.amplist)
6041 spec->loopback.amplist = alc880_loopbacks;
6042#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006043
6044 return 0;
6045}
6046
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006047
Linus Torvalds1da177e2005-04-16 15:20:36 -07006048/*
6049 * ALC260 support
6050 */
6051
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02006052static const hda_nid_t alc260_dac_nids[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006053 /* front */
6054 0x02,
6055};
6056
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02006057static const hda_nid_t alc260_adc_nids[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006058 /* ADC0 */
6059 0x04,
6060};
6061
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02006062static const hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006063 /* ADC1 */
6064 0x05,
6065};
6066
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006067/* NIDs used when simultaneous access to both ADCs makes sense. Note that
6068 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
6069 */
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02006070static const hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006071 /* ADC0, ADC1 */
6072 0x04, 0x05
6073};
6074
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006075#define ALC260_DIGOUT_NID 0x03
6076#define ALC260_DIGIN_NID 0x06
6077
Takashi Iwaia9111322011-05-02 11:30:18 +02006078static const struct hda_input_mux alc260_capture_source = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006079 .num_items = 4,
6080 .items = {
6081 { "Mic", 0x0 },
6082 { "Front Mic", 0x1 },
6083 { "Line", 0x2 },
6084 { "CD", 0x4 },
6085 },
6086};
6087
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006088/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006089 * headphone jack and the internal CD lines since these are the only pins at
6090 * which audio can appear. For flexibility, also allow the option of
6091 * recording the mixer output on the second ADC (ADC0 doesn't have a
6092 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006093 */
Takashi Iwaia9111322011-05-02 11:30:18 +02006094static const struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006095 {
6096 .num_items = 3,
6097 .items = {
6098 { "Mic/Line", 0x0 },
6099 { "CD", 0x4 },
6100 { "Headphone", 0x2 },
6101 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006102 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006103 {
6104 .num_items = 4,
6105 .items = {
6106 { "Mic/Line", 0x0 },
6107 { "CD", 0x4 },
6108 { "Headphone", 0x2 },
6109 { "Mixer", 0x5 },
6110 },
6111 },
6112
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006113};
6114
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006115/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
6116 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006117 */
Takashi Iwaia9111322011-05-02 11:30:18 +02006118static const struct hda_input_mux alc260_acer_capture_sources[2] = {
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006119 {
6120 .num_items = 4,
6121 .items = {
6122 { "Mic", 0x0 },
6123 { "Line", 0x2 },
6124 { "CD", 0x4 },
6125 { "Headphone", 0x5 },
6126 },
6127 },
6128 {
6129 .num_items = 5,
6130 .items = {
6131 { "Mic", 0x0 },
6132 { "Line", 0x2 },
6133 { "CD", 0x4 },
6134 { "Headphone", 0x6 },
6135 { "Mixer", 0x5 },
6136 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006137 },
6138};
Michael Schwingencc959482009-02-22 18:58:45 +01006139
6140/* Maxdata Favorit 100XS */
Takashi Iwaia9111322011-05-02 11:30:18 +02006141static const struct hda_input_mux alc260_favorit100_capture_sources[2] = {
Michael Schwingencc959482009-02-22 18:58:45 +01006142 {
6143 .num_items = 2,
6144 .items = {
6145 { "Line/Mic", 0x0 },
6146 { "CD", 0x4 },
6147 },
6148 },
6149 {
6150 .num_items = 3,
6151 .items = {
6152 { "Line/Mic", 0x0 },
6153 { "CD", 0x4 },
6154 { "Mixer", 0x5 },
6155 },
6156 },
6157};
6158
Linus Torvalds1da177e2005-04-16 15:20:36 -07006159/*
6160 * This is just place-holder, so there's something for alc_build_pcms to look
6161 * at when it calculates the maximum number of channels. ALC260 has no mixer
6162 * element which allows changing the channel mode, so the verb list is
6163 * never used.
6164 */
Takashi Iwaia9111322011-05-02 11:30:18 +02006165static const struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006166 { 2, NULL },
6167};
6168
Kailang Yangdf694da2005-12-05 19:42:22 +01006169
6170/* Mixer combinations
6171 *
6172 * basic: base_output + input + pc_beep + capture
6173 * HP: base_output + input + capture_alt
6174 * HP_3013: hp_3013 + input + capture
6175 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006176 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01006177 */
6178
Takashi Iwaia9111322011-05-02 11:30:18 +02006179static const struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006180 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006181 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006182 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6183 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
6184 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6185 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6186 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006187};
Kailang Yangdf694da2005-12-05 19:42:22 +01006188
Takashi Iwaia9111322011-05-02 11:30:18 +02006189static const struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006190 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6191 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6192 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6193 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6194 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6195 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6196 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
6197 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006198 { } /* end */
6199};
6200
Takashi Iwaibec15c32008-01-28 18:16:30 +01006201/* update HP, line and mono out pins according to the master switch */
Takashi Iwaie9427962011-04-28 15:46:07 +02006202static void alc260_hp_master_update(struct hda_codec *codec)
Takashi Iwaibec15c32008-01-28 18:16:30 +01006203{
6204 struct alc_spec *spec = codec->spec;
Takashi Iwaie9427962011-04-28 15:46:07 +02006205
6206 /* change HP pins */
6207 do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins),
6208 spec->autocfg.hp_pins, spec->master_mute, true);
6209 update_speakers(codec);
Takashi Iwaibec15c32008-01-28 18:16:30 +01006210}
6211
6212static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
6213 struct snd_ctl_elem_value *ucontrol)
6214{
6215 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6216 struct alc_spec *spec = codec->spec;
Takashi Iwaie9427962011-04-28 15:46:07 +02006217 *ucontrol->value.integer.value = !spec->master_mute;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006218 return 0;
6219}
6220
6221static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
6222 struct snd_ctl_elem_value *ucontrol)
6223{
6224 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6225 struct alc_spec *spec = codec->spec;
Takashi Iwaie9427962011-04-28 15:46:07 +02006226 int val = !*ucontrol->value.integer.value;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006227
Takashi Iwaie9427962011-04-28 15:46:07 +02006228 if (val == spec->master_mute)
Takashi Iwaibec15c32008-01-28 18:16:30 +01006229 return 0;
Takashi Iwaie9427962011-04-28 15:46:07 +02006230 spec->master_mute = val;
6231 alc260_hp_master_update(codec);
Takashi Iwaibec15c32008-01-28 18:16:30 +01006232 return 1;
6233}
6234
Takashi Iwaia9111322011-05-02 11:30:18 +02006235static const struct snd_kcontrol_new alc260_hp_output_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006236 {
6237 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6238 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01006239 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006240 .info = snd_ctl_boolean_mono_info,
6241 .get = alc260_hp_master_sw_get,
6242 .put = alc260_hp_master_sw_put,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006243 },
6244 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6245 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
6246 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6247 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
6248 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
6249 HDA_OUTPUT),
6250 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6251 { } /* end */
6252};
6253
Takashi Iwaia9111322011-05-02 11:30:18 +02006254static const struct hda_verb alc260_hp_unsol_verbs[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006255 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6256 {},
6257};
6258
Takashi Iwaie9427962011-04-28 15:46:07 +02006259static void alc260_hp_setup(struct hda_codec *codec)
Takashi Iwaibec15c32008-01-28 18:16:30 +01006260{
6261 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006262
Takashi Iwaie9427962011-04-28 15:46:07 +02006263 spec->autocfg.hp_pins[0] = 0x0f;
6264 spec->autocfg.speaker_pins[0] = 0x10;
6265 spec->autocfg.speaker_pins[1] = 0x11;
6266 spec->automute = 1;
6267 spec->automute_mode = ALC_AUTOMUTE_PIN;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006268}
6269
Takashi Iwaia9111322011-05-02 11:30:18 +02006270static const struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006271 {
6272 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6273 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01006274 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006275 .info = snd_ctl_boolean_mono_info,
6276 .get = alc260_hp_master_sw_get,
6277 .put = alc260_hp_master_sw_put,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006278 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006279 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6280 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
6281 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
6282 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
6283 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6284 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01006285 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6286 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02006287 { } /* end */
6288};
6289
Takashi Iwaie9427962011-04-28 15:46:07 +02006290static void alc260_hp_3013_setup(struct hda_codec *codec)
6291{
6292 struct alc_spec *spec = codec->spec;
6293
6294 spec->autocfg.hp_pins[0] = 0x15;
6295 spec->autocfg.speaker_pins[0] = 0x10;
6296 spec->autocfg.speaker_pins[1] = 0x11;
6297 spec->automute = 1;
6298 spec->automute_mode = ALC_AUTOMUTE_PIN;
6299}
6300
Takashi Iwaia9111322011-05-02 11:30:18 +02006301static const struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
Kailang Yang3f878302008-08-26 13:02:23 +02006302 .ops = &snd_hda_bind_vol,
6303 .values = {
6304 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
6305 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
6306 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
6307 0
6308 },
6309};
6310
Takashi Iwaia9111322011-05-02 11:30:18 +02006311static const struct hda_bind_ctls alc260_dc7600_bind_switch = {
Kailang Yang3f878302008-08-26 13:02:23 +02006312 .ops = &snd_hda_bind_sw,
6313 .values = {
6314 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
6315 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
6316 0
6317 },
6318};
6319
Takashi Iwaia9111322011-05-02 11:30:18 +02006320static const struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
Kailang Yang3f878302008-08-26 13:02:23 +02006321 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
6322 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
6323 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
6324 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
6325 { } /* end */
6326};
6327
Takashi Iwaia9111322011-05-02 11:30:18 +02006328static const struct hda_verb alc260_hp_3013_unsol_verbs[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006329 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6330 {},
6331};
6332
Takashi Iwaie9427962011-04-28 15:46:07 +02006333static void alc260_hp_3012_setup(struct hda_codec *codec)
Takashi Iwaibec15c32008-01-28 18:16:30 +01006334{
6335 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006336
Takashi Iwaie9427962011-04-28 15:46:07 +02006337 spec->autocfg.hp_pins[0] = 0x10;
6338 spec->autocfg.speaker_pins[0] = 0x0f;
6339 spec->autocfg.speaker_pins[1] = 0x11;
6340 spec->autocfg.speaker_pins[2] = 0x15;
6341 spec->automute = 1;
6342 spec->automute_mode = ALC_AUTOMUTE_PIN;
Kailang Yang3f878302008-08-26 13:02:23 +02006343}
6344
6345/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006346 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
6347 */
Takashi Iwaia9111322011-05-02 11:30:18 +02006348static const struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006349 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006350 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006351 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006352 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6353 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6354 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
6355 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006356 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006357 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6358 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006359 { } /* end */
6360};
6361
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006362/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
6363 * versions of the ALC260 don't act on requests to enable mic bias from NID
6364 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
6365 * datasheet doesn't mention this restriction. At this stage it's not clear
6366 * whether this behaviour is intentional or is a hardware bug in chip
6367 * revisions available in early 2006. Therefore for now allow the
6368 * "Headphone Jack Mode" control to span all choices, but if it turns out
6369 * that the lack of mic bias for this NID is intentional we could change the
6370 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6371 *
6372 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
6373 * don't appear to make the mic bias available from the "line" jack, even
6374 * though the NID used for this jack (0x14) can supply it. The theory is
6375 * that perhaps Acer have included blocking capacitors between the ALC260
6376 * and the output jack. If this turns out to be the case for all such
6377 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
6378 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01006379 *
6380 * The C20x Tablet series have a mono internal speaker which is controlled
6381 * via the chip's Mono sum widget and pin complex, so include the necessary
6382 * controls for such models. On models without a "mono speaker" the control
6383 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006384 */
Takashi Iwaia9111322011-05-02 11:30:18 +02006385static const struct snd_kcontrol_new alc260_acer_mixer[] = {
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006386 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6387 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006388 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006389 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01006390 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006391 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01006392 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006393 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6394 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6395 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6396 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6397 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6398 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6399 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6400 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006401 { } /* end */
6402};
6403
Michael Schwingencc959482009-02-22 18:58:45 +01006404/* Maxdata Favorit 100XS: one output and one input (0x12) jack
6405 */
Takashi Iwaia9111322011-05-02 11:30:18 +02006406static const struct snd_kcontrol_new alc260_favorit100_mixer[] = {
Michael Schwingencc959482009-02-22 18:58:45 +01006407 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6408 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
6409 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
6410 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6411 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6412 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6413 { } /* end */
6414};
6415
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006416/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
6417 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
6418 */
Takashi Iwaia9111322011-05-02 11:30:18 +02006419static const struct snd_kcontrol_new alc260_will_mixer[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006420 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6421 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6422 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6423 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6424 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6425 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6426 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6427 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6428 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6429 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006430 { } /* end */
6431};
6432
6433/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
6434 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
6435 */
Takashi Iwaia9111322011-05-02 11:30:18 +02006436static const struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006437 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6438 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6439 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6440 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6441 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6442 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
6443 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
6444 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6445 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6446 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6447 { } /* end */
6448};
6449
Kailang Yangdf694da2005-12-05 19:42:22 +01006450/*
6451 * initialization verbs
6452 */
Takashi Iwaia9111322011-05-02 11:30:18 +02006453static const struct hda_verb alc260_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006454 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006455 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006456 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006457 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006458 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006459 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006460 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006461 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006462 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02006463 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006464 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01006465 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006466 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02006467 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006468 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02006469 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006470 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02006471 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6472 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02006473 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006474 /* set connection select to line in (default select for this ADC) */
6475 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02006476 /* mute capture amp left and right */
6477 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6478 /* set connection select to line in (default select for this ADC) */
6479 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02006480 /* set vol=0 Line-Out mixer amp left and right */
6481 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6482 /* unmute pin widget amp left and right (no gain on this amp) */
6483 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6484 /* set vol=0 HP mixer amp left and right */
6485 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6486 /* unmute pin widget amp left and right (no gain on this amp) */
6487 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6488 /* set vol=0 Mono mixer amp left and right */
6489 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6490 /* unmute pin widget amp left and right (no gain on this amp) */
6491 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6492 /* unmute LINE-2 out pin */
6493 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006494 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6495 * Line In 2 = 0x03
6496 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006497 /* mute analog inputs */
6498 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6499 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6500 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6501 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6502 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006503 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006504 /* mute Front out path */
6505 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6506 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6507 /* mute Headphone out path */
6508 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6509 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6510 /* mute Mono out path */
6511 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6512 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006513 { }
6514};
6515
Takashi Iwai474167d2006-05-17 17:17:43 +02006516#if 0 /* should be identical with alc260_init_verbs? */
Takashi Iwaia9111322011-05-02 11:30:18 +02006517static const struct hda_verb alc260_hp_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01006518 /* Headphone and output */
6519 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6520 /* mono output */
6521 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6522 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6523 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6524 /* Mic2 (front panel) pin widget for input and vref at 80% */
6525 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6526 /* Line In pin widget for input */
6527 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6528 /* Line-2 pin widget for output */
6529 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6530 /* CD pin widget for input */
6531 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6532 /* unmute amp left and right */
6533 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6534 /* set connection select to line in (default select for this ADC) */
6535 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6536 /* unmute Line-Out mixer amp left and right (volume = 0) */
6537 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6538 /* mute pin widget amp left and right (no gain on this amp) */
6539 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6540 /* unmute HP mixer amp left and right (volume = 0) */
6541 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6542 /* mute pin widget amp left and right (no gain on this amp) */
6543 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006544 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6545 * Line In 2 = 0x03
6546 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006547 /* mute analog inputs */
6548 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6549 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6550 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6551 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6552 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006553 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6554 /* Unmute Front out path */
6555 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6556 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6557 /* Unmute Headphone out path */
6558 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6559 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6560 /* Unmute Mono out path */
6561 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6562 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6563 { }
6564};
Takashi Iwai474167d2006-05-17 17:17:43 +02006565#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006566
Takashi Iwaia9111322011-05-02 11:30:18 +02006567static const struct hda_verb alc260_hp_3013_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01006568 /* Line out and output */
6569 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6570 /* mono output */
6571 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6572 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6573 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6574 /* Mic2 (front panel) pin widget for input and vref at 80% */
6575 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6576 /* Line In pin widget for input */
6577 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6578 /* Headphone pin widget for output */
6579 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6580 /* CD pin widget for input */
6581 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6582 /* unmute amp left and right */
6583 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6584 /* set connection select to line in (default select for this ADC) */
6585 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6586 /* unmute Line-Out mixer amp left and right (volume = 0) */
6587 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6588 /* mute pin widget amp left and right (no gain on this amp) */
6589 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6590 /* unmute HP mixer amp left and right (volume = 0) */
6591 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6592 /* mute pin widget amp left and right (no gain on this amp) */
6593 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006594 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6595 * Line In 2 = 0x03
6596 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006597 /* mute analog inputs */
6598 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6599 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6600 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6601 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6602 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006603 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6604 /* Unmute Front out path */
6605 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6606 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6607 /* Unmute Headphone out path */
6608 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6609 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6610 /* Unmute Mono out path */
6611 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6612 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6613 { }
6614};
6615
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006616/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006617 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
6618 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006619 */
Takashi Iwaia9111322011-05-02 11:30:18 +02006620static const struct hda_verb alc260_fujitsu_init_verbs[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006621 /* Disable all GPIOs */
6622 {0x01, AC_VERB_SET_GPIO_MASK, 0},
6623 /* Internal speaker is connected to headphone pin */
6624 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6625 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
6626 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006627 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
6628 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6629 /* Ensure all other unused pins are disabled and muted. */
6630 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6631 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006632 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006633 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006634 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006635 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6636 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6637 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006638
Jonathan Woithef7ace402006-02-28 11:46:14 +01006639 /* Disable digital (SPDIF) pins */
6640 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6641 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006642
Kailang Yangea1fb292008-08-26 12:58:38 +02006643 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01006644 * when acting as an output.
6645 */
6646 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6647
6648 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01006649 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6650 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6651 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6652 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6653 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6654 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6655 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6656 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6657 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006658
Jonathan Woithef7ace402006-02-28 11:46:14 +01006659 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
6660 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6661 /* Unmute Line1 pin widget output buffer since it starts as an output.
6662 * If the pin mode is changed by the user the pin mode control will
6663 * take care of enabling the pin's input/output buffers as needed.
6664 * Therefore there's no need to enable the input buffer at this
6665 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006666 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006667 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02006668 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006669 * mixer ctrl)
6670 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006671 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006672
Jonathan Woithef7ace402006-02-28 11:46:14 +01006673 /* Mute capture amp left and right */
6674 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006675 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01006676 * in (on mic1 pin)
6677 */
6678 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006679
Jonathan Woithef7ace402006-02-28 11:46:14 +01006680 /* Do the same for the second ADC: mute capture input amp and
6681 * set ADC connection to line in (on mic1 pin)
6682 */
6683 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6684 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006685
Jonathan Woithef7ace402006-02-28 11:46:14 +01006686 /* Mute all inputs to mixer widget (even unconnected ones) */
6687 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6688 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6689 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6690 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6691 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6692 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6693 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6694 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006695
6696 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006697};
6698
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006699/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
6700 * similar laptops (adapted from Fujitsu init verbs).
6701 */
Takashi Iwaia9111322011-05-02 11:30:18 +02006702static const struct hda_verb alc260_acer_init_verbs[] = {
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006703 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
6704 * the headphone jack. Turn this on and rely on the standard mute
6705 * methods whenever the user wants to turn these outputs off.
6706 */
6707 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6708 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6709 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6710 /* Internal speaker/Headphone jack is connected to Line-out pin */
6711 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6712 /* Internal microphone/Mic jack is connected to Mic1 pin */
6713 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6714 /* Line In jack is connected to Line1 pin */
6715 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01006716 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
6717 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006718 /* Ensure all other unused pins are disabled and muted. */
6719 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6720 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006721 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6722 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6723 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6724 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6725 /* Disable digital (SPDIF) pins */
6726 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6727 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6728
Kailang Yangea1fb292008-08-26 12:58:38 +02006729 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006730 * bus when acting as outputs.
6731 */
6732 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6733 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6734
6735 /* Start with output sum widgets muted and their output gains at min */
6736 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6737 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6738 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6739 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6740 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6741 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6742 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6743 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6744 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6745
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006746 /* Unmute Line-out pin widget amp left and right
6747 * (no equiv mixer ctrl)
6748 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006749 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01006750 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6751 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006752 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6753 * inputs. If the pin mode is changed by the user the pin mode control
6754 * will take care of enabling the pin's input/output buffers as needed.
6755 * Therefore there's no need to enable the input buffer at this
6756 * stage.
6757 */
6758 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6759 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6760
6761 /* Mute capture amp left and right */
6762 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6763 /* Set ADC connection select to match default mixer setting - mic
6764 * (on mic1 pin)
6765 */
6766 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6767
6768 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006769 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006770 */
6771 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006772 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006773
6774 /* Mute all inputs to mixer widget (even unconnected ones) */
6775 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6776 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6777 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6778 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6779 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6780 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6781 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6782 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6783
6784 { }
6785};
6786
Michael Schwingencc959482009-02-22 18:58:45 +01006787/* Initialisation sequence for Maxdata Favorit 100XS
6788 * (adapted from Acer init verbs).
6789 */
Takashi Iwaia9111322011-05-02 11:30:18 +02006790static const struct hda_verb alc260_favorit100_init_verbs[] = {
Michael Schwingencc959482009-02-22 18:58:45 +01006791 /* GPIO 0 enables the output jack.
6792 * Turn this on and rely on the standard mute
6793 * methods whenever the user wants to turn these outputs off.
6794 */
6795 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6796 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6797 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6798 /* Line/Mic input jack is connected to Mic1 pin */
6799 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6800 /* Ensure all other unused pins are disabled and muted. */
6801 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6802 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6803 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6804 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6805 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6806 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6807 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6808 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6809 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6810 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6811 /* Disable digital (SPDIF) pins */
6812 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6813 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6814
6815 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6816 * bus when acting as outputs.
6817 */
6818 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6819 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6820
6821 /* Start with output sum widgets muted and their output gains at min */
6822 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6823 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6824 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6825 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6826 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6827 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6828 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6829 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6830 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6831
6832 /* Unmute Line-out pin widget amp left and right
6833 * (no equiv mixer ctrl)
6834 */
6835 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6836 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6837 * inputs. If the pin mode is changed by the user the pin mode control
6838 * will take care of enabling the pin's input/output buffers as needed.
6839 * Therefore there's no need to enable the input buffer at this
6840 * stage.
6841 */
6842 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6843
6844 /* Mute capture amp left and right */
6845 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6846 /* Set ADC connection select to match default mixer setting - mic
6847 * (on mic1 pin)
6848 */
6849 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6850
6851 /* Do similar with the second ADC: mute capture input amp and
6852 * set ADC connection to mic to match ALSA's default state.
6853 */
6854 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6855 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6856
6857 /* Mute all inputs to mixer widget (even unconnected ones) */
6858 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6859 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6860 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6861 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6862 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6863 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6864 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6865 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6866
6867 { }
6868};
6869
Takashi Iwaia9111322011-05-02 11:30:18 +02006870static const struct hda_verb alc260_will_verbs[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006871 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6872 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6873 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6874 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6875 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6876 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6877 {}
6878};
6879
Takashi Iwaia9111322011-05-02 11:30:18 +02006880static const struct hda_verb alc260_replacer_672v_verbs[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006881 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6882 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6883 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6884
6885 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6886 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6887 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6888
6889 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6890 {}
6891};
6892
6893/* toggle speaker-output according to the hp-jack state */
6894static void alc260_replacer_672v_automute(struct hda_codec *codec)
6895{
6896 unsigned int present;
6897
6898 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006899 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006900 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006901 snd_hda_codec_write_cache(codec, 0x01, 0,
6902 AC_VERB_SET_GPIO_DATA, 1);
6903 snd_hda_codec_write_cache(codec, 0x0f, 0,
6904 AC_VERB_SET_PIN_WIDGET_CONTROL,
6905 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006906 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006907 snd_hda_codec_write_cache(codec, 0x01, 0,
6908 AC_VERB_SET_GPIO_DATA, 0);
6909 snd_hda_codec_write_cache(codec, 0x0f, 0,
6910 AC_VERB_SET_PIN_WIDGET_CONTROL,
6911 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006912 }
6913}
6914
6915static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6916 unsigned int res)
6917{
6918 if ((res >> 26) == ALC880_HP_EVENT)
6919 alc260_replacer_672v_automute(codec);
6920}
6921
Takashi Iwaia9111322011-05-02 11:30:18 +02006922static const struct hda_verb alc260_hp_dc7600_verbs[] = {
Kailang Yang3f878302008-08-26 13:02:23 +02006923 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6924 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6925 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6926 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6927 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6928 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6929 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6930 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6931 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6932 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6933 {}
6934};
6935
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006936/* Test configuration for debugging, modelled after the ALC880 test
6937 * configuration.
6938 */
6939#ifdef CONFIG_SND_DEBUG
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02006940static const hda_nid_t alc260_test_dac_nids[1] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006941 0x02,
6942};
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02006943static const hda_nid_t alc260_test_adc_nids[2] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006944 0x04, 0x05,
6945};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006946/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006947 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006948 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006949 */
Takashi Iwaia9111322011-05-02 11:30:18 +02006950static const struct hda_input_mux alc260_test_capture_sources[2] = {
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006951 {
6952 .num_items = 7,
6953 .items = {
6954 { "MIC1 pin", 0x0 },
6955 { "MIC2 pin", 0x1 },
6956 { "LINE1 pin", 0x2 },
6957 { "LINE2 pin", 0x3 },
6958 { "CD pin", 0x4 },
6959 { "LINE-OUT pin", 0x5 },
6960 { "HP-OUT pin", 0x6 },
6961 },
6962 },
6963 {
6964 .num_items = 8,
6965 .items = {
6966 { "MIC1 pin", 0x0 },
6967 { "MIC2 pin", 0x1 },
6968 { "LINE1 pin", 0x2 },
6969 { "LINE2 pin", 0x3 },
6970 { "CD pin", 0x4 },
6971 { "Mixer", 0x5 },
6972 { "LINE-OUT pin", 0x6 },
6973 { "HP-OUT pin", 0x7 },
6974 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006975 },
6976};
Takashi Iwaia9111322011-05-02 11:30:18 +02006977static const struct snd_kcontrol_new alc260_test_mixer[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006978 /* Output driver widgets */
6979 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6980 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6981 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6982 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6983 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6984 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6985
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006986 /* Modes for retasking pin widgets
6987 * Note: the ALC260 doesn't seem to act on requests to enable mic
6988 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6989 * mention this restriction. At this stage it's not clear whether
6990 * this behaviour is intentional or is a hardware bug in chip
6991 * revisions available at least up until early 2006. Therefore for
6992 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6993 * choices, but if it turns out that the lack of mic bias for these
6994 * NIDs is intentional we could change their modes from
6995 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6996 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006997 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6998 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6999 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
7000 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
7001 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
7002 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
7003
7004 /* Loopback mixer controls */
7005 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
7006 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
7007 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
7008 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
7009 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
7010 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
7011 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
7012 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
7013 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
7014 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007015 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
7016 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
7017 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
7018 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01007019
7020 /* Controls for GPIO pins, assuming they are configured as outputs */
7021 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
7022 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
7023 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
7024 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
7025
Jonathan Woithe92621f12006-02-28 11:47:47 +01007026 /* Switches to allow the digital IO pins to be enabled. The datasheet
7027 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02007028 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01007029 */
7030 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
7031 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
7032
Jonathan Woithef8225f62008-01-08 12:16:54 +01007033 /* A switch allowing EAPD to be enabled. Some laptops seem to use
7034 * this output to turn on an external amplifier.
7035 */
7036 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
7037 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
7038
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007039 { } /* end */
7040};
Takashi Iwaia9111322011-05-02 11:30:18 +02007041static const struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01007042 /* Enable all GPIOs as outputs with an initial value of 0 */
7043 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
7044 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
7045 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
7046
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007047 /* Enable retasking pins as output, initially without power amp */
7048 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7049 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7050 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7051 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7052 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7053 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7054
Jonathan Woithe92621f12006-02-28 11:47:47 +01007055 /* Disable digital (SPDIF) pins initially, but users can enable
7056 * them via a mixer switch. In the case of SPDIF-out, this initverb
7057 * payload also sets the generation to 0, output to be in "consumer"
7058 * PCM format, copyright asserted, no pre-emphasis and no validity
7059 * control.
7060 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007061 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
7062 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
7063
Kailang Yangea1fb292008-08-26 12:58:38 +02007064 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007065 * OUT1 sum bus when acting as an output.
7066 */
7067 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
7068 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
7069 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
7070 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
7071
7072 /* Start with output sum widgets muted and their output gains at min */
7073 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7074 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7075 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7076 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7077 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7078 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7079 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7080 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7081 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7082
Jonathan Woithecdcd9262006-02-28 11:36:42 +01007083 /* Unmute retasking pin widget output buffers since the default
7084 * state appears to be output. As the pin mode is changed by the
7085 * user the pin mode control will take care of enabling the pin's
7086 * input/output buffers as needed.
7087 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007088 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7089 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7090 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7091 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7092 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7093 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7094 /* Also unmute the mono-out pin widget */
7095 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7096
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007097 /* Mute capture amp left and right */
7098 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01007099 /* Set ADC connection select to match default mixer setting (mic1
7100 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007101 */
7102 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
7103
7104 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01007105 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007106 */
7107 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7108 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
7109
7110 /* Mute all inputs to mixer widget (even unconnected ones) */
7111 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
7112 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
7113 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
7114 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
7115 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
7116 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
7117 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
7118 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
7119
7120 { }
7121};
7122#endif
7123
Takashi Iwai63300792008-01-24 15:31:36 +01007124#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
7125#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07007126
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007127#define alc260_pcm_digital_playback alc880_pcm_digital_playback
7128#define alc260_pcm_digital_capture alc880_pcm_digital_capture
7129
Kailang Yangdf694da2005-12-05 19:42:22 +01007130/*
7131 * for BIOS auto-configuration
7132 */
7133
7134static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02007135 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01007136{
7137 hda_nid_t nid_vol;
7138 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01007139 int err;
7140
7141 if (nid >= 0x0f && nid < 0x11) {
7142 nid_vol = nid - 0x7;
7143 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
7144 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
7145 } else if (nid == 0x11) {
7146 nid_vol = nid - 0x7;
7147 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
7148 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
7149 } else if (nid >= 0x12 && nid <= 0x15) {
7150 nid_vol = 0x08;
7151 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
7152 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
7153 } else
7154 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02007155
Takashi Iwai863b4512008-10-21 17:01:47 +02007156 if (!(*vol_bits & (1 << nid_vol))) {
7157 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02007158 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02007159 if (err < 0)
7160 return err;
7161 *vol_bits |= (1 << nid_vol);
7162 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02007163 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007164 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007165 return err;
7166 return 1;
7167}
7168
7169/* add playback controls from the parsed DAC table */
7170static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
7171 const struct auto_pin_cfg *cfg)
7172{
7173 hda_nid_t nid;
7174 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02007175 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01007176
7177 spec->multiout.num_dacs = 1;
7178 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaidda14412011-05-02 11:29:30 +02007179 spec->private_dac_nids[0] = 0x02;
Kailang Yangdf694da2005-12-05 19:42:22 +01007180
7181 nid = cfg->line_out_pins[0];
7182 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02007183 const char *pfx;
7184 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
7185 pfx = "Master";
7186 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
7187 pfx = "Speaker";
7188 else
7189 pfx = "Front";
7190 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01007191 if (err < 0)
7192 return err;
7193 }
7194
Takashi Iwai82bc9552006-03-21 11:24:42 +01007195 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007196 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02007197 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01007198 if (err < 0)
7199 return err;
7200 }
7201
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007202 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007203 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02007204 err = alc260_add_playback_controls(spec, nid, "Headphone",
7205 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01007206 if (err < 0)
7207 return err;
7208 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007209 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01007210}
7211
7212/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02007213static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01007214 const struct auto_pin_cfg *cfg)
7215{
Takashi Iwai05f5f472009-08-25 13:10:18 +02007216 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01007217}
7218
7219static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
7220 hda_nid_t nid, int pin_type,
7221 int sel_idx)
7222{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007223 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007224 /* need the manual connection? */
7225 if (nid >= 0x12) {
7226 int idx = nid - 0x12;
7227 snd_hda_codec_write(codec, idx + 0x0b, 0,
7228 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01007229 }
7230}
7231
7232static void alc260_auto_init_multi_out(struct hda_codec *codec)
7233{
7234 struct alc_spec *spec = codec->spec;
7235 hda_nid_t nid;
7236
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007237 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007238 if (nid) {
7239 int pin_type = get_pin_type(spec->autocfg.line_out_type);
7240 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
7241 }
Kailang Yangea1fb292008-08-26 12:58:38 +02007242
Takashi Iwai82bc9552006-03-21 11:24:42 +01007243 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007244 if (nid)
7245 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
7246
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007247 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007248 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007249 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007250}
Kailang Yangdf694da2005-12-05 19:42:22 +01007251
7252#define ALC260_PIN_CD_NID 0x16
7253static void alc260_auto_init_analog_input(struct hda_codec *codec)
7254{
7255 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02007256 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +01007257 int i;
7258
Takashi Iwai66ceeb62010-08-30 13:05:52 +02007259 for (i = 0; i < cfg->num_inputs; i++) {
7260 hda_nid_t nid = cfg->inputs[i].pin;
Kailang Yangdf694da2005-12-05 19:42:22 +01007261 if (nid >= 0x12) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02007262 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01007263 if (nid != ALC260_PIN_CD_NID &&
7264 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007265 snd_hda_codec_write(codec, nid, 0,
7266 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01007267 AMP_OUT_MUTE);
7268 }
7269 }
7270}
7271
Takashi Iwai7f311a42010-04-09 17:32:23 +02007272#define alc260_auto_init_input_src alc880_auto_init_input_src
7273
Kailang Yangdf694da2005-12-05 19:42:22 +01007274/*
7275 * generic initialization of ADC, input mixers and output mixers
7276 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007277static const struct hda_verb alc260_volume_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007278 /*
7279 * Unmute ADC0-1 and set the default input to mic-in
7280 */
7281 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
7282 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7283 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
7284 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02007285
Kailang Yangdf694da2005-12-05 19:42:22 +01007286 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7287 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007288 * Note: PASD motherboards uses the Line In 2 as the input for
7289 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007290 */
7291 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007292 /* mute analog inputs */
7293 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7294 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7295 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7296 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7297 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007298
7299 /*
7300 * Set up output mixers (0x08 - 0x0a)
7301 */
7302 /* set vol=0 to output mixers */
7303 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7304 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7305 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7306 /* set up input amps for analog loopback */
7307 /* Amp Indices: DAC = 0, mixer = 1 */
7308 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7309 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7310 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7311 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7312 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7313 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02007314
Kailang Yangdf694da2005-12-05 19:42:22 +01007315 { }
7316};
7317
7318static int alc260_parse_auto_config(struct hda_codec *codec)
7319{
7320 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007321 int err;
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02007322 static const hda_nid_t alc260_ignore[] = { 0x17, 0 };
Kailang Yangdf694da2005-12-05 19:42:22 +01007323
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007324 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7325 alc260_ignore);
7326 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007327 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007328 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
7329 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01007330 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02007331 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01007332 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02007333 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007334 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007335 return err;
7336
7337 spec->multiout.max_channels = 2;
7338
Takashi Iwai0852d7a2009-02-11 11:35:15 +01007339 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007340 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02007341 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01007342 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01007343
Takashi Iwaid88897e2008-10-31 15:01:37 +01007344 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01007345
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007346 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007347 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007348
Kailang Yang6227cdc2010-02-25 08:36:52 +01007349 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02007350
Kailang Yangdf694da2005-12-05 19:42:22 +01007351 return 1;
7352}
7353
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007354/* additional initialization for auto-configuration model */
7355static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007356{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007357 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007358 alc260_auto_init_multi_out(codec);
7359 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02007360 alc260_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02007361 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007362 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007363 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007364}
7365
Takashi Iwaicb53c622007-08-10 17:21:45 +02007366#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaia9111322011-05-02 11:30:18 +02007367static const struct hda_amp_list alc260_loopbacks[] = {
Takashi Iwaicb53c622007-08-10 17:21:45 +02007368 { 0x07, HDA_INPUT, 0 },
7369 { 0x07, HDA_INPUT, 1 },
7370 { 0x07, HDA_INPUT, 2 },
7371 { 0x07, HDA_INPUT, 3 },
7372 { 0x07, HDA_INPUT, 4 },
7373 { } /* end */
7374};
7375#endif
7376
Kailang Yangdf694da2005-12-05 19:42:22 +01007377/*
Takashi Iwaifc091762010-08-04 23:53:36 +02007378 * Pin config fixes
7379 */
7380enum {
7381 PINFIX_HP_DC5750,
7382};
7383
Takashi Iwaifc091762010-08-04 23:53:36 +02007384static const struct alc_fixup alc260_fixups[] = {
7385 [PINFIX_HP_DC5750] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007386 .type = ALC_FIXUP_PINS,
7387 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +02007388 { 0x11, 0x90130110 }, /* speaker */
7389 { }
7390 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007391 },
7392};
7393
Takashi Iwaia9111322011-05-02 11:30:18 +02007394static const struct snd_pci_quirk alc260_fixup_tbl[] = {
Takashi Iwaifc091762010-08-04 23:53:36 +02007395 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
7396 {}
7397};
7398
7399/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007400 * ALC260 configurations
7401 */
Takashi Iwaiea734962011-01-17 11:29:34 +01007402static const char * const alc260_models[ALC260_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007403 [ALC260_BASIC] = "basic",
7404 [ALC260_HP] = "hp",
7405 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02007406 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007407 [ALC260_FUJITSU_S702X] = "fujitsu",
7408 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007409 [ALC260_WILL] = "will",
7410 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01007411 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007412#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007413 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007414#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007415 [ALC260_AUTO] = "auto",
7416};
7417
Takashi Iwaia9111322011-05-02 11:30:18 +02007418static const struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01007419 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05007420 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007421 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01007422 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01007423 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01007424 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007425 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02007426 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02007427 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007428 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
7429 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
7430 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
7431 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
7432 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
7433 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
7434 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
7435 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
7436 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007437 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007438 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02007439 {}
7440};
7441
Takashi Iwaia9111322011-05-02 11:30:18 +02007442static const struct alc_config_preset alc260_presets[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007443 [ALC260_BASIC] = {
7444 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007445 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007446 .init_verbs = { alc260_init_verbs },
7447 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7448 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007449 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01007450 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007451 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7452 .channel_mode = alc260_modes,
7453 .input_mux = &alc260_capture_source,
7454 },
7455 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01007456 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007457 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007458 .init_verbs = { alc260_init_verbs,
7459 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007460 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7461 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007462 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7463 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007464 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7465 .channel_mode = alc260_modes,
7466 .input_mux = &alc260_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +02007467 .unsol_event = alc_sku_unsol_event,
7468 .setup = alc260_hp_setup,
7469 .init_hook = alc_inithook,
Kailang Yangdf694da2005-12-05 19:42:22 +01007470 },
Kailang Yang3f878302008-08-26 13:02:23 +02007471 [ALC260_HP_DC7600] = {
7472 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007473 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02007474 .init_verbs = { alc260_init_verbs,
7475 alc260_hp_dc7600_verbs },
7476 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7477 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007478 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7479 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02007480 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7481 .channel_mode = alc260_modes,
7482 .input_mux = &alc260_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +02007483 .unsol_event = alc_sku_unsol_event,
7484 .setup = alc260_hp_3012_setup,
7485 .init_hook = alc_inithook,
Kailang Yang3f878302008-08-26 13:02:23 +02007486 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007487 [ALC260_HP_3013] = {
7488 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007489 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007490 .init_verbs = { alc260_hp_3013_init_verbs,
7491 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007492 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7493 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007494 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7495 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007496 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7497 .channel_mode = alc260_modes,
7498 .input_mux = &alc260_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +02007499 .unsol_event = alc_sku_unsol_event,
7500 .setup = alc260_hp_3013_setup,
7501 .init_hook = alc_inithook,
Kailang Yangdf694da2005-12-05 19:42:22 +01007502 },
7503 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007504 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007505 .init_verbs = { alc260_fujitsu_init_verbs },
7506 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7507 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01007508 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7509 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007510 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7511 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007512 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
7513 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01007514 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007515 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007516 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007517 .init_verbs = { alc260_acer_init_verbs },
7518 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7519 .dac_nids = alc260_dac_nids,
7520 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7521 .adc_nids = alc260_dual_adc_nids,
7522 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7523 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007524 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
7525 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007526 },
Michael Schwingencc959482009-02-22 18:58:45 +01007527 [ALC260_FAVORIT100] = {
7528 .mixers = { alc260_favorit100_mixer },
7529 .init_verbs = { alc260_favorit100_init_verbs },
7530 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7531 .dac_nids = alc260_dac_nids,
7532 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7533 .adc_nids = alc260_dual_adc_nids,
7534 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7535 .channel_mode = alc260_modes,
7536 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
7537 .input_mux = alc260_favorit100_capture_sources,
7538 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007539 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007540 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007541 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
7542 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7543 .dac_nids = alc260_dac_nids,
7544 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7545 .adc_nids = alc260_adc_nids,
7546 .dig_out_nid = ALC260_DIGOUT_NID,
7547 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7548 .channel_mode = alc260_modes,
7549 .input_mux = &alc260_capture_source,
7550 },
7551 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007552 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007553 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
7554 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7555 .dac_nids = alc260_dac_nids,
7556 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7557 .adc_nids = alc260_adc_nids,
7558 .dig_out_nid = ALC260_DIGOUT_NID,
7559 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7560 .channel_mode = alc260_modes,
7561 .input_mux = &alc260_capture_source,
7562 .unsol_event = alc260_replacer_672v_unsol_event,
7563 .init_hook = alc260_replacer_672v_automute,
7564 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007565#ifdef CONFIG_SND_DEBUG
7566 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007567 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007568 .init_verbs = { alc260_test_init_verbs },
7569 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
7570 .dac_nids = alc260_test_dac_nids,
7571 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
7572 .adc_nids = alc260_test_adc_nids,
7573 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7574 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007575 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
7576 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007577 },
7578#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01007579};
7580
Linus Torvalds1da177e2005-04-16 15:20:36 -07007581static int patch_alc260(struct hda_codec *codec)
7582{
7583 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007584 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007585
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007586 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007587 if (spec == NULL)
7588 return -ENOMEM;
7589
7590 codec->spec = spec;
7591
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007592 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
7593 alc260_models,
7594 alc260_cfg_tbl);
7595 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02007596 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02007597 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01007598 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02007599 }
7600
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007601 if (board_config == ALC260_AUTO) {
7602 alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups);
7603 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
7604 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007605
Kailang Yangdf694da2005-12-05 19:42:22 +01007606 if (board_config == ALC260_AUTO) {
7607 /* automatic parse from the BIOS config */
7608 err = alc260_parse_auto_config(codec);
7609 if (err < 0) {
7610 alc_free(codec);
7611 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007612 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007613 printk(KERN_INFO
7614 "hda_codec: Cannot set up configuration "
7615 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007616 board_config = ALC260_BASIC;
7617 }
Takashi Iwai16ded522005-06-10 19:58:24 +02007618 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007619
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007620 err = snd_hda_attach_beep_device(codec, 0x1);
7621 if (err < 0) {
7622 alc_free(codec);
7623 return err;
7624 }
7625
Kailang Yangdf694da2005-12-05 19:42:22 +01007626 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02007627 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007628
Linus Torvalds1da177e2005-04-16 15:20:36 -07007629 spec->stream_analog_playback = &alc260_pcm_analog_playback;
7630 spec->stream_analog_capture = &alc260_pcm_analog_capture;
Jonathan Woithe53bacfb2010-08-08 00:17:05 +09307631 spec->stream_analog_alt_capture = &alc260_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007632
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007633 spec->stream_digital_playback = &alc260_pcm_digital_playback;
7634 spec->stream_digital_capture = &alc260_pcm_digital_capture;
7635
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007636 if (!spec->adc_nids && spec->input_mux) {
7637 /* check whether NID 0x04 is valid */
7638 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02007639 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007640 /* get type */
7641 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
7642 spec->adc_nids = alc260_adc_nids_alt;
7643 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
7644 } else {
7645 spec->adc_nids = alc260_adc_nids;
7646 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
7647 }
7648 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02007649 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007650 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007651
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007652 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwaifc091762010-08-04 23:53:36 +02007653
Takashi Iwai2134ea42008-01-10 16:53:55 +01007654 spec->vmaster_nid = 0x08;
7655
Linus Torvalds1da177e2005-04-16 15:20:36 -07007656 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007657 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007658 spec->init_hook = alc260_auto_init;
Takashi Iwai1c7161532011-04-07 10:37:16 +02007659 spec->shutup = alc_eapd_shutup;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007660#ifdef CONFIG_SND_HDA_POWER_SAVE
7661 if (!spec->loopback.amplist)
7662 spec->loopback.amplist = alc260_loopbacks;
7663#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07007664
7665 return 0;
7666}
7667
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007668
Linus Torvalds1da177e2005-04-16 15:20:36 -07007669/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007670 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07007671 *
7672 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
7673 * configuration. Each pin widget can choose any input DACs and a mixer.
7674 * Each ADC is connected from a mixer of all inputs. This makes possible
7675 * 6-channel independent captures.
7676 *
7677 * In addition, an independent DAC for the multi-playback (not used in this
7678 * driver yet).
7679 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007680#define ALC882_DIGOUT_NID 0x06
7681#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02007682#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
7683#define ALC883_DIGIN_NID ALC882_DIGIN_NID
7684#define ALC1200_DIGOUT_NID 0x10
7685
Linus Torvalds1da177e2005-04-16 15:20:36 -07007686
Takashi Iwaia9111322011-05-02 11:30:18 +02007687static const struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007688 { 8, NULL }
7689};
7690
Takashi Iwai4953550a2009-06-30 15:28:30 +02007691/* DACs */
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02007692static const hda_nid_t alc882_dac_nids[4] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007693 /* front, rear, clfe, rear_surr */
7694 0x02, 0x03, 0x04, 0x05
7695};
Takashi Iwai4953550a2009-06-30 15:28:30 +02007696#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007697
Takashi Iwai4953550a2009-06-30 15:28:30 +02007698/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01007699#define alc882_adc_nids alc880_adc_nids
7700#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02007701#define alc883_adc_nids alc882_adc_nids_alt
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02007702static const hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
7703static const hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007704#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007705
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02007706static const hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
7707static const hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007708#define alc883_capsrc_nids alc882_capsrc_nids_alt
Takashi Iwai4c6d72d2011-05-02 11:30:18 +02007709static const hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007710#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01007711
Linus Torvalds1da177e2005-04-16 15:20:36 -07007712/* input MUX */
7713/* FIXME: should be a matrix-type input source selection */
7714
Takashi Iwaia9111322011-05-02 11:30:18 +02007715static const struct hda_input_mux alc882_capture_source = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007716 .num_items = 4,
7717 .items = {
7718 { "Mic", 0x0 },
7719 { "Front Mic", 0x1 },
7720 { "Line", 0x2 },
7721 { "CD", 0x4 },
7722 },
7723};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007724
Takashi Iwai4953550a2009-06-30 15:28:30 +02007725#define alc883_capture_source alc882_capture_source
7726
Takashi Iwaia9111322011-05-02 11:30:18 +02007727static const struct hda_input_mux alc889_capture_source = {
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007728 .num_items = 3,
7729 .items = {
7730 { "Front Mic", 0x0 },
7731 { "Mic", 0x3 },
7732 { "Line", 0x2 },
7733 },
7734};
7735
Takashi Iwaia9111322011-05-02 11:30:18 +02007736static const struct hda_input_mux mb5_capture_source = {
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007737 .num_items = 3,
7738 .items = {
7739 { "Mic", 0x1 },
Alex Murrayb8f171e2010-06-14 12:08:43 +09307740 { "Line", 0x7 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007741 { "CD", 0x4 },
7742 },
7743};
7744
Takashi Iwaia9111322011-05-02 11:30:18 +02007745static const struct hda_input_mux macmini3_capture_source = {
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007746 .num_items = 2,
7747 .items = {
7748 { "Line", 0x2 },
7749 { "CD", 0x4 },
7750 },
7751};
7752
Takashi Iwaia9111322011-05-02 11:30:18 +02007753static const struct hda_input_mux alc883_3stack_6ch_intel = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02007754 .num_items = 4,
7755 .items = {
7756 { "Mic", 0x1 },
7757 { "Front Mic", 0x0 },
7758 { "Line", 0x2 },
7759 { "CD", 0x4 },
7760 },
7761};
7762
Takashi Iwaia9111322011-05-02 11:30:18 +02007763static const struct hda_input_mux alc883_lenovo_101e_capture_source = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02007764 .num_items = 2,
7765 .items = {
7766 { "Mic", 0x1 },
7767 { "Line", 0x2 },
7768 },
7769};
7770
Takashi Iwaia9111322011-05-02 11:30:18 +02007771static const struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02007772 .num_items = 4,
7773 .items = {
7774 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +01007775 { "Internal Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007776 { "Line", 0x2 },
7777 { "CD", 0x4 },
7778 },
7779};
7780
Takashi Iwaia9111322011-05-02 11:30:18 +02007781static const struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02007782 .num_items = 2,
7783 .items = {
7784 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +01007785 { "Internal Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007786 },
7787};
7788
Takashi Iwaia9111322011-05-02 11:30:18 +02007789static const struct hda_input_mux alc883_lenovo_sky_capture_source = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02007790 .num_items = 3,
7791 .items = {
7792 { "Mic", 0x0 },
7793 { "Front Mic", 0x1 },
7794 { "Line", 0x4 },
7795 },
7796};
7797
Takashi Iwaia9111322011-05-02 11:30:18 +02007798static const struct hda_input_mux alc883_asus_eee1601_capture_source = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02007799 .num_items = 2,
7800 .items = {
7801 { "Mic", 0x0 },
7802 { "Line", 0x2 },
7803 },
7804};
7805
Takashi Iwaia9111322011-05-02 11:30:18 +02007806static const struct hda_input_mux alc889A_mb31_capture_source = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02007807 .num_items = 2,
7808 .items = {
7809 { "Mic", 0x0 },
7810 /* Front Mic (0x01) unused */
7811 { "Line", 0x2 },
7812 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007813 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007814 },
7815};
7816
Takashi Iwaia9111322011-05-02 11:30:18 +02007817static const struct hda_input_mux alc889A_imac91_capture_source = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007818 .num_items = 2,
7819 .items = {
7820 { "Mic", 0x01 },
7821 { "Line", 0x2 }, /* Not sure! */
7822 },
7823};
7824
Takashi Iwai4953550a2009-06-30 15:28:30 +02007825/*
7826 * 2ch mode
7827 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007828static const struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02007829 { 2, NULL }
7830};
7831
Kailang Yangdf694da2005-12-05 19:42:22 +01007832/*
Kailang Yang272a5272007-05-14 11:00:38 +02007833 * 2ch mode
7834 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007835static const struct hda_verb alc882_3ST_ch2_init[] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007836 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7837 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7838 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7839 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7840 { } /* end */
7841};
7842
7843/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007844 * 4ch mode
7845 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007846static const struct hda_verb alc882_3ST_ch4_init[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02007847 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7848 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7849 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7850 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7851 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7852 { } /* end */
7853};
7854
7855/*
Kailang Yang272a5272007-05-14 11:00:38 +02007856 * 6ch mode
7857 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007858static const struct hda_verb alc882_3ST_ch6_init[] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007859 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7860 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7861 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7862 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7863 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7864 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7865 { } /* end */
7866};
7867
Takashi Iwaia9111322011-05-02 11:30:18 +02007868static const struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007869 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007870 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007871 { 6, alc882_3ST_ch6_init },
7872};
7873
Takashi Iwai4953550a2009-06-30 15:28:30 +02007874#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7875
Kailang Yang272a5272007-05-14 11:00:38 +02007876/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307877 * 2ch mode
7878 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007879static const struct hda_verb alc883_3ST_ch2_clevo_init[] = {
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307880 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7881 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7882 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7883 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7884 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7885 { } /* end */
7886};
7887
7888/*
7889 * 4ch mode
7890 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007891static const struct hda_verb alc883_3ST_ch4_clevo_init[] = {
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307892 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7893 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7894 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7895 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7896 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7897 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7898 { } /* end */
7899};
7900
7901/*
7902 * 6ch mode
7903 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007904static const struct hda_verb alc883_3ST_ch6_clevo_init[] = {
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307905 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7906 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7907 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7908 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7909 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7910 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7911 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7912 { } /* end */
7913};
7914
Takashi Iwaia9111322011-05-02 11:30:18 +02007915static const struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307916 { 2, alc883_3ST_ch2_clevo_init },
7917 { 4, alc883_3ST_ch4_clevo_init },
7918 { 6, alc883_3ST_ch6_clevo_init },
7919};
7920
7921
7922/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007923 * 6ch mode
7924 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007925static const struct hda_verb alc882_sixstack_ch6_init[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007926 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7927 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7928 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7929 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7930 { } /* end */
7931};
7932
7933/*
7934 * 8ch mode
7935 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007936static const struct hda_verb alc882_sixstack_ch8_init[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007937 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7938 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7939 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7940 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7941 { } /* end */
7942};
7943
Takashi Iwaia9111322011-05-02 11:30:18 +02007944static const struct hda_channel_mode alc882_sixstack_modes[2] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007945 { 6, alc882_sixstack_ch6_init },
7946 { 8, alc882_sixstack_ch8_init },
7947};
7948
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007949
7950/* Macbook Air 2,1 */
7951
Takashi Iwaia9111322011-05-02 11:30:18 +02007952static const struct hda_channel_mode alc885_mba21_ch_modes[1] = {
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007953 { 2, NULL },
7954};
7955
Takashi Iwai87350ad2007-08-16 18:19:38 +02007956/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007957 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007958 */
7959
7960/*
7961 * 2ch mode
7962 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007963static const struct hda_verb alc885_mbp_ch2_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007964 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7965 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7966 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7967 { } /* end */
7968};
7969
7970/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007971 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007972 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007973static const struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007974 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7975 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7976 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7977 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7978 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7979 { } /* end */
7980};
7981
Takashi Iwaia9111322011-05-02 11:30:18 +02007982static const struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007983 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007984 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007985};
7986
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007987/*
7988 * 2ch
7989 * Speakers/Woofer/HP = Front
7990 * LineIn = Input
7991 */
Takashi Iwaia9111322011-05-02 11:30:18 +02007992static const struct hda_verb alc885_mb5_ch2_init[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007993 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7994 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7995 { } /* end */
7996};
7997
7998/*
7999 * 6ch mode
8000 * Speakers/HP = Front
8001 * Woofer = LFE
8002 * LineIn = Surround
8003 */
Takashi Iwaia9111322011-05-02 11:30:18 +02008004static const struct hda_verb alc885_mb5_ch6_init[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008005 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8006 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8007 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8008 { } /* end */
8009};
8010
Takashi Iwaia9111322011-05-02 11:30:18 +02008011static const struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008012 { 2, alc885_mb5_ch2_init },
8013 { 6, alc885_mb5_ch6_init },
8014};
Takashi Iwai87350ad2007-08-16 18:19:38 +02008015
Takashi Iwaid01aecd2010-02-23 08:07:15 +01008016#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02008017
8018/*
8019 * 2ch mode
8020 */
Takashi Iwaia9111322011-05-02 11:30:18 +02008021static const struct hda_verb alc883_4ST_ch2_init[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02008022 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8023 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8024 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8025 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8026 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8027 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8028 { } /* end */
8029};
8030
8031/*
8032 * 4ch mode
8033 */
Takashi Iwaia9111322011-05-02 11:30:18 +02008034static const struct hda_verb alc883_4ST_ch4_init[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02008035 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8036 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8037 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8038 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8039 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8040 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8041 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
8042 { } /* end */
8043};
8044
8045/*
8046 * 6ch mode
8047 */
Takashi Iwaia9111322011-05-02 11:30:18 +02008048static const struct hda_verb alc883_4ST_ch6_init[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02008049 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8050 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8051 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8052 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8053 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
8054 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8055 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8056 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
8057 { } /* end */
8058};
8059
8060/*
8061 * 8ch mode
8062 */
Takashi Iwaia9111322011-05-02 11:30:18 +02008063static const struct hda_verb alc883_4ST_ch8_init[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02008064 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8065 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8066 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
8067 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8068 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8069 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
8070 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8071 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8072 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
8073 { } /* end */
8074};
8075
Takashi Iwaia9111322011-05-02 11:30:18 +02008076static const struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02008077 { 2, alc883_4ST_ch2_init },
8078 { 4, alc883_4ST_ch4_init },
8079 { 6, alc883_4ST_ch6_init },
8080 { 8, alc883_4ST_ch8_init },
8081};
8082
8083
8084/*
8085 * 2ch mode
8086 */
Takashi Iwaia9111322011-05-02 11:30:18 +02008087static const struct hda_verb alc883_3ST_ch2_intel_init[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02008088 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8089 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8090 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8091 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8092 { } /* end */
8093};
8094
8095/*
8096 * 4ch mode
8097 */
Takashi Iwaia9111322011-05-02 11:30:18 +02008098static const struct hda_verb alc883_3ST_ch4_intel_init[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02008099 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8100 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8101 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8102 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8103 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
8104 { } /* end */
8105};
8106
8107/*
8108 * 6ch mode
8109 */
Takashi Iwaia9111322011-05-02 11:30:18 +02008110static const struct hda_verb alc883_3ST_ch6_intel_init[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02008111 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8112 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8113 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
8114 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8115 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8116 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
8117 { } /* end */
8118};
8119
Takashi Iwaia9111322011-05-02 11:30:18 +02008120static const struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02008121 { 2, alc883_3ST_ch2_intel_init },
8122 { 4, alc883_3ST_ch4_intel_init },
8123 { 6, alc883_3ST_ch6_intel_init },
8124};
8125
8126/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08008127 * 2ch mode
8128 */
Takashi Iwaia9111322011-05-02 11:30:18 +02008129static const struct hda_verb alc889_ch2_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08008130 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
8131 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
8132 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
8133 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
8134 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8135 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8136 { } /* end */
8137};
8138
8139/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02008140 * 6ch mode
8141 */
Takashi Iwaia9111322011-05-02 11:30:18 +02008142static const struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08008143 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
8144 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
8145 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
8146 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
8147 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008148 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8149 { } /* end */
8150};
8151
8152/*
8153 * 8ch mode
8154 */
Takashi Iwaia9111322011-05-02 11:30:18 +02008155static const struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08008156 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
8157 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
8158 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
8159 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
8160 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008161 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8162 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008163 { } /* end */
8164};
8165
Takashi Iwaia9111322011-05-02 11:30:18 +02008166static const struct hda_channel_mode alc889_8ch_intel_modes[3] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08008167 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008168 { 6, alc889_ch6_intel_init },
8169 { 8, alc889_ch8_intel_init },
8170};
8171
8172/*
8173 * 6ch mode
8174 */
Takashi Iwaia9111322011-05-02 11:30:18 +02008175static const struct hda_verb alc883_sixstack_ch6_init[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02008176 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8177 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8178 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8179 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8180 { } /* end */
8181};
8182
8183/*
8184 * 8ch mode
8185 */
Takashi Iwaia9111322011-05-02 11:30:18 +02008186static const struct hda_verb alc883_sixstack_ch8_init[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02008187 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8188 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8189 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8190 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8191 { } /* end */
8192};
8193
Takashi Iwaia9111322011-05-02 11:30:18 +02008194static const struct hda_channel_mode alc883_sixstack_modes[2] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02008195 { 6, alc883_sixstack_ch6_init },
8196 { 8, alc883_sixstack_ch8_init },
8197};
8198
8199
Linus Torvalds1da177e2005-04-16 15:20:36 -07008200/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
8201 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
8202 */
Takashi Iwaia9111322011-05-02 11:30:18 +02008203static const struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02008204 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01008205 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02008206 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01008207 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02008208 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8209 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01008210 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8211 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02008212 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01008213 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07008214 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8215 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8216 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8217 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8218 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8219 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008220 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07008221 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8222 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008223 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07008224 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07008225 { } /* end */
8226};
8227
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008228/* Macbook Air 2,1 same control for HP and internal Speaker */
8229
Takashi Iwaia9111322011-05-02 11:30:18 +02008230static const struct snd_kcontrol_new alc885_mba21_mixer[] = {
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008231 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8232 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
8233 { }
8234};
8235
8236
Takashi Iwaia9111322011-05-02 11:30:18 +02008237static const struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008238 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8239 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
8240 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
8241 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
8242 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01008243 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8244 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02008245 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8246 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008247 HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
8248 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02008249 { } /* end */
8250};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008251
Takashi Iwaia9111322011-05-02 11:30:18 +02008252static const struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008253 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8254 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8255 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8256 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8257 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
8258 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10308259 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
8260 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Alex Murrayb8f171e2010-06-14 12:08:43 +09308261 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
8262 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008263 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8264 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008265 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
8266 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0x00, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008267 { } /* end */
8268};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008269
Takashi Iwaia9111322011-05-02 11:30:18 +02008270static const struct snd_kcontrol_new alc885_macmini3_mixer[] = {
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008271 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8272 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8273 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8274 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8275 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
8276 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
8277 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
8278 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
8279 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
8280 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008281 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008282 { } /* end */
8283};
8284
Takashi Iwaia9111322011-05-02 11:30:18 +02008285static const struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008286 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8287 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008288 { } /* end */
8289};
8290
8291
Takashi Iwaia9111322011-05-02 11:30:18 +02008292static const struct snd_kcontrol_new alc882_w2jc_mixer[] = {
Kailang Yangbdd148a2007-05-08 15:19:08 +02008293 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8294 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8295 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8296 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8297 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8298 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8299 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008300 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02008301 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02008302 { } /* end */
8303};
8304
Takashi Iwaia9111322011-05-02 11:30:18 +02008305static const struct snd_kcontrol_new alc882_targa_mixer[] = {
Kailang Yang272a5272007-05-14 11:00:38 +02008306 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8307 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8308 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8309 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8310 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8311 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8312 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8313 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8314 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008315 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008316 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8317 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008318 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008319 { } /* end */
8320};
8321
8322/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
8323 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
8324 */
Takashi Iwaia9111322011-05-02 11:30:18 +02008325static const struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
Kailang Yang272a5272007-05-14 11:00:38 +02008326 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8327 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8328 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8329 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
8330 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8331 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8332 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8333 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8334 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
8335 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
8336 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8337 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008338 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008339 { } /* end */
8340};
8341
Takashi Iwaia9111322011-05-02 11:30:18 +02008342static const struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
Takashi Iwai914759b2007-09-06 14:52:04 +02008343 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8344 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8345 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8346 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8347 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8348 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8349 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8350 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008351 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008352 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008353 { } /* end */
8354};
8355
Takashi Iwaia9111322011-05-02 11:30:18 +02008356static const struct snd_kcontrol_new alc882_chmode_mixer[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008357 {
8358 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8359 .name = "Channel Mode",
8360 .info = alc_ch_mode_info,
8361 .get = alc_ch_mode_get,
8362 .put = alc_ch_mode_put,
8363 },
8364 { } /* end */
8365};
8366
Takashi Iwaia9111322011-05-02 11:30:18 +02008367static const struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07008368 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008369 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8370 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008371 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008372 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8373 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008374 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008375 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8376 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008377 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008378 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8379 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008380
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008381 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008382 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008383 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008384 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008385 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008386 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008387 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008388 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008389 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008390 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008391 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008392 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008393 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008394 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008395 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008396 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008397 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008398 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008399 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8400 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008401 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008402 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8403 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008404 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008405 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8406 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8407 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8408 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8409 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008410 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008411 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008412
8413 /* FIXME: use matrix-type input source selection */
8414 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008415 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008416 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008417 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008418 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02008419 /* ADC2: mute amp left and right */
8420 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008421 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02008422 /* ADC3: mute amp left and right */
8423 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008424 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008425
8426 { }
8427};
8428
Takashi Iwaia9111322011-05-02 11:30:18 +02008429static const struct hda_verb alc882_adc1_init_verbs[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02008430 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8431 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8432 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8433 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8434 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8435 /* ADC1: mute amp left and right */
8436 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8437 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8438 { }
8439};
8440
Takashi Iwaia9111322011-05-02 11:30:18 +02008441static const struct hda_verb alc882_eapd_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008442 /* change to EAPD mode */
8443 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008444 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008445 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008446};
8447
Takashi Iwaia9111322011-05-02 11:30:18 +02008448static const struct hda_verb alc889_eapd_verbs[] = {
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008449 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8450 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8451 { }
8452};
8453
Takashi Iwaia9111322011-05-02 11:30:18 +02008454static const struct hda_verb alc_hp15_unsol_verbs[] = {
Wu Fengguang6732bd02009-07-30 09:19:14 +02008455 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8456 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8457 {}
8458};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008459
Takashi Iwaia9111322011-05-02 11:30:18 +02008460static const struct hda_verb alc885_init_verbs[] = {
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008461 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01008462 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8463 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008464 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008465 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8466 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008467 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008468 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8469 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008470 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008471 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8472 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008473
8474 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02008475 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008476 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8477 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8478 /* Front Pin: output 0 (0x0c) */
8479 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8480 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8481 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8482 /* Rear Pin: output 1 (0x0d) */
8483 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8484 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8485 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
8486 /* CLFE Pin: output 2 (0x0e) */
8487 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8488 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8489 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8490 /* Side Pin: output 3 (0x0f) */
8491 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8492 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8493 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8494 /* Mic (rear) pin: input vref at 80% */
8495 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8496 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8497 /* Front Mic pin: input vref at 80% */
8498 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8499 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8500 /* Line In pin: input */
8501 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8502 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8503
8504 /* Mixer elements: 0x18, , 0x1a, 0x1b */
8505 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01008506 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008507 /* Input mixer2 */
8508 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008509 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008510 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008511 /* ADC2: mute amp left and right */
8512 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8513 /* ADC3: mute amp left and right */
8514 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8515
8516 { }
8517};
8518
Takashi Iwaia9111322011-05-02 11:30:18 +02008519static const struct hda_verb alc885_init_input_verbs[] = {
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008520 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8521 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8522 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8523 { }
8524};
8525
8526
8527/* Unmute Selector 24h and set the default input to front mic */
Takashi Iwaia9111322011-05-02 11:30:18 +02008528static const struct hda_verb alc889_init_input_verbs[] = {
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008529 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
8530 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8531 { }
8532};
8533
8534
Takashi Iwai4953550a2009-06-30 15:28:30 +02008535#define alc883_init_verbs alc882_base_init_verbs
8536
Tobin Davis9102cd12006-12-15 10:02:12 +01008537/* Mac Pro test */
Takashi Iwaia9111322011-05-02 11:30:18 +02008538static const struct snd_kcontrol_new alc882_macpro_mixer[] = {
Tobin Davis9102cd12006-12-15 10:02:12 +01008539 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8540 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8541 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
8542 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8543 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008544 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01008545 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
8546 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008547 */
Tobin Davis9102cd12006-12-15 10:02:12 +01008548 { } /* end */
8549};
8550
Takashi Iwaia9111322011-05-02 11:30:18 +02008551static const struct hda_verb alc882_macpro_init_verbs[] = {
Tobin Davis9102cd12006-12-15 10:02:12 +01008552 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8553 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8554 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8555 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8556 /* Front Pin: output 0 (0x0c) */
8557 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8558 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8559 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8560 /* Front Mic pin: input vref at 80% */
8561 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8562 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8563 /* Speaker: output */
8564 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8565 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8566 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
8567 /* Headphone output (output 0 - 0x0c) */
8568 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8569 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8570 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8571
8572 /* FIXME: use matrix-type input source selection */
8573 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8574 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8575 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8576 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8577 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8578 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8579 /* Input mixer2 */
8580 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8581 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8582 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8583 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8584 /* Input mixer3 */
8585 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8586 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8587 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8588 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8589 /* ADC1: mute amp left and right */
8590 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8591 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8592 /* ADC2: mute amp left and right */
8593 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8594 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8595 /* ADC3: mute amp left and right */
8596 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8597 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8598
8599 { }
8600};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008601
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008602/* Macbook 5,1 */
Takashi Iwaia9111322011-05-02 11:30:18 +02008603static const struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008604 /* DACs */
8605 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8606 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8607 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8608 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008609 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008610 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8611 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8612 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008613 /* Surround mixer */
8614 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8615 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8616 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8617 /* LFE mixer */
8618 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8619 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8620 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8621 /* HP mixer */
8622 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8623 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8624 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8625 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008626 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8627 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008628 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8629 /* LFE Pin (0x0e) */
8630 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8631 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8632 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8633 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008634 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8635 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008636 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10308637 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008638 /* Front Mic pin: input vref at 80% */
8639 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8640 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8641 /* Line In pin */
8642 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8643 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8644
Alex Murrayb8f171e2010-06-14 12:08:43 +09308645 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
8646 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
8647 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008648 { }
8649};
8650
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008651/* Macmini 3,1 */
Takashi Iwaia9111322011-05-02 11:30:18 +02008652static const struct hda_verb alc885_macmini3_init_verbs[] = {
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008653 /* DACs */
8654 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8655 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8656 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8657 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8658 /* Front mixer */
8659 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8660 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8661 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8662 /* Surround mixer */
8663 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8664 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8665 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8666 /* LFE mixer */
8667 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8668 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8669 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8670 /* HP mixer */
8671 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8672 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8673 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8674 /* Front Pin (0x0c) */
8675 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8676 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8677 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8678 /* LFE Pin (0x0e) */
8679 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8680 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8681 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8682 /* HP Pin (0x0f) */
8683 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8684 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8685 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
8686 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8687 /* Line In pin */
8688 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8689 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8690
8691 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8692 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8693 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8694 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8695 { }
8696};
8697
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008698
Takashi Iwaia9111322011-05-02 11:30:18 +02008699static const struct hda_verb alc885_mba21_init_verbs[] = {
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008700 /*Internal and HP Speaker Mixer*/
8701 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8702 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8703 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8704 /*Internal Speaker Pin (0x0c)*/
8705 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8706 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8707 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8708 /* HP Pin: output 0 (0x0e) */
8709 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
8710 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8711 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8712 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8713 /* Line in (is hp when jack connected)*/
8714 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8715 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8716
8717 { }
8718 };
8719
8720
Takashi Iwai87350ad2007-08-16 18:19:38 +02008721/* Macbook Pro rev3 */
Takashi Iwaia9111322011-05-02 11:30:18 +02008722static const struct hda_verb alc885_mbp3_init_verbs[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02008723 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8724 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8725 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8726 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8727 /* Rear mixer */
8728 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8729 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8730 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008731 /* HP mixer */
8732 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8733 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8734 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008735 /* Front Pin: output 0 (0x0c) */
8736 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8737 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8738 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008739 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02008740 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008741 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8742 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008743 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8744 /* Mic (rear) pin: input vref at 80% */
8745 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8746 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8747 /* Front Mic pin: input vref at 80% */
8748 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8749 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8750 /* Line In pin: use output 1 when in LineOut mode */
8751 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8752 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8753 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8754
8755 /* FIXME: use matrix-type input source selection */
8756 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8757 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8758 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8759 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8760 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8761 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8762 /* Input mixer2 */
8763 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8764 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8765 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8766 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8767 /* Input mixer3 */
8768 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8769 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8770 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8771 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8772 /* ADC1: mute amp left and right */
8773 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8774 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8775 /* ADC2: mute amp left and right */
8776 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8777 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8778 /* ADC3: mute amp left and right */
8779 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8780 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8781
8782 { }
8783};
8784
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008785/* iMac 9,1 */
Takashi Iwaia9111322011-05-02 11:30:18 +02008786static const struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008787 /* Internal Speaker Pin (0x0c) */
8788 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8789 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8790 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8791 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8792 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8793 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8794 /* HP Pin: Rear */
8795 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8796 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8797 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8798 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8799 /* Line in Rear */
8800 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8801 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8802 /* Front Mic pin: input vref at 80% */
8803 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8804 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008805 /* Rear mixer */
8806 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8807 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8808 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008809 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8810 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8811 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8812 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8813 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008814 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8815 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8816 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8817 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008818 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008819 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8820 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8821 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8822 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008823 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008824 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8825 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8826 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8827 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008828 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008829 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8830 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008831 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008832 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8833 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008834 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008835 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8836 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008837 { }
8838};
8839
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008840/* iMac 24 mixer. */
Takashi Iwaia9111322011-05-02 11:30:18 +02008841static const struct snd_kcontrol_new alc885_imac24_mixer[] = {
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008842 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8843 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8844 { } /* end */
8845};
8846
8847/* iMac 24 init verbs. */
Takashi Iwaia9111322011-05-02 11:30:18 +02008848static const struct hda_verb alc885_imac24_init_verbs[] = {
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008849 /* Internal speakers: output 0 (0x0c) */
8850 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8851 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8852 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8853 /* Internal speakers: output 0 (0x0c) */
8854 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8855 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8856 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8857 /* Headphone: output 0 (0x0c) */
8858 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8859 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8860 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8861 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8862 /* Front Mic: input vref at 80% */
8863 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8864 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8865 { }
8866};
8867
8868/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008869static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008870{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008871 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008872
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008873 spec->autocfg.hp_pins[0] = 0x14;
8874 spec->autocfg.speaker_pins[0] = 0x18;
8875 spec->autocfg.speaker_pins[1] = 0x1a;
Takashi Iwaid922b512011-04-28 12:18:53 +02008876 spec->automute = 1;
8877 spec->automute_mode = ALC_AUTOMUTE_AMP;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008878}
8879
Takashi Iwai9d54f082010-02-22 08:34:40 +01008880#define alc885_mb5_setup alc885_imac24_setup
8881#define alc885_macmini3_setup alc885_imac24_setup
8882
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008883/* Macbook Air 2,1 */
8884static void alc885_mba21_setup(struct hda_codec *codec)
8885{
8886 struct alc_spec *spec = codec->spec;
8887
8888 spec->autocfg.hp_pins[0] = 0x14;
8889 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwaid922b512011-04-28 12:18:53 +02008890 spec->automute = 1;
8891 spec->automute_mode = ALC_AUTOMUTE_AMP;
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008892}
8893
8894
8895
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008896static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008897{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008898 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008899
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008900 spec->autocfg.hp_pins[0] = 0x15;
8901 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +02008902 spec->automute = 1;
8903 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008904}
8905
Takashi Iwai9d54f082010-02-22 08:34:40 +01008906static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308907{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008908 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308909
Takashi Iwai9d54f082010-02-22 08:34:40 +01008910 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008911 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008912 spec->autocfg.speaker_pins[1] = 0x1a;
Takashi Iwaid922b512011-04-28 12:18:53 +02008913 spec->automute = 1;
8914 spec->automute_mode = ALC_AUTOMUTE_AMP;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008915}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008916
Takashi Iwaia9111322011-05-02 11:30:18 +02008917static const struct hda_verb alc882_targa_verbs[] = {
Kailang Yang272a5272007-05-14 11:00:38 +02008918 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8919 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8920
8921 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8922 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008923
Kailang Yang272a5272007-05-14 11:00:38 +02008924 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8925 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8926 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8927
8928 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008929 { } /* end */
8930};
8931
8932/* toggle speaker-output according to the hp-jack state */
8933static void alc882_targa_automute(struct hda_codec *codec)
8934{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008935 struct alc_spec *spec = codec->spec;
Takashi Iwaid922b512011-04-28 12:18:53 +02008936 alc_hp_automute(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008937 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008938 spec->jack_present ? 1 : 3);
8939}
8940
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008941static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008942{
8943 struct alc_spec *spec = codec->spec;
8944
8945 spec->autocfg.hp_pins[0] = 0x14;
8946 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaid922b512011-04-28 12:18:53 +02008947 spec->automute = 1;
8948 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yang272a5272007-05-14 11:00:38 +02008949}
8950
8951static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8952{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008953 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008954 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008955}
8956
Takashi Iwaia9111322011-05-02 11:30:18 +02008957static const struct hda_verb alc882_asus_a7j_verbs[] = {
Kailang Yang272a5272007-05-14 11:00:38 +02008958 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8959 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8960
8961 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8962 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8963 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008964
Kailang Yang272a5272007-05-14 11:00:38 +02008965 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8966 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8967 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8968
8969 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8970 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8971 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8972 { } /* end */
8973};
8974
Takashi Iwaia9111322011-05-02 11:30:18 +02008975static const struct hda_verb alc882_asus_a7m_verbs[] = {
Takashi Iwai914759b2007-09-06 14:52:04 +02008976 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8977 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8978
8979 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8980 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8981 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008982
Takashi Iwai914759b2007-09-06 14:52:04 +02008983 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8984 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8985 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8986
8987 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8988 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8989 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8990 { } /* end */
8991};
8992
Tobin Davis9102cd12006-12-15 10:02:12 +01008993static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8994{
8995 unsigned int gpiostate, gpiomask, gpiodir;
8996
8997 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8998 AC_VERB_GET_GPIO_DATA, 0);
8999
9000 if (!muted)
9001 gpiostate |= (1 << pin);
9002 else
9003 gpiostate &= ~(1 << pin);
9004
9005 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
9006 AC_VERB_GET_GPIO_MASK, 0);
9007 gpiomask |= (1 << pin);
9008
9009 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
9010 AC_VERB_GET_GPIO_DIRECTION, 0);
9011 gpiodir |= (1 << pin);
9012
9013
9014 snd_hda_codec_write(codec, codec->afg, 0,
9015 AC_VERB_SET_GPIO_MASK, gpiomask);
9016 snd_hda_codec_write(codec, codec->afg, 0,
9017 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
9018
9019 msleep(1);
9020
9021 snd_hda_codec_write(codec, codec->afg, 0,
9022 AC_VERB_SET_GPIO_DATA, gpiostate);
9023}
9024
Takashi Iwai7debbe52007-08-16 15:01:03 +02009025/* set up GPIO at initialization */
9026static void alc885_macpro_init_hook(struct hda_codec *codec)
9027{
9028 alc882_gpio_mute(codec, 0, 0);
9029 alc882_gpio_mute(codec, 1, 0);
9030}
9031
9032/* set up GPIO and update auto-muting at initialization */
9033static void alc885_imac24_init_hook(struct hda_codec *codec)
9034{
9035 alc885_macpro_init_hook(codec);
Takashi Iwaid922b512011-04-28 12:18:53 +02009036 alc_hp_automute(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02009037}
9038
Kailang Yangdf694da2005-12-05 19:42:22 +01009039/*
9040 * generic initialization of ADC, input mixers and output mixers
9041 */
Takashi Iwaia9111322011-05-02 11:30:18 +02009042static const struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01009043 /*
9044 * Unmute ADC0-2 and set the default input to mic-in
9045 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009046 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9047 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9048 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9049 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9050
Kailang Yangdf694da2005-12-05 19:42:22 +01009051 /*
9052 * Set up output mixers (0x0c - 0x0f)
9053 */
9054 /* set vol=0 to output mixers */
9055 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9056 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9057 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9058 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9059 /* set up input amps for analog loopback */
9060 /* Amp Indices: DAC = 0, mixer = 1 */
9061 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9062 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9063 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9064 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9065 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9066 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9067 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9068 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9069 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9070 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9071
9072 /* FIXME: use matrix-type input source selection */
9073 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01009074 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01009075 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009076 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01009077 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009078 { }
9079};
9080
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009081/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
Takashi Iwaia9111322011-05-02 11:30:18 +02009082static const struct hda_verb alc889A_mb31_ch2_init[] = {
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009083 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
9084 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
9085 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
9086 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
9087 { } /* end */
9088};
9089
9090/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
Takashi Iwaia9111322011-05-02 11:30:18 +02009091static const struct hda_verb alc889A_mb31_ch4_init[] = {
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009092 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
9093 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
9094 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
9095 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
9096 { } /* end */
9097};
9098
9099/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
Takashi Iwaia9111322011-05-02 11:30:18 +02009100static const struct hda_verb alc889A_mb31_ch5_init[] = {
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009101 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
9102 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
9103 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
9104 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
9105 { } /* end */
9106};
9107
9108/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
Takashi Iwaia9111322011-05-02 11:30:18 +02009109static const struct hda_verb alc889A_mb31_ch6_init[] = {
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009110 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
9111 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
9112 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
9113 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
9114 { } /* end */
9115};
9116
Takashi Iwaia9111322011-05-02 11:30:18 +02009117static const struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009118 { 2, alc889A_mb31_ch2_init },
9119 { 4, alc889A_mb31_ch4_init },
9120 { 5, alc889A_mb31_ch5_init },
9121 { 6, alc889A_mb31_ch6_init },
9122};
9123
Takashi Iwaia9111322011-05-02 11:30:18 +02009124static const struct hda_verb alc883_medion_eapd_verbs[] = {
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009125 /* eanable EAPD on medion laptop */
9126 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9127 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
9128 { }
9129};
9130
Takashi Iwai4953550a2009-06-30 15:28:30 +02009131#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009132
Takashi Iwaia9111322011-05-02 11:30:18 +02009133static const struct snd_kcontrol_new alc883_mitac_mixer[] = {
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009134 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9135 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9136 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9137 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9138 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9139 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9140 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9141 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009142 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009143 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9144 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009145 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009146 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009147 { } /* end */
9148};
9149
Takashi Iwaia9111322011-05-02 11:30:18 +02009150static const struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009151 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9152 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
9153 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9154 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
9155 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009156 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01009157 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009158 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009159 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009160 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01009161 { } /* end */
9162};
9163
Takashi Iwaia9111322011-05-02 11:30:18 +02009164static const struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
Jiang zhefb97dc62008-03-06 11:07:11 +01009165 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9166 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
9167 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9168 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
9169 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009170 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01009171 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009172 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009173 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009174 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01009175 { } /* end */
9176};
9177
Takashi Iwaia9111322011-05-02 11:30:18 +02009178static const struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009179 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9180 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9181 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9182 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9183 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9184 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9185 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9186 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009187 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009188 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9189 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009190 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009191 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009192 { } /* end */
9193};
9194
Takashi Iwaia9111322011-05-02 11:30:18 +02009195static const struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +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", 0x0d, 0x0, HDA_OUTPUT),
9199 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9200 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9201 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9202 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9203 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9204 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9205 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9206 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9207 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9208 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9209 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009210 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009211 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9212 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009213 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009214 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009215 { } /* end */
9216};
9217
Takashi Iwaia9111322011-05-02 11:30:18 +02009218static const struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
Jiang zhe17bba1b2008-06-04 12:11:07 +02009219 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9220 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9221 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9222 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9223 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
9224 HDA_OUTPUT),
9225 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9226 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9227 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9228 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9229 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9230 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9231 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9232 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9233 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009234 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02009235 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9236 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009237 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02009238 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02009239 { } /* end */
9240};
9241
Takashi Iwaia9111322011-05-02 11:30:18 +02009242static const struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009243 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9244 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9245 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9246 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9247 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
9248 HDA_OUTPUT),
9249 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9250 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9251 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9252 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9253 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
9254 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9255 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9256 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9257 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009258 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1b, 0, HDA_INPUT),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009259 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
9260 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009261 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009262 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9263 { } /* end */
9264};
9265
Takashi Iwaia9111322011-05-02 11:30:18 +02009266static const struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02009267 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02009268 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009269 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02009270 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009271 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9272 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02009273 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9274 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009275 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9276 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9277 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
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),
Tobin Davisc07584c2006-10-13 12:32:16 +02009282 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9283 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009284 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009285 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009286 { } /* end */
9287};
9288
Takashi Iwaia9111322011-05-02 11:30:18 +02009289static const struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009290 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009291 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009292 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009293 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009294 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9295 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9296 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9297 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9298 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9299 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9300 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9301 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9302 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9303 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9304 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009305 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009306 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009307 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009308};
Kailang Yangccc656c2006-10-17 12:32:26 +02009309
Takashi Iwaia9111322011-05-02 11:30:18 +02009310static const struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009311 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009312 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009313 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009314 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009315 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9316 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9317 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009318 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009319 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009320 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009321 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009322 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009323 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009324};
Kailang Yangccc656c2006-10-17 12:32:26 +02009325
Takashi Iwaia9111322011-05-02 11:30:18 +02009326static const struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +02009327 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9328 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009329 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009330 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009331 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009332 { } /* end */
9333};
9334
Takashi Iwaia9111322011-05-02 11:30:18 +02009335static const struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009336 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9337 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009338 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9339 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009340 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9341 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009342 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009343 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009344 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009345};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009346
Takashi Iwaia9111322011-05-02 11:30:18 +02009347static const struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
Kailang Yang272a5272007-05-14 11:00:38 +02009348 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9349 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
9350 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9351 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9352 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9353 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9354 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009355 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9356 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02009357 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02009358};
Kailang Yang272a5272007-05-14 11:00:38 +02009359
Takashi Iwaia9111322011-05-02 11:30:18 +02009360static const struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009361 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9362 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9363 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9364 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
9365 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
9366 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
9367 { } /* end */
9368};
9369
Takashi Iwaia9111322011-05-02 11:30:18 +02009370static const struct hda_verb alc883_medion_wim2160_verbs[] = {
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009371 /* Unmute front mixer */
9372 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9373 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9374
9375 /* Set speaker pin to front mixer */
9376 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9377
9378 /* Init headphone pin */
9379 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9380 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9381 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9382 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9383
9384 { } /* end */
9385};
9386
9387/* toggle speaker-output according to the hp-jack state */
9388static void alc883_medion_wim2160_setup(struct hda_codec *codec)
9389{
9390 struct alc_spec *spec = codec->spec;
9391
9392 spec->autocfg.hp_pins[0] = 0x1a;
9393 spec->autocfg.speaker_pins[0] = 0x15;
Takashi Iwaid922b512011-04-28 12:18:53 +02009394 spec->automute = 1;
9395 spec->automute_mode = ALC_AUTOMUTE_AMP;
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009396}
9397
Takashi Iwaia9111322011-05-02 11:30:18 +02009398static const struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02009399 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9400 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009401 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009402 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9403 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009404 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009405 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009406 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009407 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02009408};
Tobin Davis2880a862007-08-07 11:50:26 +02009409
Takashi Iwaia9111322011-05-02 11:30:18 +02009410static const struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
Tony Vroond2fd4b02009-06-21 00:40:10 +01009411 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009412 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01009413 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9414 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009415 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9416 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9417 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009418 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009419 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9420 { } /* end */
9421};
9422
Takashi Iwaia9111322011-05-02 11:30:18 +02009423static const struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009424 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9425 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9426 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9427 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
9428 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
9429 0x0d, 1, 0x0, HDA_OUTPUT),
9430 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
9431 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
9432 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
9433 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9434 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009435 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9436 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9437 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9438 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9439 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009440 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009441 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9442 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009443 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009444 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009445 { } /* end */
9446};
9447
Takashi Iwaia9111322011-05-02 11:30:18 +02009448static const struct snd_kcontrol_new alc889A_mb31_mixer[] = {
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009449 /* Output mixers */
9450 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
9451 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
9452 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
9453 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
9454 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
9455 HDA_OUTPUT),
9456 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
9457 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
9458 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
9459 /* Output switches */
9460 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
9461 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
9462 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
9463 /* Boost mixers */
David Henningsson5f99f862011-01-04 15:24:24 +01009464 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
9465 HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009466 /* Input mixers */
9467 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
9468 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
9469 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9470 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9471 { } /* end */
9472};
9473
Takashi Iwaia9111322011-05-02 11:30:18 +02009474static const struct snd_kcontrol_new alc883_vaiott_mixer[] = {
Guido Günther3e1647c52009-06-05 00:47:26 +02009475 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9476 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9477 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9478 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009479 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
Guido Günther3e1647c52009-06-05 00:47:26 +02009480 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9481 { } /* end */
9482};
9483
Takashi Iwaia9111322011-05-02 11:30:18 +02009484static const struct hda_bind_ctls alc883_bind_cap_vol = {
Kailang Yange2757d52008-08-26 13:17:46 +02009485 .ops = &snd_hda_bind_vol,
9486 .values = {
9487 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9488 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9489 0
9490 },
9491};
9492
Takashi Iwaia9111322011-05-02 11:30:18 +02009493static const struct hda_bind_ctls alc883_bind_cap_switch = {
Kailang Yange2757d52008-08-26 13:17:46 +02009494 .ops = &snd_hda_bind_sw,
9495 .values = {
9496 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9497 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9498 0
9499 },
9500};
9501
Takashi Iwaia9111322011-05-02 11:30:18 +02009502static const struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009503 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9504 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9505 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9506 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9507 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9508 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009509 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009510 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009511 { } /* end */
9512};
9513
Takashi Iwaia9111322011-05-02 11:30:18 +02009514static const struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009515 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
9516 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
9517 {
9518 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9519 /* .name = "Capture Source", */
9520 .name = "Input Source",
9521 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009522 .info = alc_mux_enum_info,
9523 .get = alc_mux_enum_get,
9524 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02009525 },
9526 { } /* end */
9527};
9528
Takashi Iwaia9111322011-05-02 11:30:18 +02009529static const struct snd_kcontrol_new alc883_chmode_mixer[] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009530 {
9531 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9532 .name = "Channel Mode",
9533 .info = alc_ch_mode_info,
9534 .get = alc_ch_mode_get,
9535 .put = alc_ch_mode_put,
9536 },
9537 { } /* end */
9538};
9539
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009540/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009541static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009542{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009543 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009544
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009545 spec->autocfg.hp_pins[0] = 0x15;
9546 spec->autocfg.speaker_pins[0] = 0x14;
9547 spec->autocfg.speaker_pins[1] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02009548 spec->automute = 1;
9549 spec->automute_mode = ALC_AUTOMUTE_AMP;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009550}
9551
Takashi Iwaia9111322011-05-02 11:30:18 +02009552static const struct hda_verb alc883_mitac_verbs[] = {
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009553 /* HP */
9554 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9555 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9556 /* Subwoofer */
9557 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9558 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9559
9560 /* enable unsolicited event */
9561 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9562 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
9563
9564 { } /* end */
9565};
9566
Takashi Iwaia9111322011-05-02 11:30:18 +02009567static const struct hda_verb alc883_clevo_m540r_verbs[] = {
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309568 /* HP */
9569 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9570 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9571 /* Int speaker */
9572 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
9573
9574 /* enable unsolicited event */
9575 /*
9576 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9577 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9578 */
9579
9580 { } /* end */
9581};
9582
Takashi Iwaia9111322011-05-02 11:30:18 +02009583static const struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009584 /* HP */
9585 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9586 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9587 /* Int speaker */
9588 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
9589 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9590
9591 /* enable unsolicited event */
9592 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009593 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01009594
9595 { } /* end */
9596};
9597
Takashi Iwaia9111322011-05-02 11:30:18 +02009598static const struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
Jiang zhefb97dc62008-03-06 11:07:11 +01009599 /* HP */
9600 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9601 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9602 /* Subwoofer */
9603 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9604 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9605
9606 /* enable unsolicited event */
9607 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9608
9609 { } /* end */
9610};
9611
Takashi Iwaia9111322011-05-02 11:30:18 +02009612static const struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009613 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9614 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9615
9616 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9617 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02009618
David Heidelberger64a8be72009-06-08 16:15:18 +02009619/* Connect Line-Out side jack (SPDIF) to Side */
9620 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9621 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9622 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9623/* Connect Mic jack to CLFE */
9624 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9625 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9626 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
9627/* Connect Line-in jack to Surround */
9628 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9629 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9630 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
9631/* Connect HP out jack to Front */
9632 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9633 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9634 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02009635
9636 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02009637
9638 { } /* end */
9639};
9640
Takashi Iwaia9111322011-05-02 11:30:18 +02009641static const struct hda_verb alc883_lenovo_101e_verbs[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009642 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9643 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
9644 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
9645 { } /* end */
9646};
9647
Takashi Iwaia9111322011-05-02 11:30:18 +02009648static const struct hda_verb alc883_lenovo_nb0763_verbs[] = {
Kailang Yang272a5272007-05-14 11:00:38 +02009649 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9650 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9651 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9652 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9653 { } /* end */
9654};
9655
Takashi Iwaia9111322011-05-02 11:30:18 +02009656static const struct hda_verb alc888_lenovo_ms7195_verbs[] = {
Kailang Yang272a5272007-05-14 11:00:38 +02009657 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9658 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9659 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9660 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
9661 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9662 { } /* end */
9663};
9664
Takashi Iwaia9111322011-05-02 11:30:18 +02009665static const struct hda_verb alc883_haier_w66_verbs[] = {
Kailang Yang189609a2007-08-20 11:31:23 +02009666 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9667 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9668
9669 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9670
9671 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9672 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9673 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9674 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9675 { } /* end */
9676};
9677
Takashi Iwaia9111322011-05-02 11:30:18 +02009678static const struct hda_verb alc888_lenovo_sky_verbs[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009679 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9680 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9681 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9682 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9683 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9684 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9685 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9686 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9687 { } /* end */
9688};
9689
Takashi Iwaia9111322011-05-02 11:30:18 +02009690static const struct hda_verb alc888_6st_dell_verbs[] = {
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009691 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9692 { }
9693};
9694
Takashi Iwaia9111322011-05-02 11:30:18 +02009695static const struct hda_verb alc883_vaiott_verbs[] = {
Guido Günther3e1647c52009-06-05 00:47:26 +02009696 /* HP */
9697 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9698 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9699
9700 /* enable unsolicited event */
9701 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9702
9703 { } /* end */
9704};
9705
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009706static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009707{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009708 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009709
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009710 spec->autocfg.hp_pins[0] = 0x1b;
9711 spec->autocfg.speaker_pins[0] = 0x14;
9712 spec->autocfg.speaker_pins[1] = 0x16;
9713 spec->autocfg.speaker_pins[2] = 0x18;
Takashi Iwaid922b512011-04-28 12:18:53 +02009714 spec->automute = 1;
9715 spec->automute_mode = ALC_AUTOMUTE_AMP;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009716}
9717
Takashi Iwaia9111322011-05-02 11:30:18 +02009718static const struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009719 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01009720 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
9721 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009722 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009723 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009724};
9725
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009726/*
9727 * 2ch mode
9728 */
Takashi Iwaia9111322011-05-02 11:30:18 +02009729static const struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009730 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9731 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9732 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9733 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009734 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009735};
9736
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009737/*
9738 * 4ch mode
9739 */
Takashi Iwaia9111322011-05-02 11:30:18 +02009740static const struct hda_verb alc888_3st_hp_4ch_init[] = {
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009741 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9742 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9743 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9744 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9745 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9746 { } /* end */
9747};
9748
9749/*
9750 * 6ch mode
9751 */
Takashi Iwaia9111322011-05-02 11:30:18 +02009752static const struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009753 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9754 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009755 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009756 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9757 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009758 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9759 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009760};
9761
Takashi Iwaia9111322011-05-02 11:30:18 +02009762static const struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009763 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009764 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009765 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009766};
9767
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02009768static void alc888_lenovo_ms7195_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009769{
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02009770 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009771
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02009772 spec->autocfg.hp_pins[0] = 0x1b;
9773 spec->autocfg.line_out_pins[0] = 0x14;
9774 spec->autocfg.speaker_pins[0] = 0x15;
9775 spec->automute = 1;
9776 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yang272a5272007-05-14 11:00:38 +02009777}
9778
Kailang Yang272a5272007-05-14 11:00:38 +02009779/* toggle speaker-output according to the hp-jack state */
Takashi Iwaidc4271702010-11-29 07:42:59 +01009780static void alc883_lenovo_nb0763_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009781{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009782 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009783
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009784 spec->autocfg.hp_pins[0] = 0x14;
9785 spec->autocfg.speaker_pins[0] = 0x15;
Takashi Iwaid922b512011-04-28 12:18:53 +02009786 spec->automute = 1;
9787 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yang272a5272007-05-14 11:00:38 +02009788}
9789
Kailang Yangccc656c2006-10-17 12:32:26 +02009790/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009791#define alc883_targa_init_hook alc882_targa_init_hook
9792#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009793
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009794static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009795{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009796 struct alc_spec *spec = codec->spec;
9797
9798 spec->autocfg.hp_pins[0] = 0x15;
9799 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +02009800 spec->automute = 1;
9801 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009802}
9803
9804static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9805{
Takashi Iwaid922b512011-04-28 12:18:53 +02009806 alc_hp_automute(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +01009807 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009808}
9809
9810static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009811 unsigned int res)
9812{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009813 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009814 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +01009815 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009816 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009817 default:
Takashi Iwaid922b512011-04-28 12:18:53 +02009818 alc_sku_unsol_event(codec, res);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009819 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009820 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009821}
9822
Jiang zhefb97dc62008-03-06 11:07:11 +01009823/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009824static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009825{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009826 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009827
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009828 spec->autocfg.hp_pins[0] = 0x14;
9829 spec->autocfg.speaker_pins[0] = 0x15;
Takashi Iwaid922b512011-04-28 12:18:53 +02009830 spec->automute = 1;
9831 spec->automute_mode = ALC_AUTOMUTE_AMP;
Jiang zhefb97dc62008-03-06 11:07:11 +01009832}
9833
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009834static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009835{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009836 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009837
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009838 spec->autocfg.hp_pins[0] = 0x1b;
9839 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +02009840 spec->automute = 1;
9841 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yang189609a2007-08-20 11:31:23 +02009842}
9843
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02009844static void alc883_lenovo_101e_setup(struct hda_codec *codec)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009845{
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02009846 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009847
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +02009848 spec->autocfg.hp_pins[0] = 0x1b;
9849 spec->autocfg.line_out_pins[0] = 0x14;
9850 spec->autocfg.speaker_pins[0] = 0x15;
9851 spec->automute = 1;
9852 spec->detect_line = 1;
9853 spec->automute_lines = 1;
9854 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009855}
9856
Takashi Iwai676a9b52007-08-16 15:23:35 +02009857/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009858static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009859{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009860 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009861
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009862 spec->autocfg.hp_pins[0] = 0x14;
9863 spec->autocfg.speaker_pins[0] = 0x15;
9864 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwaid922b512011-04-28 12:18:53 +02009865 spec->automute = 1;
9866 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009867}
9868
Takashi Iwaia9111322011-05-02 11:30:18 +02009869static const struct hda_verb alc883_acer_eapd_verbs[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02009870 /* HP Pin: output 0 (0x0c) */
9871 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9872 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9873 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9874 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009875 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9876 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009877 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009878 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9879 /* eanable EAPD on medion laptop */
9880 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9881 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009882 /* enable unsolicited event */
9883 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009884 { }
9885};
9886
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009887static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009888{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009889 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009890
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009891 spec->autocfg.hp_pins[0] = 0x1b;
9892 spec->autocfg.speaker_pins[0] = 0x14;
9893 spec->autocfg.speaker_pins[1] = 0x15;
9894 spec->autocfg.speaker_pins[2] = 0x16;
9895 spec->autocfg.speaker_pins[3] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02009896 spec->automute = 1;
9897 spec->automute_mode = ALC_AUTOMUTE_AMP;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009898}
9899
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009900static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009901{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009902 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009903
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009904 spec->autocfg.hp_pins[0] = 0x1b;
9905 spec->autocfg.speaker_pins[0] = 0x14;
9906 spec->autocfg.speaker_pins[1] = 0x15;
9907 spec->autocfg.speaker_pins[2] = 0x16;
9908 spec->autocfg.speaker_pins[3] = 0x17;
9909 spec->autocfg.speaker_pins[4] = 0x1a;
Takashi Iwaid922b512011-04-28 12:18:53 +02009910 spec->automute = 1;
9911 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yange2757d52008-08-26 13:17:46 +02009912}
9913
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009914static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c52009-06-05 00:47:26 +02009915{
9916 struct alc_spec *spec = codec->spec;
9917
9918 spec->autocfg.hp_pins[0] = 0x15;
9919 spec->autocfg.speaker_pins[0] = 0x14;
9920 spec->autocfg.speaker_pins[1] = 0x17;
Takashi Iwaid922b512011-04-28 12:18:53 +02009921 spec->automute = 1;
9922 spec->automute_mode = ALC_AUTOMUTE_AMP;
Guido Günther3e1647c52009-06-05 00:47:26 +02009923}
9924
Takashi Iwaia9111322011-05-02 11:30:18 +02009925static const struct hda_verb alc888_asus_m90v_verbs[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009926 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9927 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9928 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9929 /* enable unsolicited event */
9930 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9931 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9932 { } /* end */
9933};
9934
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009935static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009936{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009937 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009938
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009939 spec->autocfg.hp_pins[0] = 0x1b;
9940 spec->autocfg.speaker_pins[0] = 0x14;
9941 spec->autocfg.speaker_pins[1] = 0x15;
9942 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009943 spec->ext_mic.pin = 0x18;
9944 spec->int_mic.pin = 0x19;
9945 spec->ext_mic.mux_idx = 0;
9946 spec->int_mic.mux_idx = 1;
9947 spec->auto_mic = 1;
Takashi Iwaid922b512011-04-28 12:18:53 +02009948 spec->automute = 1;
9949 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yange2757d52008-08-26 13:17:46 +02009950}
9951
Takashi Iwaia9111322011-05-02 11:30:18 +02009952static const struct hda_verb alc888_asus_eee1601_verbs[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009953 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9954 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9955 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9956 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9957 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9958 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9959 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9960 /* enable unsolicited event */
9961 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9962 { } /* end */
9963};
9964
Kailang Yange2757d52008-08-26 13:17:46 +02009965static void alc883_eee1601_inithook(struct hda_codec *codec)
9966{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009967 struct alc_spec *spec = codec->spec;
9968
9969 spec->autocfg.hp_pins[0] = 0x14;
9970 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaid922b512011-04-28 12:18:53 +02009971 alc_hp_automute(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009972}
9973
Takashi Iwaia9111322011-05-02 11:30:18 +02009974static const struct hda_verb alc889A_mb31_verbs[] = {
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009975 /* Init rear pin (used as headphone output) */
9976 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9977 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9978 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9979 /* Init line pin (used as output in 4ch and 6ch mode) */
9980 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9981 /* Init line 2 pin (used as headphone out by default) */
9982 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9983 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9984 { } /* end */
9985};
9986
9987/* Mute speakers according to the headphone jack state */
9988static void alc889A_mb31_automute(struct hda_codec *codec)
9989{
9990 unsigned int present;
9991
9992 /* Mute only in 2ch or 4ch mode */
9993 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9994 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009995 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009996 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9997 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9998 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9999 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
10000 }
10001}
10002
10003static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
10004{
10005 if ((res >> 26) == ALC880_HP_EVENT)
10006 alc889A_mb31_automute(codec);
10007}
10008
Takashi Iwai4953550a2009-06-30 15:28:30 +020010009
Takashi Iwaicb53c622007-08-10 17:21:45 +020010010#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +020010011#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +020010012#endif
10013
Sasha Alexandrdef319f2009-06-16 16:00:15 -040010014/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010015#define alc882_pcm_analog_playback alc880_pcm_analog_playback
10016#define alc882_pcm_analog_capture alc880_pcm_analog_capture
10017#define alc882_pcm_digital_playback alc880_pcm_digital_playback
10018#define alc882_pcm_digital_capture alc880_pcm_digital_capture
10019
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020010020static const hda_nid_t alc883_slave_dig_outs[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +020010021 ALC1200_DIGOUT_NID, 0,
10022};
10023
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020010024static const hda_nid_t alc1200_slave_dig_outs[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +020010025 ALC883_DIGOUT_NID, 0,
10026};
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010027
10028/*
10029 * configuration and preset
10030 */
Takashi Iwaiea734962011-01-17 11:29:34 +010010031static const char * const alc882_models[ALC882_MODEL_LAST] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +020010032 [ALC882_3ST_DIG] = "3stack-dig",
10033 [ALC882_6ST_DIG] = "6stack-dig",
10034 [ALC882_ARIMA] = "arima",
10035 [ALC882_W2JC] = "w2jc",
10036 [ALC882_TARGA] = "targa",
10037 [ALC882_ASUS_A7J] = "asus-a7j",
10038 [ALC882_ASUS_A7M] = "asus-a7m",
10039 [ALC885_MACPRO] = "macpro",
10040 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010041 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -080010042 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010043 [ALC885_MBP3] = "mbp3",
10044 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010045 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010046 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010047 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
10048 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010049 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010050 [ALC883_TARGA_DIG] = "targa-dig",
10051 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +020010052 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010053 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +020010054 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010055 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +020010056 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +020010057 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010058 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010059 [ALC883_MEDION] = "medion",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010060 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010061 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010062 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +020010063 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
10064 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +020010065 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +020010066 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010067 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010068 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010069 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010070 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010071 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +010010072 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010073 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +020010074 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010075 [ALC889A_INTEL] = "intel-alc889a",
10076 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +010010077 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010078 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c52009-06-05 00:47:26 +020010079 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010080 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010081};
10082
Takashi Iwaia9111322011-05-02 11:30:18 +020010083static const struct snd_pci_quirk alc882_cfg_tbl[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +020010084 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
10085
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010086 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +010010087 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +010010088 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010089 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
10090 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +020010091 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010092 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
10093 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +010010094 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +010010095 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +020010096 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
10097 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +020010098 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
10099 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010100 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
10101 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +010010102 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +020010103 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +010010104 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +010010105 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010106 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
10107 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +020010108 /* default Acer -- disabled as it causes more problems.
10109 * model=auto should work fine now
10110 */
10111 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010112
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010113 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010114
Lucas De Marchi25985ed2011-03-30 22:57:33 -030010115 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavilion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010116 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
10117 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +010010118 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +010010119 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -030010120 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010121
10122 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
10123 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
10124 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +020010125 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010126 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
10127 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
10128 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010129 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +010010130 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +010010131 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +020010132 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010133
10134 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +020010135 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010136 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +110010137 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010138 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
10139 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +020010140 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010141 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwaiebb47242011-05-02 10:37:29 +020010142 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010143
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010144 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
10145 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
10146 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010147 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +010010148 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010149 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010150 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +010010151 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010152 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
10153 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
10154 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
10155 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
10156 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
10157 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -070010158 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010159 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
10160 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
10161 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +010010162 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +020010163 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010164 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
10165 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +020010166 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +010010167 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +010010168 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +010010169 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +020010170 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -040010171 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +010010172 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010173 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -070010174 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010175
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010176 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +020010177 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010178 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
10179 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010180 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010181 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -040010182 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010183 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010184 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +020010185 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +010010186 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +020010187 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010188 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +020010189 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +020010190 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010191 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
10192 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +020010193 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Takashi Iwai959973b2008-11-05 11:30:56 +010010194 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +010010195 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +020010196 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010197
Jiang zhe17bba1b2008-06-04 12:11:07 +020010198 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
10199 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +110010200 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010201 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
10202 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
10203 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -040010204 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010205
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010206 {}
10207};
10208
Takashi Iwai4953550a2009-06-30 15:28:30 +020010209/* codec SSID table for Intel Mac */
Takashi Iwaia9111322011-05-02 11:30:18 +020010210static const struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +020010211 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
10212 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
10213 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
10214 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
10215 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
10216 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
10217 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -040010218 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -070010219 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -070010220 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -070010221 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010222 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
10223 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
10224 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010225 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010226 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Luke Yelavich3bfea982010-06-22 11:04:19 +100010227 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -050010228 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
10229 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +020010230 */
10231 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -050010232 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010233 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010234 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010235};
10236
Takashi Iwaia9111322011-05-02 11:30:18 +020010237static const struct alc_config_preset alc882_presets[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +020010238 [ALC882_3ST_DIG] = {
10239 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010240 .init_verbs = { alc882_base_init_verbs,
10241 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010242 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10243 .dac_nids = alc882_dac_nids,
10244 .dig_out_nid = ALC882_DIGOUT_NID,
10245 .dig_in_nid = ALC882_DIGIN_NID,
10246 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10247 .channel_mode = alc882_ch_modes,
10248 .need_dac_fix = 1,
10249 .input_mux = &alc882_capture_source,
10250 },
10251 [ALC882_6ST_DIG] = {
10252 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010253 .init_verbs = { alc882_base_init_verbs,
10254 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010255 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10256 .dac_nids = alc882_dac_nids,
10257 .dig_out_nid = ALC882_DIGOUT_NID,
10258 .dig_in_nid = ALC882_DIGIN_NID,
10259 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
10260 .channel_mode = alc882_sixstack_modes,
10261 .input_mux = &alc882_capture_source,
10262 },
10263 [ALC882_ARIMA] = {
10264 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010265 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10266 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010267 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10268 .dac_nids = alc882_dac_nids,
10269 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
10270 .channel_mode = alc882_sixstack_modes,
10271 .input_mux = &alc882_capture_source,
10272 },
10273 [ALC882_W2JC] = {
10274 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010275 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10276 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010277 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10278 .dac_nids = alc882_dac_nids,
10279 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10280 .channel_mode = alc880_threestack_modes,
10281 .need_dac_fix = 1,
10282 .input_mux = &alc882_capture_source,
10283 .dig_out_nid = ALC882_DIGOUT_NID,
10284 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -080010285 [ALC885_MBA21] = {
10286 .mixers = { alc885_mba21_mixer },
10287 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
10288 .num_dacs = 2,
10289 .dac_nids = alc882_dac_nids,
10290 .channel_mode = alc885_mba21_ch_modes,
10291 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10292 .input_mux = &alc882_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010293 .unsol_event = alc_sku_unsol_event,
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -080010294 .setup = alc885_mba21_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010295 .init_hook = alc_hp_automute,
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -080010296 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010297 [ALC885_MBP3] = {
10298 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
10299 .init_verbs = { alc885_mbp3_init_verbs,
10300 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +020010301 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010302 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +020010303 .hp_nid = 0x04,
10304 .channel_mode = alc885_mbp_4ch_modes,
10305 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010306 .input_mux = &alc882_capture_source,
10307 .dig_out_nid = ALC882_DIGOUT_NID,
10308 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaid922b512011-04-28 12:18:53 +020010309 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010310 .setup = alc885_mbp3_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010311 .init_hook = alc_hp_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010312 },
10313 [ALC885_MB5] = {
10314 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
10315 .init_verbs = { alc885_mb5_init_verbs,
10316 alc880_gpio1_init_verbs },
10317 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10318 .dac_nids = alc882_dac_nids,
10319 .channel_mode = alc885_mb5_6ch_modes,
10320 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
10321 .input_mux = &mb5_capture_source,
10322 .dig_out_nid = ALC882_DIGOUT_NID,
10323 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaid922b512011-04-28 12:18:53 +020010324 .unsol_event = alc_sku_unsol_event,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010325 .setup = alc885_mb5_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010326 .init_hook = alc_hp_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010327 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010328 [ALC885_MACMINI3] = {
10329 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
10330 .init_verbs = { alc885_macmini3_init_verbs,
10331 alc880_gpio1_init_verbs },
10332 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10333 .dac_nids = alc882_dac_nids,
10334 .channel_mode = alc885_macmini3_6ch_modes,
10335 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
10336 .input_mux = &macmini3_capture_source,
10337 .dig_out_nid = ALC882_DIGOUT_NID,
10338 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaid922b512011-04-28 12:18:53 +020010339 .unsol_event = alc_sku_unsol_event,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010340 .setup = alc885_macmini3_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010341 .init_hook = alc_hp_automute,
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010342 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010343 [ALC885_MACPRO] = {
10344 .mixers = { alc882_macpro_mixer },
10345 .init_verbs = { alc882_macpro_init_verbs },
10346 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10347 .dac_nids = alc882_dac_nids,
10348 .dig_out_nid = ALC882_DIGOUT_NID,
10349 .dig_in_nid = ALC882_DIGIN_NID,
10350 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10351 .channel_mode = alc882_ch_modes,
10352 .input_mux = &alc882_capture_source,
10353 .init_hook = alc885_macpro_init_hook,
10354 },
10355 [ALC885_IMAC24] = {
10356 .mixers = { alc885_imac24_mixer },
10357 .init_verbs = { alc885_imac24_init_verbs },
10358 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10359 .dac_nids = alc882_dac_nids,
10360 .dig_out_nid = ALC882_DIGOUT_NID,
10361 .dig_in_nid = ALC882_DIGIN_NID,
10362 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10363 .channel_mode = alc882_ch_modes,
10364 .input_mux = &alc882_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010365 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010366 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010367 .init_hook = alc885_imac24_init_hook,
10368 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010369 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010370 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010371 .init_verbs = { alc885_imac91_init_verbs,
10372 alc880_gpio1_init_verbs },
10373 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10374 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010375 .channel_mode = alc885_mba21_ch_modes,
10376 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10377 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010378 .dig_out_nid = ALC882_DIGOUT_NID,
10379 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaid922b512011-04-28 12:18:53 +020010380 .unsol_event = alc_sku_unsol_event,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010381 .setup = alc885_imac91_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010382 .init_hook = alc_hp_automute,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010383 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010384 [ALC882_TARGA] = {
10385 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010386 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +020010387 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010388 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10389 .dac_nids = alc882_dac_nids,
10390 .dig_out_nid = ALC882_DIGOUT_NID,
10391 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10392 .adc_nids = alc882_adc_nids,
10393 .capsrc_nids = alc882_capsrc_nids,
10394 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10395 .channel_mode = alc882_3ST_6ch_modes,
10396 .need_dac_fix = 1,
10397 .input_mux = &alc882_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010398 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010399 .setup = alc882_targa_setup,
10400 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010401 },
10402 [ALC882_ASUS_A7J] = {
10403 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010404 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10405 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010406 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10407 .dac_nids = alc882_dac_nids,
10408 .dig_out_nid = ALC882_DIGOUT_NID,
10409 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10410 .adc_nids = alc882_adc_nids,
10411 .capsrc_nids = alc882_capsrc_nids,
10412 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10413 .channel_mode = alc882_3ST_6ch_modes,
10414 .need_dac_fix = 1,
10415 .input_mux = &alc882_capture_source,
10416 },
10417 [ALC882_ASUS_A7M] = {
10418 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010419 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10420 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010421 alc882_asus_a7m_verbs },
10422 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10423 .dac_nids = alc882_dac_nids,
10424 .dig_out_nid = ALC882_DIGOUT_NID,
10425 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10426 .channel_mode = alc880_threestack_modes,
10427 .need_dac_fix = 1,
10428 .input_mux = &alc882_capture_source,
10429 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010430 [ALC883_3ST_2ch_DIG] = {
10431 .mixers = { alc883_3ST_2ch_mixer },
10432 .init_verbs = { alc883_init_verbs },
10433 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10434 .dac_nids = alc883_dac_nids,
10435 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010436 .dig_in_nid = ALC883_DIGIN_NID,
10437 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10438 .channel_mode = alc883_3ST_2ch_modes,
10439 .input_mux = &alc883_capture_source,
10440 },
10441 [ALC883_3ST_6ch_DIG] = {
10442 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10443 .init_verbs = { alc883_init_verbs },
10444 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10445 .dac_nids = alc883_dac_nids,
10446 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010447 .dig_in_nid = ALC883_DIGIN_NID,
10448 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10449 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010450 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010451 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010452 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010453 [ALC883_3ST_6ch] = {
10454 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10455 .init_verbs = { alc883_init_verbs },
10456 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10457 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010458 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10459 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010460 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010461 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010462 },
Jiang zhe17bba1b2008-06-04 12:11:07 +020010463 [ALC883_3ST_6ch_INTEL] = {
10464 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
10465 .init_verbs = { alc883_init_verbs },
10466 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10467 .dac_nids = alc883_dac_nids,
10468 .dig_out_nid = ALC883_DIGOUT_NID,
10469 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010470 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +020010471 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
10472 .channel_mode = alc883_3ST_6ch_intel_modes,
10473 .need_dac_fix = 1,
10474 .input_mux = &alc883_3stack_6ch_intel,
10475 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010476 [ALC889A_INTEL] = {
10477 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020010478 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
10479 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010480 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10481 .dac_nids = alc883_dac_nids,
10482 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10483 .adc_nids = alc889_adc_nids,
10484 .dig_out_nid = ALC883_DIGOUT_NID,
10485 .dig_in_nid = ALC883_DIGIN_NID,
10486 .slave_dig_outs = alc883_slave_dig_outs,
10487 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10488 .channel_mode = alc889_8ch_intel_modes,
10489 .capsrc_nids = alc889_capsrc_nids,
10490 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010491 .setup = alc889_automute_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010492 .init_hook = alc_hp_automute,
10493 .unsol_event = alc_sku_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010494 .need_dac_fix = 1,
10495 },
10496 [ALC889_INTEL] = {
10497 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
10498 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010499 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010500 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10501 .dac_nids = alc883_dac_nids,
10502 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10503 .adc_nids = alc889_adc_nids,
10504 .dig_out_nid = ALC883_DIGOUT_NID,
10505 .dig_in_nid = ALC883_DIGIN_NID,
10506 .slave_dig_outs = alc883_slave_dig_outs,
10507 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10508 .channel_mode = alc889_8ch_intel_modes,
10509 .capsrc_nids = alc889_capsrc_nids,
10510 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010511 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010512 .init_hook = alc889_intel_init_hook,
Takashi Iwaid922b512011-04-28 12:18:53 +020010513 .unsol_event = alc_sku_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010514 .need_dac_fix = 1,
10515 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010516 [ALC883_6ST_DIG] = {
10517 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10518 .init_verbs = { alc883_init_verbs },
10519 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10520 .dac_nids = alc883_dac_nids,
10521 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010522 .dig_in_nid = ALC883_DIGIN_NID,
10523 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10524 .channel_mode = alc883_sixstack_modes,
10525 .input_mux = &alc883_capture_source,
10526 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010527 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010528 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +020010529 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10530 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010531 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10532 .dac_nids = alc883_dac_nids,
10533 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010534 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10535 .channel_mode = alc883_3ST_6ch_modes,
10536 .need_dac_fix = 1,
10537 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010538 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010539 .setup = alc882_targa_setup,
10540 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010541 },
10542 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010543 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +020010544 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10545 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010546 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10547 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010548 .adc_nids = alc883_adc_nids_alt,
10549 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010550 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +020010551 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010552 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10553 .channel_mode = alc883_3ST_2ch_modes,
10554 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010555 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010556 .setup = alc882_targa_setup,
10557 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010558 },
David Heidelberger64a8be72009-06-08 16:15:18 +020010559 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +020010560 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
10561 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +020010562 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010563 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +020010564 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10565 .dac_nids = alc883_dac_nids,
10566 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10567 .adc_nids = alc883_adc_nids_rev,
10568 .capsrc_nids = alc883_capsrc_nids_rev,
10569 .dig_out_nid = ALC883_DIGOUT_NID,
10570 .dig_in_nid = ALC883_DIGIN_NID,
10571 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
10572 .channel_mode = alc883_4ST_8ch_modes,
10573 .need_dac_fix = 1,
10574 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010575 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010576 .setup = alc882_targa_setup,
10577 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +020010578 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010579 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010580 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010581 /* On TravelMate laptops, GPIO 0 enables the internal speaker
10582 * and the headphone jack. Turn this on and rely on the
10583 * standard mute methods whenever the user wants to turn
10584 * these outputs off.
10585 */
10586 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
10587 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10588 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010589 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10590 .channel_mode = alc883_3ST_2ch_modes,
10591 .input_mux = &alc883_capture_source,
10592 },
Tobin Davis2880a862007-08-07 11:50:26 +020010593 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010594 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010595 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +020010596 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10597 .dac_nids = alc883_dac_nids,
10598 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +020010599 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10600 .channel_mode = alc883_3ST_2ch_modes,
10601 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010602 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010603 .setup = alc883_acer_aspire_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010604 .init_hook = alc_hp_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010605 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010606 [ALC888_ACER_ASPIRE_4930G] = {
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +010010607 .mixers = { alc888_acer_aspire_4930g_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010608 alc883_chmode_mixer },
10609 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10610 alc888_acer_aspire_4930g_verbs },
10611 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10612 .dac_nids = alc883_dac_nids,
10613 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10614 .adc_nids = alc883_adc_nids_rev,
10615 .capsrc_nids = alc883_capsrc_nids_rev,
10616 .dig_out_nid = ALC883_DIGOUT_NID,
10617 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10618 .channel_mode = alc883_3ST_6ch_modes,
10619 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +010010620 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010621 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010622 ARRAY_SIZE(alc888_2_capture_sources),
10623 .input_mux = alc888_2_capture_sources,
Takashi Iwaid922b512011-04-28 12:18:53 +020010624 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010625 .setup = alc888_acer_aspire_4930g_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010626 .init_hook = alc_hp_automute,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010627 },
Tony Vroond2fd4b02009-06-21 00:40:10 +010010628 [ALC888_ACER_ASPIRE_6530G] = {
10629 .mixers = { alc888_acer_aspire_6530_mixer },
10630 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10631 alc888_acer_aspire_6530g_verbs },
10632 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10633 .dac_nids = alc883_dac_nids,
10634 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10635 .adc_nids = alc883_adc_nids_rev,
10636 .capsrc_nids = alc883_capsrc_nids_rev,
10637 .dig_out_nid = ALC883_DIGOUT_NID,
10638 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10639 .channel_mode = alc883_3ST_2ch_modes,
10640 .num_mux_defs =
10641 ARRAY_SIZE(alc888_2_capture_sources),
10642 .input_mux = alc888_acer_aspire_6530_sources,
Takashi Iwaid922b512011-04-28 12:18:53 +020010643 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010644 .setup = alc888_acer_aspire_6530g_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010645 .init_hook = alc_hp_automute,
Tony Vroond2fd4b02009-06-21 00:40:10 +010010646 },
Hector Martin3b315d72009-06-02 10:54:19 +020010647 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +010010648 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +020010649 alc883_chmode_mixer },
10650 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +010010651 alc889_acer_aspire_8930g_verbs,
10652 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +020010653 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10654 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +020010655 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10656 .adc_nids = alc889_adc_nids,
10657 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +020010658 .dig_out_nid = ALC883_DIGOUT_NID,
10659 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10660 .channel_mode = alc883_3ST_6ch_modes,
10661 .need_dac_fix = 1,
10662 .const_channel_count = 6,
10663 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +020010664 ARRAY_SIZE(alc889_capture_sources),
10665 .input_mux = alc889_capture_sources,
Takashi Iwaid922b512011-04-28 12:18:53 +020010666 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010667 .setup = alc889_acer_aspire_8930g_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010668 .init_hook = alc_hp_automute,
Hector Martinf5de24b2009-12-20 22:51:31 +010010669#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050010670 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +010010671#endif
Hector Martin3b315d72009-06-02 10:54:19 +020010672 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010673 [ALC888_ACER_ASPIRE_7730G] = {
10674 .mixers = { alc883_3ST_6ch_mixer,
10675 alc883_chmode_mixer },
10676 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10677 alc888_acer_aspire_7730G_verbs },
10678 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10679 .dac_nids = alc883_dac_nids,
10680 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10681 .adc_nids = alc883_adc_nids_rev,
10682 .capsrc_nids = alc883_capsrc_nids_rev,
10683 .dig_out_nid = ALC883_DIGOUT_NID,
10684 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10685 .channel_mode = alc883_3ST_6ch_modes,
10686 .need_dac_fix = 1,
10687 .const_channel_count = 6,
10688 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010689 .unsol_event = alc_sku_unsol_event,
Denis Kuplyakovd9477202010-11-24 06:01:09 +010010690 .setup = alc888_acer_aspire_7730g_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010691 .init_hook = alc_hp_automute,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010692 },
Tobin Davisc07584c2006-10-13 12:32:16 +020010693 [ALC883_MEDION] = {
10694 .mixers = { alc883_fivestack_mixer,
10695 alc883_chmode_mixer },
10696 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010697 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +020010698 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10699 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010700 .adc_nids = alc883_adc_nids_alt,
10701 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010702 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +020010703 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10704 .channel_mode = alc883_sixstack_modes,
10705 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010706 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010707 [ALC883_MEDION_WIM2160] = {
10708 .mixers = { alc883_medion_wim2160_mixer },
10709 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
10710 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10711 .dac_nids = alc883_dac_nids,
10712 .dig_out_nid = ALC883_DIGOUT_NID,
10713 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
10714 .adc_nids = alc883_adc_nids,
10715 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10716 .channel_mode = alc883_3ST_2ch_modes,
10717 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010718 .unsol_event = alc_sku_unsol_event,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010719 .setup = alc883_medion_wim2160_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010720 .init_hook = alc_hp_automute,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010721 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010722 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010723 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010724 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10725 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10726 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010727 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10728 .channel_mode = alc883_3ST_2ch_modes,
10729 .input_mux = &alc883_capture_source,
10730 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010731 [ALC883_CLEVO_M540R] = {
10732 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10733 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10734 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10735 .dac_nids = alc883_dac_nids,
10736 .dig_out_nid = ALC883_DIGOUT_NID,
10737 .dig_in_nid = ALC883_DIGIN_NID,
10738 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10739 .channel_mode = alc883_3ST_6ch_clevo_modes,
10740 .need_dac_fix = 1,
10741 .input_mux = &alc883_capture_source,
10742 /* This machine has the hardware HP auto-muting, thus
10743 * we need no software mute via unsol event
10744 */
10745 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010746 [ALC883_CLEVO_M720] = {
10747 .mixers = { alc883_clevo_m720_mixer },
10748 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010749 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10750 .dac_nids = alc883_dac_nids,
10751 .dig_out_nid = ALC883_DIGOUT_NID,
10752 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10753 .channel_mode = alc883_3ST_2ch_modes,
10754 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010755 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010756 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010757 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010758 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010759 [ALC883_LENOVO_101E_2ch] = {
10760 .mixers = { alc883_lenovo_101e_2ch_mixer},
10761 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10762 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10763 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010764 .adc_nids = alc883_adc_nids_alt,
10765 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010766 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010767 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10768 .channel_mode = alc883_3ST_2ch_modes,
10769 .input_mux = &alc883_lenovo_101e_capture_source,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020010770 .setup = alc883_lenovo_101e_setup,
10771 .unsol_event = alc_sku_unsol_event,
10772 .init_hook = alc_inithook,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010773 },
Kailang Yang272a5272007-05-14 11:00:38 +020010774 [ALC883_LENOVO_NB0763] = {
10775 .mixers = { alc883_lenovo_nb0763_mixer },
10776 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10777 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10778 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010779 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10780 .channel_mode = alc883_3ST_2ch_modes,
10781 .need_dac_fix = 1,
10782 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010783 .unsol_event = alc_sku_unsol_event,
Takashi Iwaidc4271702010-11-29 07:42:59 +010010784 .setup = alc883_lenovo_nb0763_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010785 .init_hook = alc_hp_automute,
Kailang Yang272a5272007-05-14 11:00:38 +020010786 },
10787 [ALC888_LENOVO_MS7195_DIG] = {
10788 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10789 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10790 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10791 .dac_nids = alc883_dac_nids,
10792 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010793 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10794 .channel_mode = alc883_3ST_6ch_modes,
10795 .need_dac_fix = 1,
10796 .input_mux = &alc883_capture_source,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020010797 .unsol_event = alc_sku_unsol_event,
10798 .setup = alc888_lenovo_ms7195_setup,
10799 .init_hook = alc_inithook,
Kailang Yang189609a2007-08-20 11:31:23 +020010800 },
10801 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010802 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010803 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10804 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10805 .dac_nids = alc883_dac_nids,
10806 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010807 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10808 .channel_mode = alc883_3ST_2ch_modes,
10809 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010810 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010811 .setup = alc883_haier_w66_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010812 .init_hook = alc_hp_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010813 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010814 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010815 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010816 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010817 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10818 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010819 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10820 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010821 .need_dac_fix = 1,
10822 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010823 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010824 .setup = alc888_3st_hp_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010825 .init_hook = alc_hp_automute,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010826 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010827 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010828 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010829 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10830 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10831 .dac_nids = alc883_dac_nids,
10832 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010833 .dig_in_nid = ALC883_DIGIN_NID,
10834 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10835 .channel_mode = alc883_sixstack_modes,
10836 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010837 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010838 .setup = alc888_6st_dell_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010839 .init_hook = alc_hp_automute,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010840 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010841 [ALC883_MITAC] = {
10842 .mixers = { alc883_mitac_mixer },
10843 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10844 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10845 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010846 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10847 .channel_mode = alc883_3ST_2ch_modes,
10848 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010849 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010850 .setup = alc883_mitac_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010851 .init_hook = alc_hp_automute,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010852 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010853 [ALC883_FUJITSU_PI2515] = {
10854 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10855 .init_verbs = { alc883_init_verbs,
10856 alc883_2ch_fujitsu_pi2515_verbs},
10857 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10858 .dac_nids = alc883_dac_nids,
10859 .dig_out_nid = ALC883_DIGOUT_NID,
10860 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10861 .channel_mode = alc883_3ST_2ch_modes,
10862 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010863 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010864 .setup = alc883_2ch_fujitsu_pi2515_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010865 .init_hook = alc_hp_automute,
Jiang zhefb97dc62008-03-06 11:07:11 +010010866 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010867 [ALC888_FUJITSU_XA3530] = {
10868 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10869 .init_verbs = { alc883_init_verbs,
10870 alc888_fujitsu_xa3530_verbs },
10871 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10872 .dac_nids = alc883_dac_nids,
10873 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10874 .adc_nids = alc883_adc_nids_rev,
10875 .capsrc_nids = alc883_capsrc_nids_rev,
10876 .dig_out_nid = ALC883_DIGOUT_NID,
10877 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10878 .channel_mode = alc888_4ST_8ch_intel_modes,
10879 .num_mux_defs =
10880 ARRAY_SIZE(alc888_2_capture_sources),
10881 .input_mux = alc888_2_capture_sources,
Takashi Iwaid922b512011-04-28 12:18:53 +020010882 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010883 .setup = alc888_fujitsu_xa3530_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010884 .init_hook = alc_hp_automute,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010885 },
Kailang Yange2757d52008-08-26 13:17:46 +020010886 [ALC888_LENOVO_SKY] = {
10887 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10888 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10889 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10890 .dac_nids = alc883_dac_nids,
10891 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010892 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10893 .channel_mode = alc883_sixstack_modes,
10894 .need_dac_fix = 1,
10895 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010896 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010897 .setup = alc888_lenovo_sky_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010898 .init_hook = alc_hp_automute,
Kailang Yange2757d52008-08-26 13:17:46 +020010899 },
10900 [ALC888_ASUS_M90V] = {
10901 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10902 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10903 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10904 .dac_nids = alc883_dac_nids,
10905 .dig_out_nid = ALC883_DIGOUT_NID,
10906 .dig_in_nid = ALC883_DIGIN_NID,
10907 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10908 .channel_mode = alc883_3ST_6ch_modes,
10909 .need_dac_fix = 1,
10910 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010911 .unsol_event = alc_sku_unsol_event,
10912 .setup = alc883_mode2_setup,
10913 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010914 },
10915 [ALC888_ASUS_EEE1601] = {
10916 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010917 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010918 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10919 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10920 .dac_nids = alc883_dac_nids,
10921 .dig_out_nid = ALC883_DIGOUT_NID,
10922 .dig_in_nid = ALC883_DIGIN_NID,
10923 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10924 .channel_mode = alc883_3ST_2ch_modes,
10925 .need_dac_fix = 1,
10926 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010927 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010928 .init_hook = alc883_eee1601_inithook,
10929 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010930 [ALC1200_ASUS_P5Q] = {
10931 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10932 .init_verbs = { alc883_init_verbs },
10933 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10934 .dac_nids = alc883_dac_nids,
10935 .dig_out_nid = ALC1200_DIGOUT_NID,
10936 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010937 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010938 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10939 .channel_mode = alc883_sixstack_modes,
10940 .input_mux = &alc883_capture_source,
10941 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010942 [ALC889A_MB31] = {
10943 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10944 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10945 alc880_gpio1_init_verbs },
10946 .adc_nids = alc883_adc_nids,
10947 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010948 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010949 .dac_nids = alc883_dac_nids,
10950 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10951 .channel_mode = alc889A_mb31_6ch_modes,
10952 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10953 .input_mux = &alc889A_mb31_capture_source,
10954 .dig_out_nid = ALC883_DIGOUT_NID,
10955 .unsol_event = alc889A_mb31_unsol_event,
10956 .init_hook = alc889A_mb31_automute,
10957 },
Guido Günther3e1647c52009-06-05 00:47:26 +020010958 [ALC883_SONY_VAIO_TT] = {
10959 .mixers = { alc883_vaiott_mixer },
10960 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10961 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10962 .dac_nids = alc883_dac_nids,
10963 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10964 .channel_mode = alc883_3ST_2ch_modes,
10965 .input_mux = &alc883_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020010966 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010967 .setup = alc883_vaiott_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020010968 .init_hook = alc_hp_automute,
Guido Günther3e1647c52009-06-05 00:47:26 +020010969 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010970};
10971
10972
10973/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010974 * Pin config fixes
10975 */
10976enum {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010977 PINFIX_ABIT_AW9D_MAX,
David Henningsson32eea382011-03-04 13:37:50 +010010978 PINFIX_LENOVO_Y530,
Takashi Iwai954a29c2010-07-30 10:55:44 +020010979 PINFIX_PB_M5210,
David Henningssonc3d226a2010-10-14 15:42:08 +020010980 PINFIX_ACER_ASPIRE_7736,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010981};
10982
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010983static const struct alc_fixup alc882_fixups[] = {
10984 [PINFIX_ABIT_AW9D_MAX] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010985 .type = ALC_FIXUP_PINS,
10986 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020010987 { 0x15, 0x01080104 }, /* side */
10988 { 0x16, 0x01011012 }, /* rear */
10989 { 0x17, 0x01016011 }, /* clfe */
10990 { }
10991 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010992 },
David Henningsson32eea382011-03-04 13:37:50 +010010993 [PINFIX_LENOVO_Y530] = {
10994 .type = ALC_FIXUP_PINS,
10995 .v.pins = (const struct alc_pincfg[]) {
10996 { 0x15, 0x99130112 }, /* rear int speakers */
10997 { 0x16, 0x99130111 }, /* subwoofer */
10998 { }
10999 }
11000 },
Takashi Iwai954a29c2010-07-30 10:55:44 +020011001 [PINFIX_PB_M5210] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010011002 .type = ALC_FIXUP_VERBS,
11003 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020011004 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
11005 {}
11006 }
Takashi Iwai954a29c2010-07-30 10:55:44 +020011007 },
David Henningssonc3d226a2010-10-14 15:42:08 +020011008 [PINFIX_ACER_ASPIRE_7736] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010011009 .type = ALC_FIXUP_SKU,
11010 .v.sku = ALC_FIXUP_SKU_IGNORE,
David Henningssonc3d226a2010-10-14 15:42:08 +020011011 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020011012};
11013
Takashi Iwaia9111322011-05-02 11:30:18 +020011014static const struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai954a29c2010-07-30 10:55:44 +020011015 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
David Henningsson32eea382011-03-04 13:37:50 +010011016 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", PINFIX_LENOVO_Y530),
Takashi Iwai4953550a2009-06-30 15:28:30 +020011017 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
David Henningssonc3d226a2010-10-14 15:42:08 +020011018 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736),
Takashi Iwai4953550a2009-06-30 15:28:30 +020011019 {}
11020};
11021
11022/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011023 * BIOS auto configuration
11024 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020011025static int alc882_auto_create_input_ctls(struct hda_codec *codec,
11026 const struct auto_pin_cfg *cfg)
11027{
11028 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
11029}
11030
Takashi Iwai4953550a2009-06-30 15:28:30 +020011031static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011032 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020011033 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011034{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011035 int idx;
11036
Takashi Iwai489008c2010-04-07 09:06:00 +020011037 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011038 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011039
Takashi Iwai489008c2010-04-07 09:06:00 +020011040 if (dac == 0x25)
11041 idx = 4;
11042 else if (dac >= 0x02 && dac <= 0x05)
11043 idx = dac - 2;
11044 else
11045 return;
11046 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011047}
11048
Takashi Iwai4953550a2009-06-30 15:28:30 +020011049static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011050{
11051 struct alc_spec *spec = codec->spec;
11052 int i;
11053
11054 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011055 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011056 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011057 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020011058 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020011059 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011060 }
11061}
11062
Takashi Iwai4953550a2009-06-30 15:28:30 +020011063static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011064{
11065 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020011066 hda_nid_t pin, dac;
Takashi Iwai5855fb82010-09-16 18:24:02 +020011067 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011068
David Henningsson0a3fabe2011-03-04 16:54:52 +010011069 if (spec->autocfg.line_out_type != AUTO_PIN_HP_OUT) {
11070 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
11071 pin = spec->autocfg.hp_pins[i];
11072 if (!pin)
11073 break;
11074 dac = spec->multiout.hp_nid;
11075 if (!dac)
11076 dac = spec->multiout.dac_nids[0]; /* to front */
11077 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
11078 }
Takashi Iwai489008c2010-04-07 09:06:00 +020011079 }
David Henningsson0a3fabe2011-03-04 16:54:52 +010011080
11081 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT) {
11082 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
11083 pin = spec->autocfg.speaker_pins[i];
11084 if (!pin)
11085 break;
11086 dac = spec->multiout.extra_out_nid[0];
11087 if (!dac)
11088 dac = spec->multiout.dac_nids[0]; /* to front */
11089 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
11090 }
Takashi Iwai489008c2010-04-07 09:06:00 +020011091 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011092}
11093
Takashi Iwai4953550a2009-06-30 15:28:30 +020011094static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011095{
11096 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020011097 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011098 int i;
11099
Takashi Iwai66ceeb62010-08-30 13:05:52 +020011100 for (i = 0; i < cfg->num_inputs; i++) {
11101 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai30ea0982010-09-16 18:47:56 +020011102 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai4953550a2009-06-30 15:28:30 +020011103 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
11104 snd_hda_codec_write(codec, nid, 0,
11105 AC_VERB_SET_AMP_GAIN_MUTE,
11106 AMP_OUT_MUTE);
11107 }
11108}
11109
11110static void alc882_auto_init_input_src(struct hda_codec *codec)
11111{
11112 struct alc_spec *spec = codec->spec;
11113 int c;
11114
11115 for (c = 0; c < spec->num_adc_nids; c++) {
11116 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
11117 hda_nid_t nid = spec->capsrc_nids[c];
11118 unsigned int mux_idx;
11119 const struct hda_input_mux *imux;
11120 int conns, mute, idx, item;
11121
Takashi Iwai10696aa2011-04-07 12:46:45 +020011122 /* mute ADC */
11123 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
11124 AC_VERB_SET_AMP_GAIN_MUTE,
11125 AMP_IN_MUTE(0));
11126
Takashi Iwai4953550a2009-06-30 15:28:30 +020011127 conns = snd_hda_get_connections(codec, nid, conn_list,
11128 ARRAY_SIZE(conn_list));
11129 if (conns < 0)
11130 continue;
11131 mux_idx = c >= spec->num_mux_defs ? 0 : c;
11132 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010011133 if (!imux->num_items && mux_idx > 0)
11134 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020011135 for (idx = 0; idx < conns; idx++) {
11136 /* if the current connection is the selected one,
11137 * unmute it as default - otherwise mute it
11138 */
11139 mute = AMP_IN_MUTE(idx);
11140 for (item = 0; item < imux->num_items; item++) {
11141 if (imux->items[item].index == idx) {
11142 if (spec->cur_mux[c] == item)
11143 mute = AMP_IN_UNMUTE(idx);
11144 break;
11145 }
11146 }
11147 /* check if we have a selector or mixer
11148 * we could check for the widget type instead, but
11149 * just check for Amp-In presence (in case of mixer
11150 * without amp-in there is something wrong, this
11151 * function shouldn't be used or capsrc nid is wrong)
11152 */
11153 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011154 snd_hda_codec_write(codec, nid, 0,
11155 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020011156 mute);
11157 else if (mute != AMP_IN_MUTE(idx))
11158 snd_hda_codec_write(codec, nid, 0,
11159 AC_VERB_SET_CONNECT_SEL,
11160 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011161 }
11162 }
11163}
11164
Takashi Iwai4953550a2009-06-30 15:28:30 +020011165/* add mic boosts if needed */
11166static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011167{
11168 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020011169 struct auto_pin_cfg *cfg = &spec->autocfg;
David Henningsson5322bf22011-01-05 11:03:56 +010011170 int i, err;
Takashi Iwai53e8c322010-12-17 15:23:41 +010011171 int type_idx = 0;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011172 hda_nid_t nid;
David Henningsson5322bf22011-01-05 11:03:56 +010011173 const char *prev_label = NULL;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011174
Takashi Iwai66ceeb62010-08-30 13:05:52 +020011175 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +020011176 if (cfg->inputs[i].type > AUTO_PIN_MIC)
Takashi Iwai66ceeb62010-08-30 13:05:52 +020011177 break;
11178 nid = cfg->inputs[i].pin;
11179 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
David Henningsson5322bf22011-01-05 11:03:56 +010011180 const char *label;
11181 char boost_label[32];
11182
11183 label = hda_get_autocfg_input_label(codec, cfg, i);
11184 if (prev_label && !strcmp(label, prev_label))
Takashi Iwai53e8c322010-12-17 15:23:41 +010011185 type_idx++;
11186 else
11187 type_idx = 0;
David Henningsson5322bf22011-01-05 11:03:56 +010011188 prev_label = label;
11189
11190 snprintf(boost_label, sizeof(boost_label),
11191 "%s Boost Volume", label);
11192 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11193 boost_label, type_idx,
Takashi Iwai4953550a2009-06-30 15:28:30 +020011194 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020011195 if (err < 0)
11196 return err;
11197 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011198 }
11199 return 0;
11200}
11201
11202/* almost identical with ALC880 parser... */
11203static int alc882_parse_auto_config(struct hda_codec *codec)
11204{
11205 struct alc_spec *spec = codec->spec;
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020011206 static const hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai757899a2010-07-30 10:48:14 +020011207 int err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011208
Takashi Iwai05f5f472009-08-25 13:10:18 +020011209 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11210 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011211 if (err < 0)
11212 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011213 if (!spec->autocfg.line_outs)
11214 return 0; /* can't find valid BIOS pin config */
11215
11216 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
11217 if (err < 0)
11218 return err;
Takashi Iwaice764ab2011-04-27 16:35:23 +020011219 err = alc_auto_add_multi_channel_mode(codec);
11220 if (err < 0)
11221 return err;
Takashi Iwai569ed342011-01-19 10:14:46 +010011222 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
Takashi Iwai05f5f472009-08-25 13:10:18 +020011223 if (err < 0)
11224 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020011225 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
11226 "Headphone");
11227 if (err < 0)
11228 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011229 err = alc880_auto_create_extra_out(spec,
11230 spec->autocfg.speaker_pins[0],
11231 "Speaker");
11232 if (err < 0)
11233 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011234 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
11235 if (err < 0)
11236 return err;
11237
11238 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11239
Takashi Iwai757899a2010-07-30 10:48:14 +020011240 alc_auto_parse_digital(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020011241
11242 if (spec->kctls.list)
11243 add_mixer(spec, spec->kctls.list);
11244
11245 add_verb(spec, alc883_auto_init_verbs);
11246 /* if ADC 0x07 is available, initialize it, too */
11247 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
11248 add_verb(spec, alc882_adc1_init_verbs);
11249
11250 spec->num_mux_defs = 1;
11251 spec->input_mux = &spec->private_imux[0];
11252
Kailang Yang6227cdc2010-02-25 08:36:52 +010011253 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020011254
11255 err = alc_auto_add_mic_boost(codec);
11256 if (err < 0)
11257 return err;
11258
Takashi Iwai776e1842007-08-29 15:07:11 +020011259 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011260}
11261
11262/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020011263static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011264{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011265 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011266 alc882_auto_init_multi_out(codec);
11267 alc882_auto_init_hp_out(codec);
11268 alc882_auto_init_analog_input(codec);
11269 alc882_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020011270 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011271 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011272 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011273}
11274
Takashi Iwai4953550a2009-06-30 15:28:30 +020011275static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011276{
11277 struct alc_spec *spec;
11278 int err, board_config;
11279
11280 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11281 if (spec == NULL)
11282 return -ENOMEM;
11283
11284 codec->spec = spec;
11285
Takashi Iwai4953550a2009-06-30 15:28:30 +020011286 switch (codec->vendor_id) {
11287 case 0x10ec0882:
11288 case 0x10ec0885:
11289 break;
11290 default:
11291 /* ALC883 and variants */
11292 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11293 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011294 }
11295
Takashi Iwai4953550a2009-06-30 15:28:30 +020011296 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
11297 alc882_models,
11298 alc882_cfg_tbl);
11299
11300 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
11301 board_config = snd_hda_check_board_codec_sid_config(codec,
11302 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
11303
11304 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020011305 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020011306 codec->chip_name);
11307 board_config = ALC882_AUTO;
11308 }
11309
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010011310 if (board_config == ALC882_AUTO) {
11311 alc_pick_fixup(codec, NULL, alc882_fixup_tbl, alc882_fixups);
11312 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
11313 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011314
David Henningsson90622912010-10-14 14:50:18 +020011315 alc_auto_parse_customize_define(codec);
11316
Takashi Iwai4953550a2009-06-30 15:28:30 +020011317 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011318 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020011319 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011320 if (err < 0) {
11321 alc_free(codec);
11322 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011323 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011324 printk(KERN_INFO
11325 "hda_codec: Cannot set up configuration "
11326 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020011327 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011328 }
11329 }
11330
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011331 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020011332 err = snd_hda_attach_beep_device(codec, 0x1);
11333 if (err < 0) {
11334 alc_free(codec);
11335 return err;
11336 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011337 }
11338
Takashi Iwai4953550a2009-06-30 15:28:30 +020011339 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011340 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011341
Takashi Iwai4953550a2009-06-30 15:28:30 +020011342 spec->stream_analog_playback = &alc882_pcm_analog_playback;
11343 spec->stream_analog_capture = &alc882_pcm_analog_capture;
11344 /* FIXME: setup DAC5 */
11345 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
11346 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
11347
11348 spec->stream_digital_playback = &alc882_pcm_digital_playback;
11349 spec->stream_digital_capture = &alc882_pcm_digital_capture;
11350
Takashi Iwai4953550a2009-06-30 15:28:30 +020011351 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011352 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011353 spec->num_adc_nids = 0;
11354 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011355 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011356 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011357 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020011358 hda_nid_t nid = alc882_adc_nids[i];
11359 unsigned int wcap = get_wcaps(codec, nid);
11360 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011361 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020011362 if (wcap != AC_WID_AUD_IN)
11363 continue;
11364 spec->private_adc_nids[spec->num_adc_nids] = nid;
11365 err = snd_hda_get_connections(codec, nid, &cap, 1);
11366 if (err < 0)
11367 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011368 err = snd_hda_get_connections(codec, cap, items,
11369 ARRAY_SIZE(items));
11370 if (err < 0)
11371 continue;
11372 for (j = 0; j < imux->num_items; j++)
11373 if (imux->items[j].index >= err)
11374 break;
11375 if (j < imux->num_items)
11376 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011377 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
11378 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011379 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011380 spec->adc_nids = spec->private_adc_nids;
11381 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020011382 }
11383
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011384 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010011385
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011386 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010011387 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011388
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010011389 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020011390
Takashi Iwai2134ea42008-01-10 16:53:55 +010011391 spec->vmaster_nid = 0x0c;
11392
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011393 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011394 if (board_config == ALC882_AUTO)
11395 spec->init_hook = alc882_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020011396
11397 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020011398#ifdef CONFIG_SND_HDA_POWER_SAVE
11399 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020011400 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011401#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011402
11403 return 0;
11404}
11405
Takashi Iwai4953550a2009-06-30 15:28:30 +020011406
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011407/*
Kailang Yangdf694da2005-12-05 19:42:22 +010011408 * ALC262 support
11409 */
11410
11411#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
11412#define ALC262_DIGIN_NID ALC880_DIGIN_NID
11413
11414#define alc262_dac_nids alc260_dac_nids
11415#define alc262_adc_nids alc882_adc_nids
11416#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010011417#define alc262_capsrc_nids alc882_capsrc_nids
11418#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010011419
11420#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010011421#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010011422
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020011423static const hda_nid_t alc262_dmic_adc_nids[1] = {
Kailang Yang4e555fe2008-08-26 13:05:55 +020011424 /* ADC0 */
11425 0x09
11426};
11427
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020011428static const hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
Kailang Yang4e555fe2008-08-26 13:05:55 +020011429
Takashi Iwaia9111322011-05-02 11:30:18 +020011430static const struct snd_kcontrol_new alc262_base_mixer[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010011431 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11432 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11433 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11434 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11435 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11436 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11437 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11438 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011439 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011440 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11441 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011442 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011443 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
11444 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11445 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
11446 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011447 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010011448};
11449
Takashi Iwaice875f02008-01-28 18:17:43 +010011450/* update HP, line and mono-out pins according to the master switch */
Takashi Iwaie9427962011-04-28 15:46:07 +020011451#define alc262_hp_master_update alc260_hp_master_update
Takashi Iwaice875f02008-01-28 18:17:43 +010011452
Takashi Iwaie9427962011-04-28 15:46:07 +020011453static void alc262_hp_bpc_setup(struct hda_codec *codec)
Takashi Iwaice875f02008-01-28 18:17:43 +010011454{
11455 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011456
Takashi Iwaie9427962011-04-28 15:46:07 +020011457 spec->autocfg.hp_pins[0] = 0x1b;
11458 spec->autocfg.speaker_pins[0] = 0x16;
11459 spec->automute = 1;
11460 spec->automute_mode = ALC_AUTOMUTE_PIN;
Takashi Iwaice875f02008-01-28 18:17:43 +010011461}
11462
Takashi Iwaie9427962011-04-28 15:46:07 +020011463static void alc262_hp_wildwest_setup(struct hda_codec *codec)
Takashi Iwaice875f02008-01-28 18:17:43 +010011464{
11465 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011466
Takashi Iwaie9427962011-04-28 15:46:07 +020011467 spec->autocfg.hp_pins[0] = 0x15;
11468 spec->autocfg.speaker_pins[0] = 0x16;
11469 spec->automute = 1;
11470 spec->automute_mode = ALC_AUTOMUTE_PIN;
Takashi Iwaice875f02008-01-28 18:17:43 +010011471}
11472
Takashi Iwaib72519b2009-05-08 14:31:55 +020011473#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaie9427962011-04-28 15:46:07 +020011474#define alc262_hp_master_sw_put alc260_hp_master_sw_put
Takashi Iwaice875f02008-01-28 18:17:43 +010011475
Takashi Iwaib72519b2009-05-08 14:31:55 +020011476#define ALC262_HP_MASTER_SWITCH \
11477 { \
11478 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11479 .name = "Master Playback Switch", \
11480 .info = snd_ctl_boolean_mono_info, \
11481 .get = alc262_hp_master_sw_get, \
11482 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011483 }, \
11484 { \
11485 .iface = NID_MAPPING, \
11486 .name = "Master Playback Switch", \
11487 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020011488 }
11489
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011490
Takashi Iwaia9111322011-05-02 11:30:18 +020011491static const struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011492 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011493 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11494 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11495 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011496 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11497 HDA_OUTPUT),
11498 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11499 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011500 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11501 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011502 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011503 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11504 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011505 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011506 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11507 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11508 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11509 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011510 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
11511 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
11512 { } /* end */
11513};
11514
Takashi Iwaia9111322011-05-02 11:30:18 +020011515static const struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011516 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010011517 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11518 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11519 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11520 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011521 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11522 HDA_OUTPUT),
11523 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11524 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011525 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
11526 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011527 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011528 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11529 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11530 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11531 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011532 { } /* end */
11533};
11534
Takashi Iwaia9111322011-05-02 11:30:18 +020011535static const struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
Kailang Yangcd7509a2007-01-26 18:33:17 +010011536 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11537 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011538 HDA_CODEC_VOLUME("Rear Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011539 { } /* end */
11540};
11541
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011542/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011543static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011544{
11545 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011546
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011547 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010011548 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +020011549 spec->automute = 1;
11550 spec->automute_mode = ALC_AUTOMUTE_PIN;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011551}
11552
Takashi Iwaia9111322011-05-02 11:30:18 +020011553static const struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010011554 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11555 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011556 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11557 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11558 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11559 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011560 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011561 { } /* end */
11562};
11563
Takashi Iwaia9111322011-05-02 11:30:18 +020011564static const struct hda_verb alc262_hp_t5735_verbs[] = {
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011565 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11566 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11567
11568 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11569 { }
11570};
11571
Takashi Iwaia9111322011-05-02 11:30:18 +020011572static const struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010011573 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11574 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010011575 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11576 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010011577 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11578 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11579 { } /* end */
11580};
11581
Takashi Iwaia9111322011-05-02 11:30:18 +020011582static const struct hda_verb alc262_hp_rp5700_verbs[] = {
Kailang Yang8c427222008-01-10 13:03:59 +010011583 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11584 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11585 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11586 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11587 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11588 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11589 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11590 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11591 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11592 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11593 {}
11594};
11595
Takashi Iwaia9111322011-05-02 11:30:18 +020011596static const struct hda_input_mux alc262_hp_rp5700_capture_source = {
Kailang Yang8c427222008-01-10 13:03:59 +010011597 .num_items = 1,
11598 .items = {
11599 { "Line", 0x1 },
11600 },
11601};
11602
Takashi Iwai42171c12009-05-08 14:11:43 +020011603/* bind hp and internal speaker mute (with plug check) as master switch */
Takashi Iwaie9427962011-04-28 15:46:07 +020011604#define alc262_hippo_master_update alc262_hp_master_update
Takashi Iwai42171c12009-05-08 14:11:43 +020011605#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
Takashi Iwaie9427962011-04-28 15:46:07 +020011606#define alc262_hippo_master_sw_put alc262_hp_master_sw_put
Takashi Iwai5b319542007-07-26 11:49:22 +020011607
Takashi Iwai42171c12009-05-08 14:11:43 +020011608#define ALC262_HIPPO_MASTER_SWITCH \
11609 { \
11610 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11611 .name = "Master Playback Switch", \
11612 .info = snd_ctl_boolean_mono_info, \
11613 .get = alc262_hippo_master_sw_get, \
11614 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011615 }, \
11616 { \
11617 .iface = NID_MAPPING, \
11618 .name = "Master Playback Switch", \
11619 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
11620 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020011621 }
11622
Takashi Iwaia9111322011-05-02 11:30:18 +020011623static const struct snd_kcontrol_new alc262_hippo_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011624 ALC262_HIPPO_MASTER_SWITCH,
11625 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11626 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11627 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11628 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11629 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11630 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11631 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011632 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011633 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11634 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011635 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011636 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11637 { } /* end */
11638};
11639
Takashi Iwaia9111322011-05-02 11:30:18 +020011640static const struct snd_kcontrol_new alc262_hippo1_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011641 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11642 ALC262_HIPPO_MASTER_SWITCH,
11643 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11644 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11645 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11646 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11647 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11648 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011649 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011650 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11651 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011652 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011653 { } /* end */
11654};
11655
11656/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011657static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011658{
11659 struct alc_spec *spec = codec->spec;
11660
11661 spec->autocfg.hp_pins[0] = 0x15;
11662 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaie9427962011-04-28 15:46:07 +020011663 spec->automute = 1;
11664 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai42171c12009-05-08 14:11:43 +020011665}
11666
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011667static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011668{
11669 struct alc_spec *spec = codec->spec;
11670
11671 spec->autocfg.hp_pins[0] = 0x1b;
11672 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaie9427962011-04-28 15:46:07 +020011673 spec->automute = 1;
11674 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai42171c12009-05-08 14:11:43 +020011675}
11676
11677
Takashi Iwaia9111322011-05-02 11:30:18 +020011678static const struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011679 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011680 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011681 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11682 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11683 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11684 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11685 { } /* end */
11686};
11687
Takashi Iwaia9111322011-05-02 11:30:18 +020011688static const struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011689 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11690 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011691 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11692 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11693 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11694 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11695 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11696 { } /* end */
11697};
Kailang Yang272a5272007-05-14 11:00:38 +020011698
Takashi Iwaia9111322011-05-02 11:30:18 +020011699static const struct snd_kcontrol_new alc262_tyan_mixer[] = {
Tony Vroonba340e82009-02-02 19:01:30 +000011700 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11701 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11702 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11703 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11704 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11705 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11706 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11707 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011708 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroonba340e82009-02-02 19:01:30 +000011709 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11710 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011711 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tony Vroonba340e82009-02-02 19:01:30 +000011712 { } /* end */
11713};
11714
Takashi Iwaia9111322011-05-02 11:30:18 +020011715static const struct hda_verb alc262_tyan_verbs[] = {
Tony Vroonba340e82009-02-02 19:01:30 +000011716 /* Headphone automute */
11717 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11718 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11719 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11720
11721 /* P11 AUX_IN, white 4-pin connector */
11722 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11723 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11724 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11725 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11726
11727 {}
11728};
11729
11730/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011731static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011732{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011733 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011734
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011735 spec->autocfg.hp_pins[0] = 0x1b;
11736 spec->autocfg.speaker_pins[0] = 0x15;
Takashi Iwaid922b512011-04-28 12:18:53 +020011737 spec->automute = 1;
11738 spec->automute_mode = ALC_AUTOMUTE_AMP;
Tony Vroonba340e82009-02-02 19:01:30 +000011739}
11740
Tony Vroonba340e82009-02-02 19:01:30 +000011741
Kailang Yangdf694da2005-12-05 19:42:22 +010011742#define alc262_capture_mixer alc882_capture_mixer
11743#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11744
11745/*
11746 * generic initialization of ADC, input mixers and output mixers
11747 */
Takashi Iwaia9111322011-05-02 11:30:18 +020011748static const struct hda_verb alc262_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010011749 /*
11750 * Unmute ADC0-2 and set the default input to mic-in
11751 */
11752 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11753 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11754 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11755 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11756 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11757 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11758
Takashi Iwaicb53c622007-08-10 17:21:45 +020011759 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011760 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011761 * Note: PASD motherboards uses the Line In 2 as the input for
11762 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011763 */
11764 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011765 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11766 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11767 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11768 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11769 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011770
11771 /*
11772 * Set up output mixers (0x0c - 0x0e)
11773 */
11774 /* set vol=0 to output mixers */
11775 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11776 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11777 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11778 /* set up input amps for analog loopback */
11779 /* Amp Indices: DAC = 0, mixer = 1 */
11780 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11781 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11782 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11783 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11784 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11785 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11786
11787 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11788 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11789 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11790 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11791 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11792 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11793
11794 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11795 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11796 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11797 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11798 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011799
Kailang Yangdf694da2005-12-05 19:42:22 +010011800 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11801 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011802
Kailang Yangdf694da2005-12-05 19:42:22 +010011803 /* FIXME: use matrix-type input source selection */
11804 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11805 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11806 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11807 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11808 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11809 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11810 /* Input mixer2 */
11811 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11812 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11813 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11814 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11815 /* Input mixer3 */
11816 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11817 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11818 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011819 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011820
11821 { }
11822};
11823
Takashi Iwaia9111322011-05-02 11:30:18 +020011824static const struct hda_verb alc262_eapd_verbs[] = {
Kailang Yang4e555fe2008-08-26 13:05:55 +020011825 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11826 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11827 { }
11828};
11829
Takashi Iwaia9111322011-05-02 11:30:18 +020011830static const struct hda_verb alc262_hippo1_unsol_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +020011831 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11832 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11833 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11834
11835 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11836 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11837 {}
11838};
11839
Takashi Iwaia9111322011-05-02 11:30:18 +020011840static const struct hda_verb alc262_sony_unsol_verbs[] = {
Kailang Yang272a5272007-05-14 11:00:38 +020011841 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11842 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11843 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11844
11845 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11846 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011847 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011848};
11849
Takashi Iwaia9111322011-05-02 11:30:18 +020011850static const struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
Kailang Yang4e555fe2008-08-26 13:05:55 +020011851 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11852 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11853 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11854 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11855 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011856 { } /* end */
11857};
11858
Takashi Iwaia9111322011-05-02 11:30:18 +020011859static const struct hda_verb alc262_toshiba_s06_verbs[] = {
Kailang Yang4e555fe2008-08-26 13:05:55 +020011860 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11861 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11862 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11863 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11864 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11865 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11866 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11867 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11868 {}
11869};
11870
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011871static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011872{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011873 struct alc_spec *spec = codec->spec;
11874
11875 spec->autocfg.hp_pins[0] = 0x15;
11876 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011877 spec->ext_mic.pin = 0x18;
11878 spec->ext_mic.mux_idx = 0;
11879 spec->int_mic.pin = 0x12;
11880 spec->int_mic.mux_idx = 9;
11881 spec->auto_mic = 1;
Takashi Iwaid922b512011-04-28 12:18:53 +020011882 spec->automute = 1;
11883 spec->automute_mode = ALC_AUTOMUTE_PIN;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011884}
11885
Takashi Iwai834be882006-03-01 14:16:17 +010011886/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011887 * nec model
11888 * 0x15 = headphone
11889 * 0x16 = internal speaker
11890 * 0x18 = external mic
11891 */
11892
Takashi Iwaia9111322011-05-02 11:30:18 +020011893static const struct snd_kcontrol_new alc262_nec_mixer[] = {
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011894 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11895 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11896
11897 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11898 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011899 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011900
11901 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11902 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11903 { } /* end */
11904};
11905
Takashi Iwaia9111322011-05-02 11:30:18 +020011906static const struct hda_verb alc262_nec_verbs[] = {
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011907 /* Unmute Speaker */
11908 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11909
11910 /* Headphone */
11911 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11912 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11913
11914 /* External mic to headphone */
11915 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11916 /* External mic to speaker */
11917 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11918 {}
11919};
11920
11921/*
Takashi Iwai834be882006-03-01 14:16:17 +010011922 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011923 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11924 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011925 */
11926
Takashi Iwai20f5e0b2011-06-10 09:31:54 +020011927#define ALC_HP_EVENT ALC880_HP_EVENT
Takashi Iwai834be882006-03-01 14:16:17 +010011928
Takashi Iwaia9111322011-05-02 11:30:18 +020011929static const struct hda_verb alc262_fujitsu_unsol_verbs[] = {
Takashi Iwai834be882006-03-01 14:16:17 +010011930 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11931 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011932 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11933 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011934 {}
11935};
11936
Takashi Iwaia9111322011-05-02 11:30:18 +020011937static const struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
Jiang zhe0e31daf2008-03-20 12:12:39 +010011938 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11939 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11940 {}
11941};
11942
Takashi Iwaia9111322011-05-02 11:30:18 +020011943static const struct hda_verb alc262_lenovo_3000_init_verbs[] = {
Daniel T Chene2595322009-12-19 18:19:02 -050011944 /* Front Mic pin: input vref at 50% */
11945 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11946 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11947 {}
11948};
11949
Takashi Iwaia9111322011-05-02 11:30:18 +020011950static const struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011951 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011952 .items = {
11953 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +010011954 { "Internal Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011955 { "CD", 0x4 },
11956 },
11957};
11958
Takashi Iwaia9111322011-05-02 11:30:18 +020011959static const struct hda_input_mux alc262_HP_capture_source = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011960 .num_items = 5,
11961 .items = {
11962 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011963 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011964 { "Line", 0x2 },
11965 { "CD", 0x4 },
11966 { "AUX IN", 0x6 },
11967 },
11968};
11969
Takashi Iwaia9111322011-05-02 11:30:18 +020011970static const struct hda_input_mux alc262_HP_D7000_capture_source = {
zhejiangaccbe492007-08-31 12:36:05 +020011971 .num_items = 4,
11972 .items = {
11973 { "Mic", 0x0 },
11974 { "Front Mic", 0x2 },
11975 { "Line", 0x1 },
11976 { "CD", 0x4 },
11977 },
11978};
11979
Takashi Iwai0f0f3912011-04-28 16:26:24 +020011980static void alc262_fujitsu_setup(struct hda_codec *codec)
Takashi Iwai834be882006-03-01 14:16:17 +010011981{
11982 struct alc_spec *spec = codec->spec;
Takashi Iwai834be882006-03-01 14:16:17 +010011983
Takashi Iwai0f0f3912011-04-28 16:26:24 +020011984 spec->autocfg.hp_pins[0] = 0x14;
11985 spec->autocfg.hp_pins[1] = 0x1b;
11986 spec->autocfg.speaker_pins[0] = 0x15;
11987 spec->automute = 1;
11988 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011989}
11990
Takashi Iwai834be882006-03-01 14:16:17 +010011991/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaia9111322011-05-02 11:30:18 +020011992static const struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011993 .ops = &snd_hda_bind_vol,
11994 .values = {
11995 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11996 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11997 0
11998 },
11999};
Takashi Iwai834be882006-03-01 14:16:17 +010012000
Takashi Iwaia9111322011-05-02 11:30:18 +020012001static const struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020012002 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010012003 {
12004 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12005 .name = "Master Playback Switch",
Takashi Iwai0f0f3912011-04-28 16:26:24 +020012006 .subdevice = HDA_SUBDEV_NID_FLAG | 0x14,
12007 .info = snd_ctl_boolean_mono_info,
12008 .get = alc262_hp_master_sw_get,
12009 .put = alc262_hp_master_sw_put,
Takashi Iwai834be882006-03-01 14:16:17 +010012010 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010012011 {
12012 .iface = NID_MAPPING,
12013 .name = "Master Playback Switch",
12014 .private_value = 0x1b,
12015 },
Takashi Iwai834be882006-03-01 14:16:17 +010012016 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12017 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010012018 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010012019 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12020 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010012021 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010012022 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12023 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010012024 { } /* end */
12025};
12026
Takashi Iwai0f0f3912011-04-28 16:26:24 +020012027static void alc262_lenovo_3000_setup(struct hda_codec *codec)
Jiang zhe0e31daf2008-03-20 12:12:39 +010012028{
Takashi Iwai0f0f3912011-04-28 16:26:24 +020012029 struct alc_spec *spec = codec->spec;
Jiang zhe0e31daf2008-03-20 12:12:39 +010012030
Takashi Iwai0f0f3912011-04-28 16:26:24 +020012031 spec->autocfg.hp_pins[0] = 0x1b;
12032 spec->autocfg.speaker_pins[0] = 0x14;
12033 spec->autocfg.speaker_pins[1] = 0x16;
12034 spec->automute = 1;
12035 spec->automute_mode = ALC_AUTOMUTE_AMP;
Jiang zhe0e31daf2008-03-20 12:12:39 +010012036}
12037
Takashi Iwaia9111322011-05-02 11:30:18 +020012038static const struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
Jiang zhe0e31daf2008-03-20 12:12:39 +010012039 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
12040 {
12041 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12042 .name = "Master Playback Switch",
Takashi Iwai0f0f3912011-04-28 16:26:24 +020012043 .subdevice = HDA_SUBDEV_NID_FLAG | 0x1b,
12044 .info = snd_ctl_boolean_mono_info,
12045 .get = alc262_hp_master_sw_get,
12046 .put = alc262_hp_master_sw_put,
Jiang zhe0e31daf2008-03-20 12:12:39 +010012047 },
12048 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12049 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010012050 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012051 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12052 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010012053 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010012054 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12055 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012056 { } /* end */
12057};
12058
Takashi Iwaia9111322011-05-02 11:30:18 +020012059static const struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012060 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020012061 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012062 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12063 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010012064 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012065 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12066 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010012067 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012068 { } /* end */
12069};
12070
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012071/* additional init verbs for Benq laptops */
Takashi Iwaia9111322011-05-02 11:30:18 +020012072static const struct hda_verb alc262_EAPD_verbs[] = {
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012073 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
12074 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
12075 {}
12076};
12077
Takashi Iwaia9111322011-05-02 11:30:18 +020012078static const struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
Kailang Yang83c34212007-07-05 11:43:05 +020012079 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12080 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12081
12082 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
12083 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
12084 {}
12085};
12086
Tobin Davisf651b502007-10-26 12:40:47 +020012087/* Samsung Q1 Ultra Vista model setup */
Takashi Iwaia9111322011-05-02 11:30:18 +020012088static const struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012089 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
12090 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020012091 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12092 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010012093 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
12094 HDA_CODEC_VOLUME("Headphone Mic Boost Volume", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020012095 { } /* end */
12096};
12097
Takashi Iwaia9111322011-05-02 11:30:18 +020012098static const struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012099 /* output mixer */
12100 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12101 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12102 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12103 /* speaker */
12104 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12105 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12106 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12107 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12108 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020012109 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012110 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12111 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12112 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12113 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12114 /* internal mic */
12115 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12116 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12117 /* ADC, choose mic */
12118 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12119 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12120 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12121 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12122 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12123 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12124 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12125 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12126 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
12127 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020012128 {}
12129};
12130
Tobin Davisf651b502007-10-26 12:40:47 +020012131/* mute/unmute internal speaker according to the hp jack and mute state */
12132static void alc262_ultra_automute(struct hda_codec *codec)
12133{
12134 struct alc_spec *spec = codec->spec;
12135 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020012136
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012137 mute = 0;
12138 /* auto-mute only when HP is used as HP */
12139 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012140 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012141 if (spec->jack_present)
12142 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020012143 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012144 /* mute/unmute internal speaker */
12145 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12146 HDA_AMP_MUTE, mute);
12147 /* mute/unmute HP */
12148 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12149 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020012150}
12151
12152/* unsolicited event for HP jack sensing */
12153static void alc262_ultra_unsol_event(struct hda_codec *codec,
12154 unsigned int res)
12155{
12156 if ((res >> 26) != ALC880_HP_EVENT)
12157 return;
12158 alc262_ultra_automute(codec);
12159}
12160
Takashi Iwaia9111322011-05-02 11:30:18 +020012161static const struct hda_input_mux alc262_ultra_capture_source = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012162 .num_items = 2,
12163 .items = {
12164 { "Mic", 0x1 },
12165 { "Headphone", 0x7 },
12166 },
12167};
12168
12169static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
12170 struct snd_ctl_elem_value *ucontrol)
12171{
12172 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12173 struct alc_spec *spec = codec->spec;
12174 int ret;
12175
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012176 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012177 if (!ret)
12178 return 0;
12179 /* reprogram the HP pin as mic or HP according to the input source */
12180 snd_hda_codec_write_cache(codec, 0x15, 0,
12181 AC_VERB_SET_PIN_WIDGET_CONTROL,
12182 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
12183 alc262_ultra_automute(codec); /* mute/unmute HP */
12184 return ret;
12185}
12186
Takashi Iwaia9111322011-05-02 11:30:18 +020012187static const struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012188 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
12189 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
12190 {
12191 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12192 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012193 .info = alc_mux_enum_info,
12194 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012195 .put = alc262_ultra_mux_enum_put,
12196 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010012197 {
12198 .iface = NID_MAPPING,
12199 .name = "Capture Source",
12200 .private_value = 0x15,
12201 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012202 { } /* end */
12203};
12204
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012205/* We use two mixers depending on the output pin; 0x16 is a mono output
12206 * and thus it's bound with a different mixer.
12207 * This function returns which mixer amp should be used.
12208 */
12209static int alc262_check_volbit(hda_nid_t nid)
12210{
12211 if (!nid)
12212 return 0;
12213 else if (nid == 0x16)
12214 return 2;
12215 else
12216 return 1;
12217}
12218
12219static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012220 const char *pfx, int *vbits, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012221{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012222 unsigned long val;
12223 int vbit;
12224
12225 vbit = alc262_check_volbit(nid);
12226 if (!vbit)
12227 return 0;
12228 if (*vbits & vbit) /* a volume control for this mixer already there */
12229 return 0;
12230 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012231 if (vbit == 2)
12232 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
12233 else
12234 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012235 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012236}
12237
12238static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012239 const char *pfx, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012240{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012241 unsigned long val;
12242
12243 if (!nid)
12244 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012245 if (nid == 0x16)
12246 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
12247 else
12248 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012249 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012250}
12251
Kailang Yangdf694da2005-12-05 19:42:22 +010012252/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012253static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
12254 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012255{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012256 const char *pfx;
12257 int vbits;
Takashi Iwai033688a2010-09-08 15:47:09 +020012258 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +010012259
12260 spec->multiout.num_dacs = 1; /* only use one dac */
12261 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaidda14412011-05-02 11:29:30 +020012262 spec->private_dac_nids[0] = 2;
Kailang Yangdf694da2005-12-05 19:42:22 +010012263
Takashi Iwaice764ab2011-04-27 16:35:23 +020012264 pfx = alc_get_line_out_pfx(spec, true);
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010012265 if (!pfx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012266 pfx = "Front";
Takashi Iwai033688a2010-09-08 15:47:09 +020012267 for (i = 0; i < 2; i++) {
12268 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, i);
12269 if (err < 0)
12270 return err;
12271 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12272 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i],
12273 "Speaker", i);
12274 if (err < 0)
12275 return err;
12276 }
12277 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12278 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i],
12279 "Headphone", i);
12280 if (err < 0)
12281 return err;
12282 }
12283 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012284
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012285 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
12286 alc262_check_volbit(cfg->speaker_pins[0]) |
12287 alc262_check_volbit(cfg->hp_pins[0]);
12288 if (vbits == 1 || vbits == 2)
12289 pfx = "Master"; /* only one mixer is used */
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012290 vbits = 0;
Takashi Iwai033688a2010-09-08 15:47:09 +020012291 for (i = 0; i < 2; i++) {
12292 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx,
12293 &vbits, i);
12294 if (err < 0)
12295 return err;
12296 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12297 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i],
12298 "Speaker", &vbits, i);
12299 if (err < 0)
12300 return err;
12301 }
12302 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12303 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i],
12304 "Headphone", &vbits, i);
12305 if (err < 0)
12306 return err;
12307 }
12308 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012309 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010012310}
12311
Takashi Iwai05f5f472009-08-25 13:10:18 +020012312#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010012313 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010012314
12315/*
12316 * generic initialization of ADC, input mixers and output mixers
12317 */
Takashi Iwaia9111322011-05-02 11:30:18 +020012318static const struct hda_verb alc262_volume_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010012319 /*
12320 * Unmute ADC0-2 and set the default input to mic-in
12321 */
12322 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12323 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12324 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12325 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12326 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12327 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12328
Takashi Iwaicb53c622007-08-10 17:21:45 +020012329 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010012330 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012331 * Note: PASD motherboards uses the Line In 2 as the input for
12332 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010012333 */
12334 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012335 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12336 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12337 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12338 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12339 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012340
12341 /*
12342 * Set up output mixers (0x0c - 0x0f)
12343 */
12344 /* set vol=0 to output mixers */
12345 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12346 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12347 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020012348
Kailang Yangdf694da2005-12-05 19:42:22 +010012349 /* set up input amps for analog loopback */
12350 /* Amp Indices: DAC = 0, mixer = 1 */
12351 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12352 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12353 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12354 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12355 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12356 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12357
12358 /* FIXME: use matrix-type input source selection */
12359 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12360 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12361 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12362 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12363 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12364 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12365 /* Input mixer2 */
12366 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12367 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12368 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12369 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12370 /* Input mixer3 */
12371 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12372 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12373 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12374 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12375
12376 { }
12377};
12378
Takashi Iwaia9111322011-05-02 11:30:18 +020012379static const struct hda_verb alc262_HP_BPC_init_verbs[] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012380 /*
12381 * Unmute ADC0-2 and set the default input to mic-in
12382 */
12383 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12384 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12385 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12386 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12387 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12388 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12389
Takashi Iwaicb53c622007-08-10 17:21:45 +020012390 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012391 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012392 * Note: PASD motherboards uses the Line In 2 as the input for
12393 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012394 */
12395 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012396 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12397 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12398 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12399 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12400 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12401 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12402 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012403
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012404 /*
12405 * Set up output mixers (0x0c - 0x0e)
12406 */
12407 /* set vol=0 to output mixers */
12408 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12409 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12410 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12411
12412 /* set up input amps for analog loopback */
12413 /* Amp Indices: DAC = 0, mixer = 1 */
12414 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12415 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12416 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12417 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12418 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12419 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12420
Takashi Iwaice875f02008-01-28 18:17:43 +010012421 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012422 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12423 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12424
12425 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12426 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12427
12428 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12429 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12430
12431 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12432 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12433 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12434 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12435 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12436
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012437 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012438 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12439 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012440 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012441 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12442 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12443
12444
12445 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012446 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
12447 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012448 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012449 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12450 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12451 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12452 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12453 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12454 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12455 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12456 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012457 /* Input mixer2 */
12458 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012459 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12460 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12461 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12462 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12463 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12464 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12465 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12466 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012467 /* Input mixer3 */
12468 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012469 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12470 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12471 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12472 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12473 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12474 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12475 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12476 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012477
Takashi Iwaice875f02008-01-28 18:17:43 +010012478 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12479
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012480 { }
12481};
12482
Takashi Iwaia9111322011-05-02 11:30:18 +020012483static const struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
Kailang Yangcd7509a2007-01-26 18:33:17 +010012484 /*
12485 * Unmute ADC0-2 and set the default input to mic-in
12486 */
12487 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12488 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12489 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12490 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12491 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12492 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12493
Takashi Iwaicb53c622007-08-10 17:21:45 +020012494 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010012495 * mixer widget
12496 * Note: PASD motherboards uses the Line In 2 as the input for front
12497 * panel mic (mic 2)
12498 */
12499 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012500 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12501 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12502 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12503 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12504 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12505 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12506 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12507 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010012508 /*
12509 * Set up output mixers (0x0c - 0x0e)
12510 */
12511 /* set vol=0 to output mixers */
12512 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12513 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12514 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12515
12516 /* set up input amps for analog loopback */
12517 /* Amp Indices: DAC = 0, mixer = 1 */
12518 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12519 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12520 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12521 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12522 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12523 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12524
12525
12526 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
12527 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
12528 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
12529 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
12530 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12531 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
12532 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
12533
12534 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12535 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12536
12537 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12538 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12539
12540 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
12541 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12542 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12543 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
12544 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12545 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12546
12547 /* FIXME: use matrix-type input source selection */
12548 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12549 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12550 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
12551 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
12552 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
12553 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
12554 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
12555 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12556 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
12557 /* Input mixer2 */
12558 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12559 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12560 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12561 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12562 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12563 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12564 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12565 /* Input mixer3 */
12566 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12567 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12568 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12569 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12570 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12571 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12572 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12573
Takashi Iwaice875f02008-01-28 18:17:43 +010012574 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12575
Kailang Yangcd7509a2007-01-26 18:33:17 +010012576 { }
12577};
12578
Takashi Iwaia9111322011-05-02 11:30:18 +020012579static const struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012580
12581 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12582 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12583 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12584
12585 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12586 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12587 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12588 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12589
12590 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12591 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12592 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12593 {}
12594};
12595
Takashi Iwai18675e42010-09-08 15:55:44 +020012596/*
12597 * Pin config fixes
12598 */
12599enum {
12600 PINFIX_FSC_H270,
12601};
12602
12603static const struct alc_fixup alc262_fixups[] = {
12604 [PINFIX_FSC_H270] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010012605 .type = ALC_FIXUP_PINS,
12606 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai18675e42010-09-08 15:55:44 +020012607 { 0x14, 0x99130110 }, /* speaker */
12608 { 0x15, 0x0221142f }, /* front HP */
12609 { 0x1b, 0x0121141f }, /* rear HP */
12610 { }
12611 }
12612 },
Takashi Iwai18675e42010-09-08 15:55:44 +020012613};
12614
Takashi Iwaia9111322011-05-02 11:30:18 +020012615static const struct snd_pci_quirk alc262_fixup_tbl[] = {
Takashi Iwai18675e42010-09-08 15:55:44 +020012616 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270),
12617 {}
12618};
12619
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012620
Takashi Iwaicb53c622007-08-10 17:21:45 +020012621#ifdef CONFIG_SND_HDA_POWER_SAVE
12622#define alc262_loopbacks alc880_loopbacks
12623#endif
12624
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012625/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012626#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12627#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12628#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12629#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12630
12631/*
12632 * BIOS auto configuration
12633 */
12634static int alc262_parse_auto_config(struct hda_codec *codec)
12635{
12636 struct alc_spec *spec = codec->spec;
12637 int err;
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020012638 static const hda_nid_t alc262_ignore[] = { 0x1d, 0 };
Kailang Yangdf694da2005-12-05 19:42:22 +010012639
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012640 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12641 alc262_ignore);
12642 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012643 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012644 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012645 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012646 spec->multiout.max_channels = 2;
12647 spec->no_analog = 1;
12648 goto dig_only;
12649 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012650 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012651 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012652 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12653 if (err < 0)
12654 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012655 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012656 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012657 return err;
12658
12659 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12660
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012661 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012662 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012663
Takashi Iwai603c4012008-07-30 15:01:44 +020012664 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012665 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012666
Takashi Iwaid88897e2008-10-31 15:01:37 +010012667 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012668 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012669 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012670
Takashi Iwai776e1842007-08-29 15:07:11 +020012671 err = alc_auto_add_mic_boost(codec);
12672 if (err < 0)
12673 return err;
12674
Kailang Yang6227cdc2010-02-25 08:36:52 +010012675 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012676
Kailang Yangdf694da2005-12-05 19:42:22 +010012677 return 1;
12678}
12679
12680#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12681#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12682#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012683#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012684
12685
12686/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012687static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012688{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012689 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012690 alc262_auto_init_multi_out(codec);
12691 alc262_auto_init_hp_out(codec);
12692 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012693 alc262_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012694 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012695 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012696 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012697}
12698
12699/*
12700 * configuration and preset
12701 */
Takashi Iwaiea734962011-01-17 11:29:34 +010012702static const char * const alc262_models[ALC262_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012703 [ALC262_BASIC] = "basic",
12704 [ALC262_HIPPO] = "hippo",
12705 [ALC262_HIPPO_1] = "hippo_1",
12706 [ALC262_FUJITSU] = "fujitsu",
12707 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012708 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012709 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012710 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012711 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012712 [ALC262_BENQ_T31] = "benq-t31",
12713 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012714 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012715 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012716 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012717 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012718 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012719 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012720 [ALC262_AUTO] = "auto",
12721};
12722
Takashi Iwaia9111322011-05-02 11:30:18 +020012723static const struct snd_pci_quirk alc262_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012724 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012725 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012726 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12727 ALC262_HP_BPC),
12728 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12729 ALC262_HP_BPC),
Takashi Iwai5734a072011-01-19 17:07:12 +010012730 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1500, "HP z series",
12731 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012732 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12733 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012734 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012735 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012736 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012737 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012738 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012739 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012740 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012741 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012742 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12743 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12744 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012745 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12746 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012747 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012748 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012749 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012750 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012751 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012752 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012753 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012754 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012755#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012756 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12757 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012758#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012759 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012760 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012761 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012762 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012763 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012764 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012765 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12766 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012767 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012768 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012769 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012770 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012771 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012772 {}
12773};
12774
Takashi Iwaia9111322011-05-02 11:30:18 +020012775static const struct alc_config_preset alc262_presets[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010012776 [ALC262_BASIC] = {
12777 .mixers = { alc262_base_mixer },
12778 .init_verbs = { alc262_init_verbs },
12779 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12780 .dac_nids = alc262_dac_nids,
12781 .hp_nid = 0x03,
12782 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12783 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012784 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012785 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012786 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012787 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012788 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012789 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12790 .dac_nids = alc262_dac_nids,
12791 .hp_nid = 0x03,
12792 .dig_out_nid = ALC262_DIGOUT_NID,
12793 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12794 .channel_mode = alc262_modes,
12795 .input_mux = &alc262_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012796 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012797 .setup = alc262_hippo_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020012798 .init_hook = alc_inithook,
Kailang Yangccc656c2006-10-17 12:32:26 +020012799 },
12800 [ALC262_HIPPO_1] = {
12801 .mixers = { alc262_hippo1_mixer },
12802 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12803 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12804 .dac_nids = alc262_dac_nids,
12805 .hp_nid = 0x02,
12806 .dig_out_nid = ALC262_DIGOUT_NID,
12807 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12808 .channel_mode = alc262_modes,
12809 .input_mux = &alc262_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012810 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012811 .setup = alc262_hippo1_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020012812 .init_hook = alc_inithook,
Kailang Yangccc656c2006-10-17 12:32:26 +020012813 },
Takashi Iwai834be882006-03-01 14:16:17 +010012814 [ALC262_FUJITSU] = {
12815 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012816 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12817 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012818 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12819 .dac_nids = alc262_dac_nids,
12820 .hp_nid = 0x03,
12821 .dig_out_nid = ALC262_DIGOUT_NID,
12822 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12823 .channel_mode = alc262_modes,
12824 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwai0f0f3912011-04-28 16:26:24 +020012825 .unsol_event = alc_sku_unsol_event,
12826 .setup = alc262_fujitsu_setup,
12827 .init_hook = alc_inithook,
Takashi Iwai834be882006-03-01 14:16:17 +010012828 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012829 [ALC262_HP_BPC] = {
12830 .mixers = { alc262_HP_BPC_mixer },
12831 .init_verbs = { alc262_HP_BPC_init_verbs },
12832 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12833 .dac_nids = alc262_dac_nids,
12834 .hp_nid = 0x03,
12835 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12836 .channel_mode = alc262_modes,
12837 .input_mux = &alc262_HP_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012838 .unsol_event = alc_sku_unsol_event,
12839 .setup = alc262_hp_bpc_setup,
12840 .init_hook = alc_inithook,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012841 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012842 [ALC262_HP_BPC_D7000_WF] = {
12843 .mixers = { alc262_HP_BPC_WildWest_mixer },
12844 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12845 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12846 .dac_nids = alc262_dac_nids,
12847 .hp_nid = 0x03,
12848 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12849 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012850 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012851 .unsol_event = alc_sku_unsol_event,
12852 .setup = alc262_hp_wildwest_setup,
12853 .init_hook = alc_inithook,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012854 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012855 [ALC262_HP_BPC_D7000_WL] = {
12856 .mixers = { alc262_HP_BPC_WildWest_mixer,
12857 alc262_HP_BPC_WildWest_option_mixer },
12858 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12859 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12860 .dac_nids = alc262_dac_nids,
12861 .hp_nid = 0x03,
12862 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12863 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012864 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012865 .unsol_event = alc_sku_unsol_event,
12866 .setup = alc262_hp_wildwest_setup,
12867 .init_hook = alc_inithook,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012868 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012869 [ALC262_HP_TC_T5735] = {
12870 .mixers = { alc262_hp_t5735_mixer },
12871 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12872 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12873 .dac_nids = alc262_dac_nids,
12874 .hp_nid = 0x03,
12875 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12876 .channel_mode = alc262_modes,
12877 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012878 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012879 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012880 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012881 },
12882 [ALC262_HP_RP5700] = {
12883 .mixers = { alc262_hp_rp5700_mixer },
12884 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12885 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12886 .dac_nids = alc262_dac_nids,
12887 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12888 .channel_mode = alc262_modes,
12889 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012890 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012891 [ALC262_BENQ_ED8] = {
12892 .mixers = { alc262_base_mixer },
12893 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12894 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12895 .dac_nids = alc262_dac_nids,
12896 .hp_nid = 0x03,
12897 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12898 .channel_mode = alc262_modes,
12899 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012900 },
Kailang Yang272a5272007-05-14 11:00:38 +020012901 [ALC262_SONY_ASSAMD] = {
12902 .mixers = { alc262_sony_mixer },
12903 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12904 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12905 .dac_nids = alc262_dac_nids,
12906 .hp_nid = 0x02,
12907 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12908 .channel_mode = alc262_modes,
12909 .input_mux = &alc262_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012910 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012911 .setup = alc262_hippo_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020012912 .init_hook = alc_inithook,
Kailang Yang83c34212007-07-05 11:43:05 +020012913 },
12914 [ALC262_BENQ_T31] = {
12915 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012916 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12917 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012918 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12919 .dac_nids = alc262_dac_nids,
12920 .hp_nid = 0x03,
12921 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12922 .channel_mode = alc262_modes,
12923 .input_mux = &alc262_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012924 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012925 .setup = alc262_hippo_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020012926 .init_hook = alc_inithook,
Kailang Yangea1fb292008-08-26 12:58:38 +020012927 },
Tobin Davisf651b502007-10-26 12:40:47 +020012928 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012929 .mixers = { alc262_ultra_mixer },
12930 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012931 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012932 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12933 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012934 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12935 .channel_mode = alc262_modes,
12936 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012937 .adc_nids = alc262_adc_nids, /* ADC0 */
12938 .capsrc_nids = alc262_capsrc_nids,
12939 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012940 .unsol_event = alc262_ultra_unsol_event,
12941 .init_hook = alc262_ultra_automute,
12942 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012943 [ALC262_LENOVO_3000] = {
12944 .mixers = { alc262_lenovo_3000_mixer },
12945 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012946 alc262_lenovo_3000_unsol_verbs,
12947 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012948 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12949 .dac_nids = alc262_dac_nids,
12950 .hp_nid = 0x03,
12951 .dig_out_nid = ALC262_DIGOUT_NID,
12952 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12953 .channel_mode = alc262_modes,
12954 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwai0f0f3912011-04-28 16:26:24 +020012955 .unsol_event = alc_sku_unsol_event,
12956 .setup = alc262_lenovo_3000_setup,
12957 .init_hook = alc_inithook,
Jiang zhe0e31daf2008-03-20 12:12:39 +010012958 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012959 [ALC262_NEC] = {
12960 .mixers = { alc262_nec_mixer },
12961 .init_verbs = { alc262_nec_verbs },
12962 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12963 .dac_nids = alc262_dac_nids,
12964 .hp_nid = 0x03,
12965 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12966 .channel_mode = alc262_modes,
12967 .input_mux = &alc262_capture_source,
12968 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012969 [ALC262_TOSHIBA_S06] = {
12970 .mixers = { alc262_toshiba_s06_mixer },
12971 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12972 alc262_eapd_verbs },
12973 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12974 .capsrc_nids = alc262_dmic_capsrc_nids,
12975 .dac_nids = alc262_dac_nids,
12976 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012977 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012978 .dig_out_nid = ALC262_DIGOUT_NID,
12979 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12980 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012981 .unsol_event = alc_sku_unsol_event,
12982 .setup = alc262_toshiba_s06_setup,
12983 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012984 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012985 [ALC262_TOSHIBA_RX1] = {
12986 .mixers = { alc262_toshiba_rx1_mixer },
12987 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12988 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12989 .dac_nids = alc262_dac_nids,
12990 .hp_nid = 0x03,
12991 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12992 .channel_mode = alc262_modes,
12993 .input_mux = &alc262_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020012994 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012995 .setup = alc262_hippo_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020012996 .init_hook = alc_inithook,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012997 },
Tony Vroonba340e82009-02-02 19:01:30 +000012998 [ALC262_TYAN] = {
12999 .mixers = { alc262_tyan_mixer },
13000 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
13001 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
13002 .dac_nids = alc262_dac_nids,
13003 .hp_nid = 0x02,
13004 .dig_out_nid = ALC262_DIGOUT_NID,
13005 .num_channel_mode = ARRAY_SIZE(alc262_modes),
13006 .channel_mode = alc262_modes,
13007 .input_mux = &alc262_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020013008 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013009 .setup = alc262_tyan_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020013010 .init_hook = alc_hp_automute,
Tony Vroonba340e82009-02-02 19:01:30 +000013011 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013012};
13013
13014static int patch_alc262(struct hda_codec *codec)
13015{
13016 struct alc_spec *spec;
13017 int board_config;
13018 int err;
13019
Robert P. J. Daydc041e02006-12-19 14:44:15 +010013020 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010013021 if (spec == NULL)
13022 return -ENOMEM;
13023
13024 codec->spec = spec;
13025#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013026 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
13027 * under-run
13028 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013029 {
13030 int tmp;
13031 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
13032 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
13033 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
13034 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
13035 }
13036#endif
Kailang Yangda00c242010-03-19 11:23:45 +010013037 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013038
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013039 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
13040
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013041 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
13042 alc262_models,
13043 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010013044
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013045 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013046 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13047 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010013048 board_config = ALC262_AUTO;
13049 }
13050
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010013051 if (board_config == ALC262_AUTO) {
13052 alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups);
13053 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
13054 }
Takashi Iwai18675e42010-09-08 15:55:44 +020013055
Kailang Yangdf694da2005-12-05 19:42:22 +010013056 if (board_config == ALC262_AUTO) {
13057 /* automatic parse from the BIOS config */
13058 err = alc262_parse_auto_config(codec);
13059 if (err < 0) {
13060 alc_free(codec);
13061 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013062 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013063 printk(KERN_INFO
13064 "hda_codec: Cannot set up configuration "
13065 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013066 board_config = ALC262_BASIC;
13067 }
13068 }
13069
Takashi Iwaidc1eae22010-07-29 15:30:02 +020013070 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010013071 err = snd_hda_attach_beep_device(codec, 0x1);
13072 if (err < 0) {
13073 alc_free(codec);
13074 return err;
13075 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013076 }
13077
Kailang Yangdf694da2005-12-05 19:42:22 +010013078 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013079 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013080
Kailang Yangdf694da2005-12-05 19:42:22 +010013081 spec->stream_analog_playback = &alc262_pcm_analog_playback;
13082 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020013083
Kailang Yangdf694da2005-12-05 19:42:22 +010013084 spec->stream_digital_playback = &alc262_pcm_digital_playback;
13085 spec->stream_digital_capture = &alc262_pcm_digital_capture;
13086
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013087 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020013088 int i;
13089 /* check whether the digital-mic has to be supported */
13090 for (i = 0; i < spec->input_mux->num_items; i++) {
13091 if (spec->input_mux->items[i].index >= 9)
13092 break;
13093 }
13094 if (i < spec->input_mux->num_items) {
13095 /* use only ADC0 */
13096 spec->adc_nids = alc262_dmic_adc_nids;
13097 spec->num_adc_nids = 1;
13098 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010013099 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020013100 /* all analog inputs */
13101 /* check whether NID 0x07 is valid */
13102 unsigned int wcap = get_wcaps(codec, 0x07);
13103
13104 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013105 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020013106 if (wcap != AC_WID_AUD_IN) {
13107 spec->adc_nids = alc262_adc_nids_alt;
13108 spec->num_adc_nids =
13109 ARRAY_SIZE(alc262_adc_nids_alt);
13110 spec->capsrc_nids = alc262_capsrc_nids_alt;
13111 } else {
13112 spec->adc_nids = alc262_adc_nids;
13113 spec->num_adc_nids =
13114 ARRAY_SIZE(alc262_adc_nids);
13115 spec->capsrc_nids = alc262_capsrc_nids;
13116 }
Kailang Yangdf694da2005-12-05 19:42:22 +010013117 }
13118 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010013119 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013120 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020013121 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010013122 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010013123
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010013124 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai18675e42010-09-08 15:55:44 +020013125
Takashi Iwai2134ea42008-01-10 16:53:55 +010013126 spec->vmaster_nid = 0x0c;
13127
Kailang Yangdf694da2005-12-05 19:42:22 +010013128 codec->patch_ops = alc_patch_ops;
13129 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013130 spec->init_hook = alc262_auto_init;
Takashi Iwai1c7161532011-04-07 10:37:16 +020013131 spec->shutup = alc_eapd_shutup;
Kailang Yangbf1b0222010-10-21 08:49:56 +020013132
13133 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020013134#ifdef CONFIG_SND_HDA_POWER_SAVE
13135 if (!spec->loopback.amplist)
13136 spec->loopback.amplist = alc262_loopbacks;
13137#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020013138
Kailang Yangdf694da2005-12-05 19:42:22 +010013139 return 0;
13140}
13141
Kailang Yangdf694da2005-12-05 19:42:22 +010013142/*
Kailang Yanga361d842007-06-05 12:30:55 +020013143 * ALC268 channel source setting (2 channel)
13144 */
13145#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
13146#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020013147
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020013148static const hda_nid_t alc268_dac_nids[2] = {
Kailang Yanga361d842007-06-05 12:30:55 +020013149 /* front, hp */
13150 0x02, 0x03
13151};
13152
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020013153static const hda_nid_t alc268_adc_nids[2] = {
Kailang Yanga361d842007-06-05 12:30:55 +020013154 /* ADC0-1 */
13155 0x08, 0x07
13156};
13157
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020013158static const hda_nid_t alc268_adc_nids_alt[1] = {
Kailang Yanga361d842007-06-05 12:30:55 +020013159 /* ADC0 */
13160 0x08
13161};
13162
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020013163static const hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
Takashi Iwaie1406342008-02-11 18:32:32 +010013164
Takashi Iwaia9111322011-05-02 11:30:18 +020013165static const struct snd_kcontrol_new alc268_base_mixer[] = {
Kailang Yanga361d842007-06-05 12:30:55 +020013166 /* output mixer control */
13167 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13168 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13169 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13170 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013171 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13172 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
13173 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020013174 { }
13175};
13176
Takashi Iwaia9111322011-05-02 11:30:18 +020013177static const struct snd_kcontrol_new alc268_toshiba_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013178 /* output mixer control */
13179 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13180 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13181 ALC262_HIPPO_MASTER_SWITCH,
David Henningsson5f99f862011-01-04 15:24:24 +010013182 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13183 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
13184 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020013185 { }
13186};
13187
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013188/* bind Beep switches of both NID 0x0f and 0x10 */
Takashi Iwaia9111322011-05-02 11:30:18 +020013189static const struct hda_bind_ctls alc268_bind_beep_sw = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013190 .ops = &snd_hda_bind_sw,
13191 .values = {
13192 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
13193 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
13194 0
13195 },
13196};
13197
Takashi Iwaia9111322011-05-02 11:30:18 +020013198static const struct snd_kcontrol_new alc268_beep_mixer[] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013199 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
13200 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
13201 { }
13202};
13203
Takashi Iwaia9111322011-05-02 11:30:18 +020013204static const struct hda_verb alc268_eapd_verbs[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +020013205 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13206 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13207 { }
13208};
13209
Takashi Iwaid2738092007-08-16 14:59:45 +020013210/* Toshiba specific */
Takashi Iwaia9111322011-05-02 11:30:18 +020013211static const struct hda_verb alc268_toshiba_verbs[] = {
Takashi Iwaid2738092007-08-16 14:59:45 +020013212 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13213 { } /* end */
13214};
13215
13216/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020013217/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwaia9111322011-05-02 11:30:18 +020013218static const struct hda_bind_ctls alc268_acer_bind_master_vol = {
Takashi Iwai6bc96852007-08-17 09:02:12 +020013219 .ops = &snd_hda_bind_vol,
13220 .values = {
13221 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
13222 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
13223 0
13224 },
13225};
13226
Takashi Iwai0f0f3912011-04-28 16:26:24 +020013227static void alc268_acer_setup(struct hda_codec *codec)
Takashi Iwai889c4392007-08-23 18:56:52 +020013228{
13229 struct alc_spec *spec = codec->spec;
Takashi Iwai889c4392007-08-23 18:56:52 +020013230
Takashi Iwai0f0f3912011-04-28 16:26:24 +020013231 spec->autocfg.hp_pins[0] = 0x14;
13232 spec->autocfg.speaker_pins[0] = 0x15;
13233 spec->automute = 1;
13234 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai889c4392007-08-23 18:56:52 +020013235}
13236
Takashi Iwai0f0f3912011-04-28 16:26:24 +020013237#define alc268_acer_master_sw_get alc262_hp_master_sw_get
13238#define alc268_acer_master_sw_put alc262_hp_master_sw_put
Takashi Iwaid2738092007-08-16 14:59:45 +020013239
Takashi Iwaia9111322011-05-02 11:30:18 +020013240static const struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
Kailang Yang8ef355d2008-08-26 13:10:22 +020013241 /* output mixer control */
13242 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13243 {
13244 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13245 .name = "Master Playback Switch",
Takashi Iwai0f0f3912011-04-28 16:26:24 +020013246 .subdevice = HDA_SUBDEV_NID_FLAG | 0x15,
13247 .info = snd_ctl_boolean_mono_info,
13248 .get = alc268_acer_master_sw_get,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013249 .put = alc268_acer_master_sw_put,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013250 },
13251 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
13252 { }
13253};
13254
Takashi Iwaia9111322011-05-02 11:30:18 +020013255static const struct snd_kcontrol_new alc268_acer_mixer[] = {
Takashi Iwaid2738092007-08-16 14:59:45 +020013256 /* output mixer control */
13257 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13258 {
13259 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13260 .name = "Master Playback Switch",
Takashi Iwai0f0f3912011-04-28 16:26:24 +020013261 .subdevice = HDA_SUBDEV_NID_FLAG | 0x14,
13262 .info = snd_ctl_boolean_mono_info,
13263 .get = alc268_acer_master_sw_get,
Takashi Iwaid2738092007-08-16 14:59:45 +020013264 .put = alc268_acer_master_sw_put,
Takashi Iwaid2738092007-08-16 14:59:45 +020013265 },
David Henningsson5f99f862011-01-04 15:24:24 +010013266 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13267 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
13268 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020013269 { }
13270};
13271
Takashi Iwaia9111322011-05-02 11:30:18 +020013272static const struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013273 /* output mixer control */
13274 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13275 {
13276 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13277 .name = "Master Playback Switch",
Takashi Iwai0f0f3912011-04-28 16:26:24 +020013278 .subdevice = HDA_SUBDEV_NID_FLAG | 0x14,
13279 .info = snd_ctl_boolean_mono_info,
13280 .get = alc268_acer_master_sw_get,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013281 .put = alc268_acer_master_sw_put,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013282 },
David Henningsson5f99f862011-01-04 15:24:24 +010013283 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13284 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013285 { }
13286};
13287
Takashi Iwaia9111322011-05-02 11:30:18 +020013288static const struct hda_verb alc268_acer_aspire_one_verbs[] = {
Kailang Yang8ef355d2008-08-26 13:10:22 +020013289 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13290 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13291 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13292 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13293 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
13294 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
13295 { }
13296};
13297
Takashi Iwaia9111322011-05-02 11:30:18 +020013298static const struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013299 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
13300 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020013301 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13302 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013303 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13304 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020013305 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13306 { }
13307};
13308
13309/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013310#define alc268_toshiba_setup alc262_hippo_setup
Takashi Iwaid2738092007-08-16 14:59:45 +020013311
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013312static void alc268_acer_lc_setup(struct hda_codec *codec)
13313{
13314 struct alc_spec *spec = codec->spec;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020013315 spec->autocfg.hp_pins[0] = 0x15;
13316 spec->autocfg.speaker_pins[0] = 0x14;
13317 spec->automute_mixer_nid[0] = 0x0f;
13318 spec->automute = 1;
13319 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013320 spec->ext_mic.pin = 0x18;
13321 spec->ext_mic.mux_idx = 0;
13322 spec->int_mic.pin = 0x12;
13323 spec->int_mic.mux_idx = 6;
13324 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013325}
13326
Takashi Iwaia9111322011-05-02 11:30:18 +020013327static const struct snd_kcontrol_new alc268_dell_mixer[] = {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013328 /* output mixer control */
13329 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13330 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13331 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13332 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013333 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13334 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013335 { }
13336};
13337
Takashi Iwaia9111322011-05-02 11:30:18 +020013338static const struct hda_verb alc268_dell_verbs[] = {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013339 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13340 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13341 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013342 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013343 { }
13344};
13345
13346/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013347static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013348{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013349 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013350
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013351 spec->autocfg.hp_pins[0] = 0x15;
13352 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013353 spec->ext_mic.pin = 0x18;
13354 spec->ext_mic.mux_idx = 0;
13355 spec->int_mic.pin = 0x19;
13356 spec->int_mic.mux_idx = 1;
13357 spec->auto_mic = 1;
Takashi Iwaid922b512011-04-28 12:18:53 +020013358 spec->automute = 1;
13359 spec->automute_mode = ALC_AUTOMUTE_PIN;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013360}
13361
Takashi Iwaia9111322011-05-02 11:30:18 +020013362static const struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013363 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13364 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13365 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13366 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13367 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13368 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013369 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13370 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013371 { }
13372};
13373
Takashi Iwaia9111322011-05-02 11:30:18 +020013374static const struct hda_verb alc267_quanta_il1_verbs[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013375 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13376 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
13377 { }
13378};
13379
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013380static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013381{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013382 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013383 spec->autocfg.hp_pins[0] = 0x15;
13384 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013385 spec->ext_mic.pin = 0x18;
13386 spec->ext_mic.mux_idx = 0;
13387 spec->int_mic.pin = 0x19;
13388 spec->int_mic.mux_idx = 1;
13389 spec->auto_mic = 1;
Takashi Iwaid922b512011-04-28 12:18:53 +020013390 spec->automute = 1;
13391 spec->automute_mode = ALC_AUTOMUTE_PIN;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013392}
13393
Kailang Yanga361d842007-06-05 12:30:55 +020013394/*
13395 * generic initialization of ADC, input mixers and output mixers
13396 */
Takashi Iwaia9111322011-05-02 11:30:18 +020013397static const struct hda_verb alc268_base_init_verbs[] = {
Kailang Yanga361d842007-06-05 12:30:55 +020013398 /* Unmute DAC0-1 and set vol = 0 */
13399 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013400 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013401
13402 /*
13403 * Set up output mixers (0x0c - 0x0e)
13404 */
13405 /* set vol=0 to output mixers */
13406 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013407 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
13408
13409 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13410 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13411
13412 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13413 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
13414 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13415 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13416 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13417 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13418 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13419 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13420
13421 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13422 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13423 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13424 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013425 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013426
13427 /* set PCBEEP vol = 0, mute connections */
13428 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13429 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13430 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013431
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013432 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013433
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013434 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13435 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13436 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13437 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013438
Kailang Yanga361d842007-06-05 12:30:55 +020013439 { }
13440};
13441
13442/*
13443 * generic initialization of ADC, input mixers and output mixers
13444 */
Takashi Iwaia9111322011-05-02 11:30:18 +020013445static const struct hda_verb alc268_volume_init_verbs[] = {
Kailang Yanga361d842007-06-05 12:30:55 +020013446 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013447 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13448 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013449
13450 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13451 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13452 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13453 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13454 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13455
Kailang Yanga361d842007-06-05 12:30:55 +020013456 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013457 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13458 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13459
13460 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013461 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013462
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013463 /* set PCBEEP vol = 0, mute connections */
13464 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13465 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13466 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013467
13468 { }
13469};
13470
Takashi Iwaia9111322011-05-02 11:30:18 +020013471static const struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013472 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13473 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13474 { } /* end */
13475};
13476
Takashi Iwaia9111322011-05-02 11:30:18 +020013477static const struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
Kailang Yanga361d842007-06-05 12:30:55 +020013478 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13479 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013480 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013481 { } /* end */
13482};
13483
Takashi Iwaia9111322011-05-02 11:30:18 +020013484static const struct snd_kcontrol_new alc268_capture_mixer[] = {
Kailang Yanga361d842007-06-05 12:30:55 +020013485 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13486 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13487 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13488 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013489 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013490 { } /* end */
13491};
13492
Takashi Iwaia9111322011-05-02 11:30:18 +020013493static const struct hda_input_mux alc268_capture_source = {
Kailang Yanga361d842007-06-05 12:30:55 +020013494 .num_items = 4,
13495 .items = {
13496 { "Mic", 0x0 },
13497 { "Front Mic", 0x1 },
13498 { "Line", 0x2 },
13499 { "CD", 0x3 },
13500 },
13501};
13502
Takashi Iwaia9111322011-05-02 11:30:18 +020013503static const struct hda_input_mux alc268_acer_capture_source = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013504 .num_items = 3,
13505 .items = {
13506 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013507 { "Internal Mic", 0x1 },
13508 { "Line", 0x2 },
13509 },
13510};
13511
Takashi Iwaia9111322011-05-02 11:30:18 +020013512static const struct hda_input_mux alc268_acer_dmic_capture_source = {
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013513 .num_items = 3,
13514 .items = {
13515 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013516 { "Internal Mic", 0x6 },
13517 { "Line", 0x2 },
13518 },
13519};
13520
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013521#ifdef CONFIG_SND_DEBUG
Takashi Iwaia9111322011-05-02 11:30:18 +020013522static const struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013523 /* Volume widgets */
13524 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13525 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13526 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13527 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13528 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13529 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13530 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13531 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13532 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13533 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13534 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13535 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13536 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013537 /* The below appears problematic on some hardwares */
13538 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013539 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13540 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13541 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13542 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13543
13544 /* Modes for retasking pin widgets */
13545 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13546 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13547 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13548 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13549
13550 /* Controls for GPIO pins, assuming they are configured as outputs */
13551 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13552 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13553 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13554 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13555
13556 /* Switches to allow the digital SPDIF output pin to be enabled.
13557 * The ALC268 does not have an SPDIF input.
13558 */
13559 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13560
13561 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13562 * this output to turn on an external amplifier.
13563 */
13564 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13565 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13566
13567 { } /* end */
13568};
13569#endif
13570
Kailang Yanga361d842007-06-05 12:30:55 +020013571/* create input playback/capture controls for the given pin */
13572static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13573 const char *ctlname, int idx)
13574{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013575 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013576 int err;
13577
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013578 switch (nid) {
13579 case 0x14:
13580 case 0x16:
13581 dac = 0x02;
13582 break;
13583 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013584 case 0x1a: /* ALC259/269 only */
13585 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013586 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013587 dac = 0x03;
13588 break;
13589 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013590 snd_printd(KERN_WARNING "hda_codec: "
13591 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013592 return 0;
13593 }
13594 if (spec->multiout.dac_nids[0] != dac &&
13595 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013596 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013597 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013598 HDA_OUTPUT));
13599 if (err < 0)
13600 return err;
Takashi Iwaidda14412011-05-02 11:29:30 +020013601 spec->private_dac_nids[spec->multiout.num_dacs++] = dac;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013602 }
13603
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013604 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013605 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013606 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013607 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013608 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013609 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013610 if (err < 0)
13611 return err;
13612 return 0;
13613}
13614
13615/* add playback controls from the parsed DAC table */
13616static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13617 const struct auto_pin_cfg *cfg)
13618{
13619 hda_nid_t nid;
13620 int err;
13621
Kailang Yanga361d842007-06-05 12:30:55 +020013622 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013623
13624 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013625 if (nid) {
13626 const char *name;
13627 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13628 name = "Speaker";
13629 else
13630 name = "Front";
13631 err = alc268_new_analog_output(spec, nid, name, 0);
13632 if (err < 0)
13633 return err;
13634 }
Kailang Yanga361d842007-06-05 12:30:55 +020013635
13636 nid = cfg->speaker_pins[0];
13637 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013638 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013639 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13640 if (err < 0)
13641 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013642 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013643 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13644 if (err < 0)
13645 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013646 }
13647 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013648 if (nid) {
13649 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13650 if (err < 0)
13651 return err;
13652 }
Kailang Yanga361d842007-06-05 12:30:55 +020013653
13654 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13655 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013656 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013657 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013658 if (err < 0)
13659 return err;
13660 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013661 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013662}
13663
13664/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013665static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013666 const struct auto_pin_cfg *cfg)
13667{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013668 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013669}
13670
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013671static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13672 hda_nid_t nid, int pin_type)
13673{
13674 int idx;
13675
13676 alc_set_pin_output(codec, nid, pin_type);
13677 if (nid == 0x14 || nid == 0x16)
13678 idx = 0;
13679 else
13680 idx = 1;
13681 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13682}
13683
13684static void alc268_auto_init_multi_out(struct hda_codec *codec)
13685{
13686 struct alc_spec *spec = codec->spec;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013687 int i;
13688
13689 for (i = 0; i < spec->autocfg.line_outs; i++) {
13690 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013691 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13692 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13693 }
13694}
13695
13696static void alc268_auto_init_hp_out(struct hda_codec *codec)
13697{
13698 struct alc_spec *spec = codec->spec;
13699 hda_nid_t pin;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013700 int i;
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013701
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013702 for (i = 0; i < spec->autocfg.hp_outs; i++) {
13703 pin = spec->autocfg.hp_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013704 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013705 }
13706 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
13707 pin = spec->autocfg.speaker_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013708 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013709 }
13710 if (spec->autocfg.mono_out_pin)
13711 snd_hda_codec_write(codec, spec->autocfg.mono_out_pin, 0,
13712 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013713}
13714
Kailang Yanga361d842007-06-05 12:30:55 +020013715static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13716{
13717 struct alc_spec *spec = codec->spec;
13718 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13719 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13720 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13721 unsigned int dac_vol1, dac_vol2;
13722
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013723 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013724 snd_hda_codec_write(codec, speaker_nid, 0,
13725 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013726 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013727 snd_hda_codec_write(codec, 0x0f, 0,
13728 AC_VERB_SET_AMP_GAIN_MUTE,
13729 AMP_IN_UNMUTE(1));
13730 snd_hda_codec_write(codec, 0x10, 0,
13731 AC_VERB_SET_AMP_GAIN_MUTE,
13732 AMP_IN_UNMUTE(1));
13733 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013734 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013735 snd_hda_codec_write(codec, 0x0f, 0,
13736 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13737 snd_hda_codec_write(codec, 0x10, 0,
13738 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13739 }
13740
13741 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013742 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013743 dac_vol2 = AMP_OUT_ZERO;
13744 else if (line_nid == 0x15)
13745 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013746 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013747 dac_vol2 = AMP_OUT_ZERO;
13748 else if (hp_nid == 0x15)
13749 dac_vol1 = AMP_OUT_ZERO;
13750 if (line_nid != 0x16 || hp_nid != 0x16 ||
13751 spec->autocfg.line_out_pins[1] != 0x16 ||
13752 spec->autocfg.line_out_pins[2] != 0x16)
13753 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13754
13755 snd_hda_codec_write(codec, 0x02, 0,
13756 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13757 snd_hda_codec_write(codec, 0x03, 0,
13758 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13759}
13760
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013761/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013762#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13763#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013764#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013765#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13766
13767/*
13768 * BIOS auto configuration
13769 */
13770static int alc268_parse_auto_config(struct hda_codec *codec)
13771{
13772 struct alc_spec *spec = codec->spec;
13773 int err;
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020013774 static const hda_nid_t alc268_ignore[] = { 0 };
Kailang Yanga361d842007-06-05 12:30:55 +020013775
13776 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13777 alc268_ignore);
13778 if (err < 0)
13779 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013780 if (!spec->autocfg.line_outs) {
13781 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13782 spec->multiout.max_channels = 2;
13783 spec->no_analog = 1;
13784 goto dig_only;
13785 }
Kailang Yanga361d842007-06-05 12:30:55 +020013786 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013787 }
Kailang Yanga361d842007-06-05 12:30:55 +020013788 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13789 if (err < 0)
13790 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013791 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013792 if (err < 0)
13793 return err;
13794
13795 spec->multiout.max_channels = 2;
13796
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013797 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013798 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013799 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013800 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013801 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013802
Takashi Iwai892981f2009-03-02 08:04:35 +010013803 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013804 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013805
Takashi Iwaid88897e2008-10-31 15:01:37 +010013806 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013807 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013808 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013809
Takashi Iwai776e1842007-08-29 15:07:11 +020013810 err = alc_auto_add_mic_boost(codec);
13811 if (err < 0)
13812 return err;
13813
Kailang Yang6227cdc2010-02-25 08:36:52 +010013814 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013815
Kailang Yanga361d842007-06-05 12:30:55 +020013816 return 1;
13817}
13818
Kailang Yanga361d842007-06-05 12:30:55 +020013819#define alc268_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaiae0ebbf2011-03-10 14:11:59 +010013820#define alc268_auto_init_input_src alc882_auto_init_input_src
Kailang Yanga361d842007-06-05 12:30:55 +020013821
13822/* init callback for auto-configuration model -- overriding the default init */
13823static void alc268_auto_init(struct hda_codec *codec)
13824{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013825 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013826 alc268_auto_init_multi_out(codec);
13827 alc268_auto_init_hp_out(codec);
13828 alc268_auto_init_mono_speaker_out(codec);
13829 alc268_auto_init_analog_input(codec);
Takashi Iwaiae0ebbf2011-03-10 14:11:59 +010013830 alc268_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013831 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013832 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013833 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013834}
13835
13836/*
13837 * configuration and preset
13838 */
Takashi Iwaiea734962011-01-17 11:29:34 +010013839static const char * const alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013840 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013841 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013842 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013843 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013844 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013845 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013846 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013847 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013848#ifdef CONFIG_SND_DEBUG
13849 [ALC268_TEST] = "test",
13850#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013851 [ALC268_AUTO] = "auto",
13852};
13853
Takashi Iwaia9111322011-05-02 11:30:18 +020013854static const struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013855 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013856 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013857 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013858 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013859 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013860 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13861 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013862 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chen0a1896b2011-06-06 18:55:34 -040013863 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron 910", ALC268_AUTO),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013864 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13865 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013866 /* almost compatible with toshiba but with optional digital outs;
13867 * auto-probing seems working fine
13868 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013869 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013870 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013871 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013872 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013873 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013874 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013875 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013876 {}
13877};
13878
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013879/* Toshiba laptops have no unique PCI SSID but only codec SSID */
Takashi Iwaia9111322011-05-02 11:30:18 +020013880static const struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013881 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13882 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13883 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13884 ALC268_TOSHIBA),
13885 {}
13886};
13887
Takashi Iwaia9111322011-05-02 11:30:18 +020013888static const struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013889 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013890 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13891 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013892 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13893 alc267_quanta_il1_verbs },
13894 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13895 .dac_nids = alc268_dac_nids,
13896 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13897 .adc_nids = alc268_adc_nids_alt,
13898 .hp_nid = 0x03,
13899 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13900 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013901 .unsol_event = alc_sku_unsol_event,
13902 .setup = alc267_quanta_il1_setup,
13903 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013904 },
Kailang Yanga361d842007-06-05 12:30:55 +020013905 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013906 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13907 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013908 .init_verbs = { alc268_base_init_verbs },
13909 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13910 .dac_nids = alc268_dac_nids,
13911 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13912 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013913 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013914 .hp_nid = 0x03,
13915 .dig_out_nid = ALC268_DIGOUT_NID,
13916 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13917 .channel_mode = alc268_modes,
13918 .input_mux = &alc268_capture_source,
13919 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013920 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013921 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013922 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013923 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13924 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013925 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13926 .dac_nids = alc268_dac_nids,
13927 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13928 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013929 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013930 .hp_nid = 0x03,
13931 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13932 .channel_mode = alc268_modes,
13933 .input_mux = &alc268_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020013934 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013935 .setup = alc268_toshiba_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020013936 .init_hook = alc_inithook,
Takashi Iwaid2738092007-08-16 14:59:45 +020013937 },
13938 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013939 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013940 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013941 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13942 alc268_acer_verbs },
13943 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13944 .dac_nids = alc268_dac_nids,
13945 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13946 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013947 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013948 .hp_nid = 0x02,
13949 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13950 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013951 .input_mux = &alc268_acer_capture_source,
Takashi Iwai0f0f3912011-04-28 16:26:24 +020013952 .unsol_event = alc_sku_unsol_event,
13953 .setup = alc268_acer_setup,
13954 .init_hook = alc_inithook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013955 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013956 [ALC268_ACER_DMIC] = {
13957 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13958 alc268_beep_mixer },
13959 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13960 alc268_acer_verbs },
13961 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13962 .dac_nids = alc268_dac_nids,
13963 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13964 .adc_nids = alc268_adc_nids_alt,
13965 .capsrc_nids = alc268_capsrc_nids,
13966 .hp_nid = 0x02,
13967 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13968 .channel_mode = alc268_modes,
13969 .input_mux = &alc268_acer_dmic_capture_source,
Takashi Iwai0f0f3912011-04-28 16:26:24 +020013970 .unsol_event = alc_sku_unsol_event,
13971 .setup = alc268_acer_setup,
13972 .init_hook = alc_inithook,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013973 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013974 [ALC268_ACER_ASPIRE_ONE] = {
13975 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013976 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013977 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013978 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13979 alc268_acer_aspire_one_verbs },
13980 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13981 .dac_nids = alc268_dac_nids,
13982 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13983 .adc_nids = alc268_adc_nids_alt,
13984 .capsrc_nids = alc268_capsrc_nids,
13985 .hp_nid = 0x03,
13986 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13987 .channel_mode = alc268_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020013988 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013989 .setup = alc268_acer_lc_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020013990 .init_hook = alc_inithook,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013991 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013992 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013993 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13994 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013995 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13996 alc268_dell_verbs },
13997 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13998 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013999 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
14000 .adc_nids = alc268_adc_nids_alt,
14001 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014002 .hp_nid = 0x02,
14003 .num_channel_mode = ARRAY_SIZE(alc268_modes),
14004 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014005 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014006 .setup = alc268_dell_setup,
14007 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014008 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010014009 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010014010 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
14011 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010014012 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
14013 alc268_toshiba_verbs },
14014 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
14015 .dac_nids = alc268_dac_nids,
14016 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
14017 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010014018 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010014019 .hp_nid = 0x03,
14020 .dig_out_nid = ALC268_DIGOUT_NID,
14021 .num_channel_mode = ARRAY_SIZE(alc268_modes),
14022 .channel_mode = alc268_modes,
14023 .input_mux = &alc268_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020014024 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014025 .setup = alc268_toshiba_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020014026 .init_hook = alc_inithook,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010014027 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010014028#ifdef CONFIG_SND_DEBUG
14029 [ALC268_TEST] = {
14030 .mixers = { alc268_test_mixer, alc268_capture_mixer },
14031 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
14032 alc268_volume_init_verbs },
14033 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
14034 .dac_nids = alc268_dac_nids,
14035 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
14036 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010014037 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010014038 .hp_nid = 0x03,
14039 .dig_out_nid = ALC268_DIGOUT_NID,
14040 .num_channel_mode = ARRAY_SIZE(alc268_modes),
14041 .channel_mode = alc268_modes,
14042 .input_mux = &alc268_capture_source,
14043 },
14044#endif
Kailang Yanga361d842007-06-05 12:30:55 +020014045};
14046
14047static int patch_alc268(struct hda_codec *codec)
14048{
14049 struct alc_spec *spec;
14050 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010014051 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020014052
Julia Lawallef86f582009-12-19 08:18:03 +010014053 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020014054 if (spec == NULL)
14055 return -ENOMEM;
14056
14057 codec->spec = spec;
14058
14059 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
14060 alc268_models,
14061 alc268_cfg_tbl);
14062
Takashi Iwai3abf2f32009-08-19 20:05:02 +020014063 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
14064 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010014065 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020014066
Kailang Yanga361d842007-06-05 12:30:55 +020014067 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014068 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14069 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020014070 board_config = ALC268_AUTO;
14071 }
14072
14073 if (board_config == ALC268_AUTO) {
14074 /* automatic parse from the BIOS config */
14075 err = alc268_parse_auto_config(codec);
14076 if (err < 0) {
14077 alc_free(codec);
14078 return err;
14079 } else if (!err) {
14080 printk(KERN_INFO
14081 "hda_codec: Cannot set up configuration "
14082 "from BIOS. Using base mode...\n");
14083 board_config = ALC268_3ST;
14084 }
14085 }
14086
14087 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014088 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020014089
Kailang Yanga361d842007-06-05 12:30:55 +020014090 spec->stream_analog_playback = &alc268_pcm_analog_playback;
14091 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010014092 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020014093
Kailang Yanga361d842007-06-05 12:30:55 +020014094 spec->stream_digital_playback = &alc268_pcm_digital_playback;
14095
Takashi Iwai22971e32009-02-10 11:56:44 +010014096 has_beep = 0;
14097 for (i = 0; i < spec->num_mixers; i++) {
14098 if (spec->mixers[i] == alc268_beep_mixer) {
14099 has_beep = 1;
14100 break;
14101 }
14102 }
14103
14104 if (has_beep) {
14105 err = snd_hda_attach_beep_device(codec, 0x1);
14106 if (err < 0) {
14107 alc_free(codec);
14108 return err;
14109 }
14110 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
14111 /* override the amp caps for beep generator */
14112 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010014113 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
14114 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
14115 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
14116 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010014117 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010014118
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014119 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014120 /* check whether NID 0x07 is valid */
14121 unsigned int wcap = get_wcaps(codec, 0x07);
Kailang Yanga361d842007-06-05 12:30:55 +020014122
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014123 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014124 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020014125 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014126 if (spec->auto_mic ||
14127 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014128 spec->adc_nids = alc268_adc_nids_alt;
14129 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014130 if (spec->auto_mic)
14131 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014132 if (spec->auto_mic || spec->input_mux->num_items == 1)
14133 add_mixer(spec, alc268_capture_nosrc_mixer);
14134 else
14135 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014136 } else {
14137 spec->adc_nids = alc268_adc_nids;
14138 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010014139 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020014140 }
14141 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010014142
14143 spec->vmaster_nid = 0x02;
14144
Kailang Yanga361d842007-06-05 12:30:55 +020014145 codec->patch_ops = alc_patch_ops;
14146 if (board_config == ALC268_AUTO)
14147 spec->init_hook = alc268_auto_init;
Takashi Iwai1c7161532011-04-07 10:37:16 +020014148 spec->shutup = alc_eapd_shutup;
Kailang Yangea1fb292008-08-26 12:58:38 +020014149
Kailang Yangbf1b0222010-10-21 08:49:56 +020014150 alc_init_jacks(codec);
14151
Kailang Yanga361d842007-06-05 12:30:55 +020014152 return 0;
14153}
14154
14155/*
Kailang Yangf6a92242007-12-13 16:52:54 +010014156 * ALC269 channel source setting (2 channel)
14157 */
14158#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
14159
14160#define alc269_dac_nids alc260_dac_nids
14161
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020014162static const hda_nid_t alc269_adc_nids[1] = {
Kailang Yangf6a92242007-12-13 16:52:54 +010014163 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020014164 0x08,
14165};
14166
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020014167static const hda_nid_t alc269_capsrc_nids[1] = {
Takashi Iwaie01bf502008-08-21 16:25:07 +020014168 0x23,
14169};
14170
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020014171static const hda_nid_t alc269vb_adc_nids[1] = {
Kailang Yang84898e82010-02-04 14:16:14 +010014172 /* ADC1 */
14173 0x09,
14174};
14175
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020014176static const hda_nid_t alc269vb_capsrc_nids[1] = {
Kailang Yang84898e82010-02-04 14:16:14 +010014177 0x22,
14178};
14179
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020014180static const hda_nid_t alc269_adc_candidates[] = {
David Henningsson262ac222011-04-07 11:43:00 +020014181 0x08, 0x09, 0x07, 0x11,
Takashi Iwai66946352010-03-29 17:21:45 +020014182};
Takashi Iwaie01bf502008-08-21 16:25:07 +020014183
Kailang Yangf6a92242007-12-13 16:52:54 +010014184#define alc269_modes alc260_modes
14185#define alc269_capture_source alc880_lg_lw_capture_source
14186
Takashi Iwaia9111322011-05-02 11:30:18 +020014187static const struct snd_kcontrol_new alc269_base_mixer[] = {
Kailang Yangf6a92242007-12-13 16:52:54 +010014188 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14189 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14190 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14191 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14192 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14193 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014194 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010014195 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14196 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014197 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010014198 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14199 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
14200 { } /* end */
14201};
14202
Takashi Iwaia9111322011-05-02 11:30:18 +020014203static const struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014204 /* output mixer control */
14205 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14206 {
14207 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14208 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014209 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020014210 .info = snd_hda_mixer_amp_switch_info,
14211 .get = snd_hda_mixer_amp_switch_get,
14212 .put = alc268_acer_master_sw_put,
14213 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14214 },
14215 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14216 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014217 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014218 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14219 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014220 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014221 { }
14222};
14223
Takashi Iwaia9111322011-05-02 11:30:18 +020014224static const struct snd_kcontrol_new alc269_lifebook_mixer[] = {
Tony Vroon64154832008-11-06 15:08:49 +000014225 /* output mixer control */
14226 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14227 {
14228 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14229 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014230 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000014231 .info = snd_hda_mixer_amp_switch_info,
14232 .get = snd_hda_mixer_amp_switch_get,
14233 .put = alc268_acer_master_sw_put,
14234 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14235 },
14236 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14237 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014238 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014239 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14240 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014241 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014242 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
14243 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014244 HDA_CODEC_VOLUME("Dock Mic Boost Volume", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014245 { }
14246};
14247
Takashi Iwaia9111322011-05-02 11:30:18 +020014248static const struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020014249 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014250 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020014251 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014252 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020014253 { } /* end */
14254};
14255
Takashi Iwaia9111322011-05-02 11:30:18 +020014256static const struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
Kailang Yang84898e82010-02-04 14:16:14 +010014257 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14258 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14259 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14260 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14261 { } /* end */
14262};
14263
Takashi Iwaia9111322011-05-02 11:30:18 +020014264static const struct snd_kcontrol_new alc269_asus_mixer[] = {
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014265 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14266 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
14267 { } /* end */
14268};
14269
Kailang Yangf6a92242007-12-13 16:52:54 +010014270/* capture mixer elements */
Takashi Iwaia9111322011-05-02 11:30:18 +020014271static const struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
Kailang Yang84898e82010-02-04 14:16:14 +010014272 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14273 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014274 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
14275 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014276 { } /* end */
14277};
14278
Takashi Iwaia9111322011-05-02 11:30:18 +020014279static const struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020014280 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14281 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014282 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010014283 { } /* end */
14284};
14285
Takashi Iwaia9111322011-05-02 11:30:18 +020014286static const struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
Kailang Yang84898e82010-02-04 14:16:14 +010014287 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14288 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014289 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
14290 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014291 { } /* end */
14292};
14293
Takashi Iwaia9111322011-05-02 11:30:18 +020014294static const struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
Kailang Yang84898e82010-02-04 14:16:14 +010014295 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14296 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014297 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014298 { } /* end */
14299};
14300
Takashi Iwai26f5df22008-11-03 17:39:46 +010014301/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010014302#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020014303
Takashi Iwaia9111322011-05-02 11:30:18 +020014304static const struct hda_verb alc269_quanta_fl1_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014305 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14306 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14307 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14308 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14309 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14310 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14311 { }
14312};
14313
Takashi Iwaia9111322011-05-02 11:30:18 +020014314static const struct hda_verb alc269_lifebook_verbs[] = {
Tony Vroon64154832008-11-06 15:08:49 +000014315 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14316 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
14317 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14318 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14319 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14320 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14321 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14322 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14323 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14324 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14325 { }
14326};
14327
Kailang Yang60db6b52008-08-26 13:13:00 +020014328/* toggle speaker-output according to the hp-jack state */
14329static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
14330{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014331 alc_hp_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014332
14333 snd_hda_codec_write(codec, 0x20, 0,
14334 AC_VERB_SET_COEF_INDEX, 0x0c);
14335 snd_hda_codec_write(codec, 0x20, 0,
14336 AC_VERB_SET_PROC_COEF, 0x680);
14337
14338 snd_hda_codec_write(codec, 0x20, 0,
14339 AC_VERB_SET_COEF_INDEX, 0x0c);
14340 snd_hda_codec_write(codec, 0x20, 0,
14341 AC_VERB_SET_PROC_COEF, 0x480);
14342}
14343
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014344#define alc269_lifebook_speaker_automute \
14345 alc269_quanta_fl1_speaker_automute
Tony Vroon64154832008-11-06 15:08:49 +000014346
Tony Vroon64154832008-11-06 15:08:49 +000014347static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
14348{
14349 unsigned int present_laptop;
14350 unsigned int present_dock;
14351
Wu Fengguang864f92b2009-11-18 12:38:02 +080014352 present_laptop = snd_hda_jack_detect(codec, 0x18);
14353 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000014354
14355 /* Laptop mic port overrides dock mic port, design decision */
14356 if (present_dock)
14357 snd_hda_codec_write(codec, 0x23, 0,
14358 AC_VERB_SET_CONNECT_SEL, 0x3);
14359 if (present_laptop)
14360 snd_hda_codec_write(codec, 0x23, 0,
14361 AC_VERB_SET_CONNECT_SEL, 0x0);
14362 if (!present_dock && !present_laptop)
14363 snd_hda_codec_write(codec, 0x23, 0,
14364 AC_VERB_SET_CONNECT_SEL, 0x1);
14365}
14366
Kailang Yang60db6b52008-08-26 13:13:00 +020014367static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
14368 unsigned int res)
14369{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014370 switch (res >> 26) {
14371 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014372 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014373 break;
14374 case ALC880_MIC_EVENT:
14375 alc_mic_automute(codec);
14376 break;
14377 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014378}
14379
Tony Vroon64154832008-11-06 15:08:49 +000014380static void alc269_lifebook_unsol_event(struct hda_codec *codec,
14381 unsigned int res)
14382{
14383 if ((res >> 26) == ALC880_HP_EVENT)
14384 alc269_lifebook_speaker_automute(codec);
14385 if ((res >> 26) == ALC880_MIC_EVENT)
14386 alc269_lifebook_mic_autoswitch(codec);
14387}
14388
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014389static void alc269_quanta_fl1_setup(struct hda_codec *codec)
14390{
14391 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014392 spec->autocfg.hp_pins[0] = 0x15;
14393 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014394 spec->automute_mixer_nid[0] = 0x0c;
14395 spec->automute = 1;
14396 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014397 spec->ext_mic.pin = 0x18;
14398 spec->ext_mic.mux_idx = 0;
14399 spec->int_mic.pin = 0x19;
14400 spec->int_mic.mux_idx = 1;
14401 spec->auto_mic = 1;
14402}
14403
Kailang Yang60db6b52008-08-26 13:13:00 +020014404static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
14405{
14406 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014407 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014408}
14409
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014410static void alc269_lifebook_setup(struct hda_codec *codec)
14411{
14412 struct alc_spec *spec = codec->spec;
14413 spec->autocfg.hp_pins[0] = 0x15;
14414 spec->autocfg.hp_pins[1] = 0x1a;
14415 spec->autocfg.speaker_pins[0] = 0x14;
14416 spec->automute_mixer_nid[0] = 0x0c;
14417 spec->automute = 1;
14418 spec->automute_mode = ALC_AUTOMUTE_MIXER;
14419}
14420
Tony Vroon64154832008-11-06 15:08:49 +000014421static void alc269_lifebook_init_hook(struct hda_codec *codec)
14422{
14423 alc269_lifebook_speaker_automute(codec);
14424 alc269_lifebook_mic_autoswitch(codec);
14425}
14426
Takashi Iwaia9111322011-05-02 11:30:18 +020014427static const struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014428 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14429 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14430 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14431 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14432 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14433 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14434 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14435 {}
14436};
14437
Takashi Iwaia9111322011-05-02 11:30:18 +020014438static const struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014439 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14440 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14441 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14442 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
14443 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14444 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14445 {}
14446};
14447
Takashi Iwaia9111322011-05-02 11:30:18 +020014448static const struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
Kailang Yang84898e82010-02-04 14:16:14 +010014449 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14450 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14451 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14452 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14453 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14454 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14455 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14456 {}
14457};
14458
Takashi Iwaia9111322011-05-02 11:30:18 +020014459static const struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
Kailang Yang84898e82010-02-04 14:16:14 +010014460 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14461 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14462 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14463 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14464 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14465 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14466 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14467 {}
14468};
14469
Takashi Iwaia9111322011-05-02 11:30:18 +020014470static const struct hda_verb alc271_acer_dmic_verbs[] = {
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014471 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14472 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14473 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14474 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14475 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14476 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14477 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14478 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14479 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14480 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14481 { }
14482};
14483
Kailang Yang226b1ec2010-04-09 11:01:20 +020014484static void alc269_laptop_amic_setup(struct hda_codec *codec)
14485{
14486 struct alc_spec *spec = codec->spec;
14487 spec->autocfg.hp_pins[0] = 0x15;
14488 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014489 spec->automute_mixer_nid[0] = 0x0c;
14490 spec->automute = 1;
14491 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014492 spec->ext_mic.pin = 0x18;
14493 spec->ext_mic.mux_idx = 0;
14494 spec->int_mic.pin = 0x19;
14495 spec->int_mic.mux_idx = 1;
14496 spec->auto_mic = 1;
14497}
14498
Kailang Yang84898e82010-02-04 14:16:14 +010014499static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014500{
14501 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014502 spec->autocfg.hp_pins[0] = 0x15;
14503 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014504 spec->automute_mixer_nid[0] = 0x0c;
14505 spec->automute = 1;
14506 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014507 spec->ext_mic.pin = 0x18;
14508 spec->ext_mic.mux_idx = 0;
14509 spec->int_mic.pin = 0x12;
14510 spec->int_mic.mux_idx = 5;
14511 spec->auto_mic = 1;
14512}
14513
Kailang Yang226b1ec2010-04-09 11:01:20 +020014514static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014515{
14516 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014517 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014518 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014519 spec->automute_mixer_nid[0] = 0x0c;
14520 spec->automute = 1;
14521 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014522 spec->ext_mic.pin = 0x18;
14523 spec->ext_mic.mux_idx = 0;
14524 spec->int_mic.pin = 0x19;
14525 spec->int_mic.mux_idx = 1;
14526 spec->auto_mic = 1;
14527}
14528
Kailang Yang226b1ec2010-04-09 11:01:20 +020014529static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14530{
14531 struct alc_spec *spec = codec->spec;
14532 spec->autocfg.hp_pins[0] = 0x21;
14533 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020014534 spec->automute_mixer_nid[0] = 0x0c;
14535 spec->automute = 1;
14536 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014537 spec->ext_mic.pin = 0x18;
14538 spec->ext_mic.mux_idx = 0;
14539 spec->int_mic.pin = 0x12;
14540 spec->int_mic.mux_idx = 6;
14541 spec->auto_mic = 1;
14542}
14543
Kailang Yangf6a92242007-12-13 16:52:54 +010014544/*
14545 * generic initialization of ADC, input mixers and output mixers
14546 */
Takashi Iwaia9111322011-05-02 11:30:18 +020014547static const struct hda_verb alc269_init_verbs[] = {
Kailang Yangf6a92242007-12-13 16:52:54 +010014548 /*
14549 * Unmute ADC0 and set the default input to mic-in
14550 */
Kailang Yang84898e82010-02-04 14:16:14 +010014551 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014552
14553 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014554 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014555 */
14556 /* set vol=0 to output mixers */
14557 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14558 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14559
14560 /* set up input amps for analog loopback */
14561 /* Amp Indices: DAC = 0, mixer = 1 */
14562 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14563 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14564 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14565 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14566 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14567 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14568
14569 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14570 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14571 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14572 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14573 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14574 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14575 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14576
14577 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14578 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014579
Kailang Yang84898e82010-02-04 14:16:14 +010014580 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014581 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14582 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014583 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014584
14585 /* set EAPD */
14586 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014587 { }
14588};
14589
Takashi Iwaia9111322011-05-02 11:30:18 +020014590static const struct hda_verb alc269vb_init_verbs[] = {
Kailang Yang84898e82010-02-04 14:16:14 +010014591 /*
14592 * Unmute ADC0 and set the default input to mic-in
14593 */
14594 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14595
14596 /*
14597 * Set up output mixers (0x02 - 0x03)
14598 */
14599 /* set vol=0 to output mixers */
14600 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14601 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14602
14603 /* set up input amps for analog loopback */
14604 /* Amp Indices: DAC = 0, mixer = 1 */
14605 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14606 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14607 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14608 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14609 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14610 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14611
14612 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14613 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14614 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14615 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14616 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14617 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14618 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14619
14620 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14621 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14622
14623 /* FIXME: use Mux-type input source selection */
14624 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14625 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14626 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14627
14628 /* set EAPD */
14629 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014630 { }
14631};
14632
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014633#define alc269_auto_create_multi_out_ctls \
14634 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014635#define alc269_auto_create_input_ctls \
14636 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014637
14638#ifdef CONFIG_SND_HDA_POWER_SAVE
14639#define alc269_loopbacks alc880_loopbacks
14640#endif
14641
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014642/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014643#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14644#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14645#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14646#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14647
Takashi Iwaia9111322011-05-02 11:30:18 +020014648static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
Takashi Iwaif03d3112009-03-05 14:18:16 +010014649 .substreams = 1,
14650 .channels_min = 2,
14651 .channels_max = 8,
14652 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14653 /* NID is set in alc_build_pcms */
14654 .ops = {
14655 .open = alc880_playback_pcm_open,
14656 .prepare = alc880_playback_pcm_prepare,
14657 .cleanup = alc880_playback_pcm_cleanup
14658 },
14659};
14660
Takashi Iwaia9111322011-05-02 11:30:18 +020014661static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
Takashi Iwaif03d3112009-03-05 14:18:16 +010014662 .substreams = 1,
14663 .channels_min = 2,
14664 .channels_max = 2,
14665 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14666 /* NID is set in alc_build_pcms */
14667};
14668
Takashi Iwaiad358792010-03-30 18:00:59 +020014669#ifdef CONFIG_SND_HDA_POWER_SAVE
14670static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14671{
14672 switch (codec->subsystem_id) {
14673 case 0x103c1586:
14674 return 1;
14675 }
14676 return 0;
14677}
14678
14679static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14680{
14681 /* update mute-LED according to the speaker mute state */
14682 if (nid == 0x01 || nid == 0x14) {
14683 int pinval;
14684 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14685 HDA_AMP_MUTE)
14686 pinval = 0x24;
14687 else
14688 pinval = 0x20;
14689 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a542010-03-30 18:03:44 +020014690 snd_hda_codec_update_cache(codec, 0x19, 0,
14691 AC_VERB_SET_PIN_WIDGET_CONTROL,
14692 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014693 }
14694 return alc_check_power_status(codec, nid);
14695}
14696#endif /* CONFIG_SND_HDA_POWER_SAVE */
14697
Takashi Iwai840b64c2010-07-13 22:49:01 +020014698static int alc275_setup_dual_adc(struct hda_codec *codec)
14699{
14700 struct alc_spec *spec = codec->spec;
14701
14702 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14703 return 0;
14704 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14705 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14706 if (spec->ext_mic.pin <= 0x12) {
14707 spec->private_adc_nids[0] = 0x08;
14708 spec->private_adc_nids[1] = 0x11;
14709 spec->private_capsrc_nids[0] = 0x23;
14710 spec->private_capsrc_nids[1] = 0x22;
14711 } else {
14712 spec->private_adc_nids[0] = 0x11;
14713 spec->private_adc_nids[1] = 0x08;
14714 spec->private_capsrc_nids[0] = 0x22;
14715 spec->private_capsrc_nids[1] = 0x23;
14716 }
14717 spec->adc_nids = spec->private_adc_nids;
14718 spec->capsrc_nids = spec->private_capsrc_nids;
14719 spec->num_adc_nids = 2;
14720 spec->dual_adc_switch = 1;
14721 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14722 spec->adc_nids[0], spec->adc_nids[1]);
14723 return 1;
14724 }
14725 return 0;
14726}
14727
Takashi Iwaid433a672010-09-20 15:11:54 +020014728/* different alc269-variants */
14729enum {
14730 ALC269_TYPE_NORMAL,
Kailang Yang48c88e82010-11-23 08:56:16 +010014731 ALC269_TYPE_ALC258,
Takashi Iwaid433a672010-09-20 15:11:54 +020014732 ALC269_TYPE_ALC259,
Kailang Yang48c88e82010-11-23 08:56:16 +010014733 ALC269_TYPE_ALC269VB,
14734 ALC269_TYPE_ALC270,
Takashi Iwaid433a672010-09-20 15:11:54 +020014735 ALC269_TYPE_ALC271X,
14736};
14737
Kailang Yangf6a92242007-12-13 16:52:54 +010014738/*
14739 * BIOS auto configuration
14740 */
14741static int alc269_parse_auto_config(struct hda_codec *codec)
14742{
14743 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014744 int err;
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020014745 static const hda_nid_t alc269_ignore[] = { 0x1d, 0 };
Kailang Yangf6a92242007-12-13 16:52:54 +010014746
14747 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14748 alc269_ignore);
14749 if (err < 0)
14750 return err;
14751
14752 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14753 if (err < 0)
14754 return err;
Takashi Iwaif3550d12010-09-20 15:09:03 +020014755 if (spec->codec_variant == ALC269_TYPE_NORMAL)
14756 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
14757 else
14758 err = alc_auto_create_input_ctls(codec, &spec->autocfg, 0,
14759 0x22, 0);
Kailang Yangf6a92242007-12-13 16:52:54 +010014760 if (err < 0)
14761 return err;
14762
14763 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14764
Takashi Iwai757899a2010-07-30 10:48:14 +020014765 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014766
Takashi Iwai603c4012008-07-30 15:01:44 +020014767 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014768 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014769
Takashi Iwaid433a672010-09-20 15:11:54 +020014770 if (spec->codec_variant != ALC269_TYPE_NORMAL) {
Kailang Yang84898e82010-02-04 14:16:14 +010014771 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014772 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014773 } else {
14774 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014775 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014776 }
14777
Kailang Yangf6a92242007-12-13 16:52:54 +010014778 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014779 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014780
14781 if (!alc275_setup_dual_adc(codec))
14782 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14783 sizeof(alc269_adc_candidates));
Takashi Iwai66946352010-03-29 17:21:45 +020014784
Kailang Yangf6a92242007-12-13 16:52:54 +010014785 err = alc_auto_add_mic_boost(codec);
14786 if (err < 0)
14787 return err;
14788
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014789 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014790 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014791
Kailang Yangf6a92242007-12-13 16:52:54 +010014792 return 1;
14793}
14794
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014795#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14796#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014797#define alc269_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaiae0ebbf2011-03-10 14:11:59 +010014798#define alc269_auto_init_input_src alc882_auto_init_input_src
Kailang Yangf6a92242007-12-13 16:52:54 +010014799
14800
14801/* init callback for auto-configuration model -- overriding the default init */
14802static void alc269_auto_init(struct hda_codec *codec)
14803{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014804 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014805 alc269_auto_init_multi_out(codec);
14806 alc269_auto_init_hp_out(codec);
14807 alc269_auto_init_analog_input(codec);
Takashi Iwaiae0ebbf2011-03-10 14:11:59 +010014808 if (!spec->dual_adc_switch)
14809 alc269_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014810 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014811 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014812 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014813}
14814
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014815static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
14816{
14817 int val = alc_read_coef_idx(codec, 0x04);
14818 if (power_up)
14819 val |= 1 << 11;
14820 else
14821 val &= ~(1 << 11);
14822 alc_write_coef_idx(codec, 0x04, val);
14823}
14824
Takashi Iwai5402e4c2011-04-07 10:39:25 +020014825static void alc269_shutup(struct hda_codec *codec)
Kailang Yang977ddd62010-09-15 10:02:29 +020014826{
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014827 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017)
14828 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014829 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014830 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014831 msleep(150);
14832 }
Kailang Yang977ddd62010-09-15 10:02:29 +020014833}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014834
Takashi Iwai5402e4c2011-04-07 10:39:25 +020014835#ifdef SND_HDA_NEEDS_RESUME
Kailang Yang977ddd62010-09-15 10:02:29 +020014836static int alc269_resume(struct hda_codec *codec)
14837{
Kailang Yang977ddd62010-09-15 10:02:29 +020014838 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014839 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014840 msleep(150);
14841 }
14842
14843 codec->patch_ops.init(codec);
14844
14845 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014846 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014847 msleep(200);
14848 }
14849
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014850 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018)
14851 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014852
14853 snd_hda_codec_resume_amp(codec);
14854 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +020014855 hda_call_check_power_status(codec, 0x01);
Kailang Yang977ddd62010-09-15 10:02:29 +020014856 return 0;
14857}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014858#endif /* SND_HDA_NEEDS_RESUME */
Kailang Yang977ddd62010-09-15 10:02:29 +020014859
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014860static void alc269_fixup_hweq(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014861 const struct alc_fixup *fix, int action)
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014862{
14863 int coef;
14864
Takashi Iwai58701122011-01-13 15:41:45 +010014865 if (action != ALC_FIXUP_ACT_INIT)
Takashi Iwai9fb1ef22011-01-13 14:40:43 +010014866 return;
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014867 coef = alc_read_coef_idx(codec, 0x1e);
14868 alc_write_coef_idx(codec, 0x1e, coef | 0x80);
14869}
14870
Takashi Iwai6981d182011-04-15 10:11:12 +020014871static void alc271_fixup_dmic(struct hda_codec *codec,
14872 const struct alc_fixup *fix, int action)
14873{
Takashi Iwaia9111322011-05-02 11:30:18 +020014874 static const struct hda_verb verbs[] = {
Takashi Iwai6981d182011-04-15 10:11:12 +020014875 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14876 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14877 {}
14878 };
14879 unsigned int cfg;
14880
14881 if (strcmp(codec->chip_name, "ALC271X"))
14882 return;
14883 cfg = snd_hda_codec_get_pincfg(codec, 0x12);
14884 if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
14885 snd_hda_sequence_write(codec, verbs);
14886}
14887
Takashi Iwaiff818c22010-04-12 08:59:25 +020014888enum {
14889 ALC269_FIXUP_SONY_VAIO,
Takashi Iwai74dc8902011-01-13 14:14:41 +010014890 ALC275_FIXUP_SONY_VAIO_GPIO2,
David Henningsson145a9022010-09-16 10:07:53 +020014891 ALC269_FIXUP_DELL_M101Z,
David Henningsson022c92b2010-12-17 20:43:04 +010014892 ALC269_FIXUP_SKU_IGNORE,
David Henningssonac612402010-12-15 09:18:18 +010014893 ALC269_FIXUP_ASUS_G73JW,
Kailang Yang357f9152011-01-12 08:12:52 +010014894 ALC269_FIXUP_LENOVO_EAPD,
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014895 ALC275_FIXUP_SONY_HWEQ,
Takashi Iwai6981d182011-04-15 10:11:12 +020014896 ALC271_FIXUP_DMIC,
Takashi Iwaiff818c22010-04-12 08:59:25 +020014897};
14898
Takashi Iwaiff818c22010-04-12 08:59:25 +020014899static const struct alc_fixup alc269_fixups[] = {
14900 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014901 .type = ALC_FIXUP_VERBS,
14902 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020014903 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14904 {}
14905 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014906 },
Takashi Iwai74dc8902011-01-13 14:14:41 +010014907 [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014908 .type = ALC_FIXUP_VERBS,
14909 .v.verbs = (const struct hda_verb[]) {
Kailang Yang27855912010-12-21 09:09:53 +010014910 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
14911 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
14912 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
14913 { }
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014914 },
14915 .chained = true,
14916 .chain_id = ALC269_FIXUP_SONY_VAIO
Kailang Yang27855912010-12-21 09:09:53 +010014917 },
David Henningsson145a9022010-09-16 10:07:53 +020014918 [ALC269_FIXUP_DELL_M101Z] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014919 .type = ALC_FIXUP_VERBS,
14920 .v.verbs = (const struct hda_verb[]) {
David Henningsson145a9022010-09-16 10:07:53 +020014921 /* Enables internal speaker */
14922 {0x20, AC_VERB_SET_COEF_INDEX, 13},
14923 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
14924 {}
14925 }
14926 },
David Henningsson022c92b2010-12-17 20:43:04 +010014927 [ALC269_FIXUP_SKU_IGNORE] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014928 .type = ALC_FIXUP_SKU,
14929 .v.sku = ALC_FIXUP_SKU_IGNORE,
David Henningssonfe67b242010-12-15 08:01:46 +010014930 },
David Henningssonac612402010-12-15 09:18:18 +010014931 [ALC269_FIXUP_ASUS_G73JW] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014932 .type = ALC_FIXUP_PINS,
14933 .v.pins = (const struct alc_pincfg[]) {
David Henningssonac612402010-12-15 09:18:18 +010014934 { 0x17, 0x99130111 }, /* subwoofer */
14935 { }
14936 }
14937 },
Kailang Yang357f9152011-01-12 08:12:52 +010014938 [ALC269_FIXUP_LENOVO_EAPD] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014939 .type = ALC_FIXUP_VERBS,
14940 .v.verbs = (const struct hda_verb[]) {
Kailang Yang357f9152011-01-12 08:12:52 +010014941 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
14942 {}
14943 }
14944 },
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014945 [ALC275_FIXUP_SONY_HWEQ] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014946 .type = ALC_FIXUP_FUNC,
14947 .v.func = alc269_fixup_hweq,
14948 .chained = true,
14949 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
Takashi Iwai6981d182011-04-15 10:11:12 +020014950 },
14951 [ALC271_FIXUP_DMIC] = {
14952 .type = ALC_FIXUP_FUNC,
14953 .v.func = alc271_fixup_dmic,
14954 },
Takashi Iwaiff818c22010-04-12 08:59:25 +020014955};
14956
Takashi Iwaia9111322011-05-02 11:30:18 +020014957static const struct snd_pci_quirk alc269_fixup_tbl[] = {
Takashi Iwai74dc8902011-01-13 14:14:41 +010014958 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014959 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
14960 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
Takashi Iwai7039c742010-12-23 16:35:34 +010014961 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningsson145a9022010-09-16 10:07:53 +020014962 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
Takashi Iwai6981d182011-04-15 10:11:12 +020014963 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
David Henningsson022c92b2010-12-17 20:43:04 +010014964 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
David Henningssonded9f522011-01-26 11:46:12 +010014965 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
14966 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
14967 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
14968 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
David Henningssonac612402010-12-15 09:18:18 +010014969 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
Kailang Yang357f9152011-01-12 08:12:52 +010014970 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014971 {}
14972};
14973
14974
Kailang Yangf6a92242007-12-13 16:52:54 +010014975/*
14976 * configuration and preset
14977 */
Takashi Iwaiea734962011-01-17 11:29:34 +010014978static const char * const alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014979 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014980 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014981 [ALC269_AMIC] = "laptop-amic",
14982 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014983 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014984 [ALC269_LIFEBOOK] = "lifebook",
14985 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014986};
14987
Takashi Iwaia9111322011-05-02 11:30:18 +020014988static const struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014989 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014990 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020014991 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014992 ALC269_AMIC),
14993 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14994 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14995 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14996 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14997 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14998 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14999 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
15000 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
15001 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
Chih-Wei Huangc790ad32011-02-25 11:14:31 +080015002 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269VB_AMIC),
Kailang Yang84898e82010-02-04 14:16:14 +010015003 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
15004 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
15005 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
15006 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
15007 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
15008 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
15009 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
15010 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
15011 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
15012 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
15013 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
15014 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
15015 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
15016 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
15017 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
15018 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
15019 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
15020 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
15021 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
15022 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
15023 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
15024 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
15025 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
15026 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
15027 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
15028 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020015029 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010015030 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020015031 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010015032 ALC269_DMIC),
15033 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
15034 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020015035 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000015036 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010015037 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
15038 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
15039 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
15040 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
15041 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
15042 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010015043 {}
15044};
15045
Takashi Iwaia9111322011-05-02 11:30:18 +020015046static const struct alc_config_preset alc269_presets[] = {
Kailang Yangf6a92242007-12-13 16:52:54 +010015047 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015048 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010015049 .init_verbs = { alc269_init_verbs },
15050 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15051 .dac_nids = alc269_dac_nids,
15052 .hp_nid = 0x03,
15053 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15054 .channel_mode = alc269_modes,
15055 .input_mux = &alc269_capture_source,
15056 },
Kailang Yang60db6b52008-08-26 13:13:00 +020015057 [ALC269_QUANTA_FL1] = {
15058 .mixers = { alc269_quanta_fl1_mixer },
15059 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
15060 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15061 .dac_nids = alc269_dac_nids,
15062 .hp_nid = 0x03,
15063 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15064 .channel_mode = alc269_modes,
15065 .input_mux = &alc269_capture_source,
15066 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015067 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020015068 .init_hook = alc269_quanta_fl1_init_hook,
15069 },
Kailang Yang84898e82010-02-04 14:16:14 +010015070 [ALC269_AMIC] = {
15071 .mixers = { alc269_laptop_mixer },
15072 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020015073 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015074 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020015075 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15076 .dac_nids = alc269_dac_nids,
15077 .hp_nid = 0x03,
15078 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15079 .channel_mode = alc269_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015080 .unsol_event = alc_sku_unsol_event,
Kailang Yang84898e82010-02-04 14:16:14 +010015081 .setup = alc269_laptop_amic_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015082 .init_hook = alc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020015083 },
Kailang Yang84898e82010-02-04 14:16:14 +010015084 [ALC269_DMIC] = {
15085 .mixers = { alc269_laptop_mixer },
15086 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020015087 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015088 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020015089 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15090 .dac_nids = alc269_dac_nids,
15091 .hp_nid = 0x03,
15092 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15093 .channel_mode = alc269_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015094 .unsol_event = alc_sku_unsol_event,
Kailang Yang84898e82010-02-04 14:16:14 +010015095 .setup = alc269_laptop_dmic_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015096 .init_hook = alc_inithook,
Kailang Yang84898e82010-02-04 14:16:14 +010015097 },
15098 [ALC269VB_AMIC] = {
15099 .mixers = { alc269vb_laptop_mixer },
15100 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
15101 .init_verbs = { alc269vb_init_verbs,
15102 alc269vb_laptop_amic_init_verbs },
15103 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15104 .dac_nids = alc269_dac_nids,
15105 .hp_nid = 0x03,
15106 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15107 .channel_mode = alc269_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015108 .unsol_event = alc_sku_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020015109 .setup = alc269vb_laptop_amic_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015110 .init_hook = alc_inithook,
Kailang Yang84898e82010-02-04 14:16:14 +010015111 },
15112 [ALC269VB_DMIC] = {
15113 .mixers = { alc269vb_laptop_mixer },
15114 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
15115 .init_verbs = { alc269vb_init_verbs,
15116 alc269vb_laptop_dmic_init_verbs },
15117 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15118 .dac_nids = alc269_dac_nids,
15119 .hp_nid = 0x03,
15120 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15121 .channel_mode = alc269_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015122 .unsol_event = alc_sku_unsol_event,
Kailang Yang84898e82010-02-04 14:16:14 +010015123 .setup = alc269vb_laptop_dmic_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015124 .init_hook = alc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020015125 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010015126 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015127 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010015128 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010015129 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015130 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010015131 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15132 .dac_nids = alc269_dac_nids,
15133 .hp_nid = 0x03,
15134 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15135 .channel_mode = alc269_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015136 .unsol_event = alc_sku_unsol_event,
Kailang Yang84898e82010-02-04 14:16:14 +010015137 .setup = alc269_laptop_dmic_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015138 .init_hook = alc_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010015139 },
Tony Vroon64154832008-11-06 15:08:49 +000015140 [ALC269_LIFEBOOK] = {
15141 .mixers = { alc269_lifebook_mixer },
15142 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
15143 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15144 .dac_nids = alc269_dac_nids,
15145 .hp_nid = 0x03,
15146 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15147 .channel_mode = alc269_modes,
15148 .input_mux = &alc269_capture_source,
15149 .unsol_event = alc269_lifebook_unsol_event,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020015150 .setup = alc269_lifebook_setup,
Tony Vroon64154832008-11-06 15:08:49 +000015151 .init_hook = alc269_lifebook_init_hook,
15152 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020015153 [ALC271_ACER] = {
15154 .mixers = { alc269_asus_mixer },
15155 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
15156 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
15157 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15158 .dac_nids = alc269_dac_nids,
15159 .adc_nids = alc262_dmic_adc_nids,
15160 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
15161 .capsrc_nids = alc262_dmic_capsrc_nids,
15162 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15163 .channel_mode = alc269_modes,
15164 .input_mux = &alc269_capture_source,
15165 .dig_out_nid = ALC880_DIGOUT_NID,
15166 .unsol_event = alc_sku_unsol_event,
15167 .setup = alc269vb_laptop_dmic_setup,
15168 .init_hook = alc_inithook,
15169 },
Kailang Yangf6a92242007-12-13 16:52:54 +010015170};
15171
Kailang Yang977ddd62010-09-15 10:02:29 +020015172static int alc269_fill_coef(struct hda_codec *codec)
15173{
15174 int val;
15175
15176 if ((alc_read_coef_idx(codec, 0) & 0x00ff) < 0x015) {
15177 alc_write_coef_idx(codec, 0xf, 0x960b);
15178 alc_write_coef_idx(codec, 0xe, 0x8817);
15179 }
15180
15181 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x016) {
15182 alc_write_coef_idx(codec, 0xf, 0x960b);
15183 alc_write_coef_idx(codec, 0xe, 0x8814);
15184 }
15185
15186 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
15187 val = alc_read_coef_idx(codec, 0x04);
15188 /* Power up output pin */
15189 alc_write_coef_idx(codec, 0x04, val | (1<<11));
15190 }
15191
15192 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
15193 val = alc_read_coef_idx(codec, 0xd);
15194 if ((val & 0x0c00) >> 10 != 0x1) {
15195 /* Capless ramp up clock control */
Kailang Yangb896b4e2011-05-18 11:53:16 +020015196 alc_write_coef_idx(codec, 0xd, val | (1<<10));
Kailang Yang977ddd62010-09-15 10:02:29 +020015197 }
15198 val = alc_read_coef_idx(codec, 0x17);
15199 if ((val & 0x01c0) >> 6 != 0x4) {
15200 /* Class D power on reset */
Kailang Yangb896b4e2011-05-18 11:53:16 +020015201 alc_write_coef_idx(codec, 0x17, val | (1<<7));
Kailang Yang977ddd62010-09-15 10:02:29 +020015202 }
15203 }
Kailang Yangb896b4e2011-05-18 11:53:16 +020015204
15205 val = alc_read_coef_idx(codec, 0xd); /* Class D */
15206 alc_write_coef_idx(codec, 0xd, val | (1<<14));
15207
15208 val = alc_read_coef_idx(codec, 0x4); /* HP */
15209 alc_write_coef_idx(codec, 0x4, val | (1<<11));
15210
Kailang Yang977ddd62010-09-15 10:02:29 +020015211 return 0;
15212}
15213
Kailang Yangf6a92242007-12-13 16:52:54 +010015214static int patch_alc269(struct hda_codec *codec)
15215{
15216 struct alc_spec *spec;
Kailang Yang48c88e82010-11-23 08:56:16 +010015217 int board_config, coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010015218 int err;
15219
15220 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15221 if (spec == NULL)
15222 return -ENOMEM;
15223
15224 codec->spec = spec;
15225
Kailang Yangda00c242010-03-19 11:23:45 +010015226 alc_auto_parse_customize_define(codec);
15227
Kailang Yangc793bec2010-12-21 09:14:13 +010015228 if (codec->vendor_id == 0x10ec0269) {
15229 coef = alc_read_coef_idx(codec, 0);
15230 if ((coef & 0x00f0) == 0x0010) {
15231 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
15232 spec->cdefine.platform_type == 1) {
15233 alc_codec_rename(codec, "ALC271X");
15234 spec->codec_variant = ALC269_TYPE_ALC271X;
15235 } else if ((coef & 0xf000) == 0x1000) {
15236 spec->codec_variant = ALC269_TYPE_ALC270;
15237 } else if ((coef & 0xf000) == 0x2000) {
15238 alc_codec_rename(codec, "ALC259");
15239 spec->codec_variant = ALC269_TYPE_ALC259;
15240 } else if ((coef & 0xf000) == 0x3000) {
15241 alc_codec_rename(codec, "ALC258");
15242 spec->codec_variant = ALC269_TYPE_ALC258;
15243 } else {
15244 alc_codec_rename(codec, "ALC269VB");
15245 spec->codec_variant = ALC269_TYPE_ALC269VB;
15246 }
15247 } else
15248 alc_fix_pll_init(codec, 0x20, 0x04, 15);
15249 alc269_fill_coef(codec);
15250 }
Kailang Yang977ddd62010-09-15 10:02:29 +020015251
Kailang Yangf6a92242007-12-13 16:52:54 +010015252 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
15253 alc269_models,
15254 alc269_cfg_tbl);
15255
15256 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015257 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15258 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010015259 board_config = ALC269_AUTO;
15260 }
15261
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010015262 if (board_config == ALC269_AUTO) {
15263 alc_pick_fixup(codec, NULL, alc269_fixup_tbl, alc269_fixups);
15264 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
15265 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020015266
Kailang Yangf6a92242007-12-13 16:52:54 +010015267 if (board_config == ALC269_AUTO) {
15268 /* automatic parse from the BIOS config */
15269 err = alc269_parse_auto_config(codec);
15270 if (err < 0) {
15271 alc_free(codec);
15272 return err;
15273 } else if (!err) {
15274 printk(KERN_INFO
15275 "hda_codec: Cannot set up configuration "
15276 "from BIOS. Using base mode...\n");
15277 board_config = ALC269_BASIC;
15278 }
15279 }
15280
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015281 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020015282 err = snd_hda_attach_beep_device(codec, 0x1);
15283 if (err < 0) {
15284 alc_free(codec);
15285 return err;
15286 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015287 }
15288
Kailang Yangf6a92242007-12-13 16:52:54 +010015289 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015290 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010015291
Kailang Yang84898e82010-02-04 14:16:14 +010015292 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010015293 /* Due to a hardware problem on Lenovo Ideadpad, we need to
15294 * fix the sample rate of analog I/O to 44.1kHz
15295 */
15296 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
15297 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020015298 } else if (spec->dual_adc_switch) {
15299 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15300 /* switch ADC dynamically */
15301 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010015302 } else {
15303 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15304 spec->stream_analog_capture = &alc269_pcm_analog_capture;
15305 }
Kailang Yangf6a92242007-12-13 16:52:54 +010015306 spec->stream_digital_playback = &alc269_pcm_digital_playback;
15307 spec->stream_digital_capture = &alc269_pcm_digital_capture;
15308
Takashi Iwai66946352010-03-29 17:21:45 +020015309 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
Kailang Yang1657cbd2010-11-23 08:53:32 +010015310 if (spec->codec_variant == ALC269_TYPE_NORMAL) {
Takashi Iwai66946352010-03-29 17:21:45 +020015311 spec->adc_nids = alc269_adc_nids;
15312 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
15313 spec->capsrc_nids = alc269_capsrc_nids;
15314 } else {
15315 spec->adc_nids = alc269vb_adc_nids;
15316 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
15317 spec->capsrc_nids = alc269vb_capsrc_nids;
15318 }
Kailang Yang84898e82010-02-04 14:16:14 +010015319 }
15320
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015321 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015322 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015323 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010015324 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010015325
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010015326 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwaiff818c22010-04-12 08:59:25 +020015327
Takashi Iwai100d5eb2009-08-10 11:55:51 +020015328 spec->vmaster_nid = 0x02;
15329
Kailang Yangf6a92242007-12-13 16:52:54 +010015330 codec->patch_ops = alc_patch_ops;
Kailang Yang977ddd62010-09-15 10:02:29 +020015331#ifdef SND_HDA_NEEDS_RESUME
15332 codec->patch_ops.resume = alc269_resume;
15333#endif
Kailang Yangf6a92242007-12-13 16:52:54 +010015334 if (board_config == ALC269_AUTO)
15335 spec->init_hook = alc269_auto_init;
Takashi Iwai5402e4c2011-04-07 10:39:25 +020015336 spec->shutup = alc269_shutup;
Kailang Yangbf1b0222010-10-21 08:49:56 +020015337
15338 alc_init_jacks(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010015339#ifdef CONFIG_SND_HDA_POWER_SAVE
15340 if (!spec->loopback.amplist)
15341 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020015342 if (alc269_mic2_for_mute_led(codec))
15343 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010015344#endif
15345
15346 return 0;
15347}
15348
15349/*
Kailang Yangdf694da2005-12-05 19:42:22 +010015350 * ALC861 channel source setting (2/6 channel selection for 3-stack)
15351 */
15352
15353/*
15354 * set the path ways for 2 channel output
15355 * need to set the codec line out and mic 1 pin widgets to inputs
15356 */
Takashi Iwaia9111322011-05-02 11:30:18 +020015357static const struct hda_verb alc861_threestack_ch2_init[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010015358 /* set pin widget 1Ah (line in) for input */
15359 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015360 /* set pin widget 18h (mic1/2) for input, for mic also enable
15361 * the vref
15362 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015363 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15364
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015365 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15366#if 0
15367 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15368 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15369#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015370 { } /* end */
15371};
15372/*
15373 * 6ch mode
15374 * need to set the codec line out and mic 1 pin widgets to outputs
15375 */
Takashi Iwaia9111322011-05-02 11:30:18 +020015376static const struct hda_verb alc861_threestack_ch6_init[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010015377 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15378 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15379 /* set pin widget 18h (mic1) for output (CLFE)*/
15380 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15381
15382 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015383 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015384
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015385 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15386#if 0
15387 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15388 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15389#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015390 { } /* end */
15391};
15392
Takashi Iwaia9111322011-05-02 11:30:18 +020015393static const struct hda_channel_mode alc861_threestack_modes[2] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010015394 { 2, alc861_threestack_ch2_init },
15395 { 6, alc861_threestack_ch6_init },
15396};
Takashi Iwai22309c32006-08-09 16:57:28 +020015397/* Set mic1 as input and unmute the mixer */
Takashi Iwaia9111322011-05-02 11:30:18 +020015398static const struct hda_verb alc861_uniwill_m31_ch2_init[] = {
Takashi Iwai22309c32006-08-09 16:57:28 +020015399 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15400 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15401 { } /* end */
15402};
15403/* Set mic1 as output and mute mixer */
Takashi Iwaia9111322011-05-02 11:30:18 +020015404static const struct hda_verb alc861_uniwill_m31_ch4_init[] = {
Takashi Iwai22309c32006-08-09 16:57:28 +020015405 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15406 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15407 { } /* end */
15408};
15409
Takashi Iwaia9111322011-05-02 11:30:18 +020015410static const struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
Takashi Iwai22309c32006-08-09 16:57:28 +020015411 { 2, alc861_uniwill_m31_ch2_init },
15412 { 4, alc861_uniwill_m31_ch4_init },
15413};
Kailang Yangdf694da2005-12-05 19:42:22 +010015414
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015415/* Set mic1 and line-in as input and unmute the mixer */
Takashi Iwaia9111322011-05-02 11:30:18 +020015416static const struct hda_verb alc861_asus_ch2_init[] = {
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015417 /* set pin widget 1Ah (line in) for input */
15418 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015419 /* set pin widget 18h (mic1/2) for input, for mic also enable
15420 * the vref
15421 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015422 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15423
15424 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15425#if 0
15426 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15427 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15428#endif
15429 { } /* end */
15430};
15431/* Set mic1 nad line-in as output and mute mixer */
Takashi Iwaia9111322011-05-02 11:30:18 +020015432static const struct hda_verb alc861_asus_ch6_init[] = {
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015433 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15434 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15435 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15436 /* set pin widget 18h (mic1) for output (CLFE)*/
15437 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15438 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15439 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
15440 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
15441
15442 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15443#if 0
15444 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15445 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15446#endif
15447 { } /* end */
15448};
15449
Takashi Iwaia9111322011-05-02 11:30:18 +020015450static const struct hda_channel_mode alc861_asus_modes[2] = {
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015451 { 2, alc861_asus_ch2_init },
15452 { 6, alc861_asus_ch6_init },
15453};
15454
Kailang Yangdf694da2005-12-05 19:42:22 +010015455/* patch-ALC861 */
15456
Takashi Iwaia9111322011-05-02 11:30:18 +020015457static const struct snd_kcontrol_new alc861_base_mixer[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010015458 /* output mixer control */
15459 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15460 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15461 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15462 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15463 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15464
15465 /*Input mixer control */
15466 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15467 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15468 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15469 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15470 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15471 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15472 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15473 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15474 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15475 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015476
Kailang Yangdf694da2005-12-05 19:42:22 +010015477 { } /* end */
15478};
15479
Takashi Iwaia9111322011-05-02 11:30:18 +020015480static const struct snd_kcontrol_new alc861_3ST_mixer[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010015481 /* output mixer control */
15482 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15483 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15484 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15485 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15486 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15487
15488 /* Input mixer control */
15489 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15490 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15491 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15492 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15493 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15494 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15495 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15496 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15497 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15498 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015499
Kailang Yangdf694da2005-12-05 19:42:22 +010015500 {
15501 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15502 .name = "Channel Mode",
15503 .info = alc_ch_mode_info,
15504 .get = alc_ch_mode_get,
15505 .put = alc_ch_mode_put,
15506 .private_value = ARRAY_SIZE(alc861_threestack_modes),
15507 },
15508 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015509};
15510
Takashi Iwaia9111322011-05-02 11:30:18 +020015511static const struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015512 /* output mixer control */
15513 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15514 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15515 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015516
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015517 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015518};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015519
Takashi Iwaia9111322011-05-02 11:30:18 +020015520static const struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
Takashi Iwai22309c32006-08-09 16:57:28 +020015521 /* output mixer control */
15522 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15523 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15524 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15525 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15526 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15527
15528 /* Input mixer control */
15529 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15530 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15531 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15532 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15533 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15534 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15535 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15536 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15537 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15538 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015539
Takashi Iwai22309c32006-08-09 16:57:28 +020015540 {
15541 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15542 .name = "Channel Mode",
15543 .info = alc_ch_mode_info,
15544 .get = alc_ch_mode_get,
15545 .put = alc_ch_mode_put,
15546 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
15547 },
15548 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015549};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015550
Takashi Iwaia9111322011-05-02 11:30:18 +020015551static const struct snd_kcontrol_new alc861_asus_mixer[] = {
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015552 /* output mixer control */
15553 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15554 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15555 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15556 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15557 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15558
15559 /* Input mixer control */
15560 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15561 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15562 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15563 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15564 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15565 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15566 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15567 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15568 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015569 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
15570
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015571 {
15572 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15573 .name = "Channel Mode",
15574 .info = alc_ch_mode_info,
15575 .get = alc_ch_mode_get,
15576 .put = alc_ch_mode_put,
15577 .private_value = ARRAY_SIZE(alc861_asus_modes),
15578 },
15579 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015580};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015581
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015582/* additional mixer */
Takashi Iwaia9111322011-05-02 11:30:18 +020015583static const struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015584 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15585 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015586 { }
15587};
15588
Kailang Yangdf694da2005-12-05 19:42:22 +010015589/*
15590 * generic initialization of ADC, input mixers and output mixers
15591 */
Takashi Iwaia9111322011-05-02 11:30:18 +020015592static const struct hda_verb alc861_base_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010015593 /*
15594 * Unmute ADC0 and set the default input to mic-in
15595 */
15596 /* port-A for surround (rear panel) */
15597 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15598 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
15599 /* port-B for mic-in (rear panel) with vref */
15600 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15601 /* port-C for line-in (rear panel) */
15602 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15603 /* port-D for Front */
15604 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15605 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15606 /* port-E for HP out (front panel) */
15607 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15608 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015609 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015610 /* port-F for mic-in (front panel) with vref */
15611 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15612 /* port-G for CLFE (rear panel) */
15613 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15614 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15615 /* port-H for side (rear panel) */
15616 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15617 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15618 /* CD-in */
15619 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15620 /* route front mic to ADC1*/
15621 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15622 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015623
Kailang Yangdf694da2005-12-05 19:42:22 +010015624 /* Unmute DAC0~3 & spdif out*/
15625 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15626 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15627 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15628 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15629 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015630
Kailang Yangdf694da2005-12-05 19:42:22 +010015631 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15632 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15633 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15634 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15635 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015636
Kailang Yangdf694da2005-12-05 19:42:22 +010015637 /* Unmute Stereo Mixer 15 */
15638 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15639 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15640 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015641 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015642
15643 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15644 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15645 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15646 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15647 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15648 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15649 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15650 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015651 /* hp used DAC 3 (Front) */
15652 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015653 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15654
15655 { }
15656};
15657
Takashi Iwaia9111322011-05-02 11:30:18 +020015658static const struct hda_verb alc861_threestack_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010015659 /*
15660 * Unmute ADC0 and set the default input to mic-in
15661 */
15662 /* port-A for surround (rear panel) */
15663 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15664 /* port-B for mic-in (rear panel) with vref */
15665 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15666 /* port-C for line-in (rear panel) */
15667 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15668 /* port-D for Front */
15669 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15670 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15671 /* port-E for HP out (front panel) */
15672 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15673 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015674 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015675 /* port-F for mic-in (front panel) with vref */
15676 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15677 /* port-G for CLFE (rear panel) */
15678 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15679 /* port-H for side (rear panel) */
15680 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15681 /* CD-in */
15682 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15683 /* route front mic to ADC1*/
15684 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15685 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15686 /* Unmute DAC0~3 & spdif out*/
15687 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15688 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15689 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15690 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15691 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015692
Kailang Yangdf694da2005-12-05 19:42:22 +010015693 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15694 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15695 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15696 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15697 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015698
Kailang Yangdf694da2005-12-05 19:42:22 +010015699 /* Unmute Stereo Mixer 15 */
15700 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15701 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15702 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015703 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015704
15705 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15706 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15707 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15708 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15709 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15710 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15711 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15712 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015713 /* hp used DAC 3 (Front) */
15714 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015715 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15716 { }
15717};
Takashi Iwai22309c32006-08-09 16:57:28 +020015718
Takashi Iwaia9111322011-05-02 11:30:18 +020015719static const struct hda_verb alc861_uniwill_m31_init_verbs[] = {
Takashi Iwai22309c32006-08-09 16:57:28 +020015720 /*
15721 * Unmute ADC0 and set the default input to mic-in
15722 */
15723 /* port-A for surround (rear panel) */
15724 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15725 /* port-B for mic-in (rear panel) with vref */
15726 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15727 /* port-C for line-in (rear panel) */
15728 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15729 /* port-D for Front */
15730 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15731 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15732 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015733 /* this has to be set to VREF80 */
15734 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015735 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015736 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015737 /* port-F for mic-in (front panel) with vref */
15738 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15739 /* port-G for CLFE (rear panel) */
15740 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15741 /* port-H for side (rear panel) */
15742 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15743 /* CD-in */
15744 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15745 /* route front mic to ADC1*/
15746 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15747 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15748 /* Unmute DAC0~3 & spdif out*/
15749 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15750 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15751 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15752 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15753 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015754
Takashi Iwai22309c32006-08-09 16:57:28 +020015755 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15756 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15757 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15758 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15759 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015760
Takashi Iwai22309c32006-08-09 16:57:28 +020015761 /* Unmute Stereo Mixer 15 */
15762 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15763 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15764 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015765 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015766
15767 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15768 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15769 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15770 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15771 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15772 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15773 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15774 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015775 /* hp used DAC 3 (Front) */
15776 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015777 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15778 { }
15779};
15780
Takashi Iwaia9111322011-05-02 11:30:18 +020015781static const struct hda_verb alc861_asus_init_verbs[] = {
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015782 /*
15783 * Unmute ADC0 and set the default input to mic-in
15784 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015785 /* port-A for surround (rear panel)
15786 * according to codec#0 this is the HP jack
15787 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015788 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15789 /* route front PCM to HP */
15790 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15791 /* port-B for mic-in (rear panel) with vref */
15792 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15793 /* port-C for line-in (rear panel) */
15794 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15795 /* port-D for Front */
15796 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15797 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15798 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015799 /* this has to be set to VREF80 */
15800 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015801 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015802 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015803 /* port-F for mic-in (front panel) with vref */
15804 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15805 /* port-G for CLFE (rear panel) */
15806 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15807 /* port-H for side (rear panel) */
15808 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15809 /* CD-in */
15810 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15811 /* route front mic to ADC1*/
15812 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15813 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15814 /* Unmute DAC0~3 & spdif out*/
15815 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15816 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15817 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15818 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15819 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15820 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15821 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15822 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15823 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15824 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015825
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015826 /* Unmute Stereo Mixer 15 */
15827 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15828 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15829 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015830 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015831
15832 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15833 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15834 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15835 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15836 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15837 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15838 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15839 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015840 /* hp used DAC 3 (Front) */
15841 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015842 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15843 { }
15844};
15845
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015846/* additional init verbs for ASUS laptops */
Takashi Iwaia9111322011-05-02 11:30:18 +020015847static const struct hda_verb alc861_asus_laptop_init_verbs[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015848 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15849 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15850 { }
15851};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015852
Kailang Yangdf694da2005-12-05 19:42:22 +010015853/*
15854 * generic initialization of ADC, input mixers and output mixers
15855 */
Takashi Iwaia9111322011-05-02 11:30:18 +020015856static const struct hda_verb alc861_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010015857 /*
15858 * Unmute ADC0 and set the default input to mic-in
15859 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015860 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015861 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015862
Kailang Yangdf694da2005-12-05 19:42:22 +010015863 /* Unmute DAC0~3 & spdif out*/
15864 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15865 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15866 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15867 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15868 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015869
Kailang Yangdf694da2005-12-05 19:42:22 +010015870 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15871 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15872 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15873 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15874 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015875
Kailang Yangdf694da2005-12-05 19:42:22 +010015876 /* Unmute Stereo Mixer 15 */
15877 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15878 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15879 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15880 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15881
Takashi Iwai1c209302009-07-22 15:17:45 +020015882 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15883 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15884 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15885 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15886 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15887 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15888 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15889 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015890
15891 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15892 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015893 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15894 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015895 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15896 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015897 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15898 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015899
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015900 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015901
15902 { }
15903};
15904
Takashi Iwaia9111322011-05-02 11:30:18 +020015905static const struct hda_verb alc861_toshiba_init_verbs[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015906 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015907
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015908 { }
15909};
15910
15911/* toggle speaker-output according to the hp-jack state */
15912static void alc861_toshiba_automute(struct hda_codec *codec)
15913{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015914 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015915
Takashi Iwai47fd8302007-08-10 17:11:07 +020015916 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15917 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15918 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15919 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015920}
15921
15922static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15923 unsigned int res)
15924{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015925 if ((res >> 26) == ALC880_HP_EVENT)
15926 alc861_toshiba_automute(codec);
15927}
15928
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015929/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015930#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15931#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15932#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15933#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15934
15935
15936#define ALC861_DIGOUT_NID 0x07
15937
Takashi Iwaia9111322011-05-02 11:30:18 +020015938static const struct hda_channel_mode alc861_8ch_modes[1] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010015939 { 8, NULL }
15940};
15941
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020015942static const hda_nid_t alc861_dac_nids[4] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010015943 /* front, surround, clfe, side */
15944 0x03, 0x06, 0x05, 0x04
15945};
15946
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020015947static const hda_nid_t alc660_dac_nids[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015948 /* front, clfe, surround */
15949 0x03, 0x05, 0x06
15950};
15951
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020015952static const hda_nid_t alc861_adc_nids[1] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010015953 /* ADC0-2 */
15954 0x08,
15955};
15956
Takashi Iwaia9111322011-05-02 11:30:18 +020015957static const struct hda_input_mux alc861_capture_source = {
Kailang Yangdf694da2005-12-05 19:42:22 +010015958 .num_items = 5,
15959 .items = {
15960 { "Mic", 0x0 },
15961 { "Front Mic", 0x3 },
15962 { "Line", 0x1 },
15963 { "CD", 0x4 },
15964 { "Mixer", 0x5 },
15965 },
15966};
15967
Takashi Iwai1c209302009-07-22 15:17:45 +020015968static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15969{
15970 struct alc_spec *spec = codec->spec;
15971 hda_nid_t mix, srcs[5];
15972 int i, j, num;
15973
15974 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15975 return 0;
15976 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15977 if (num < 0)
15978 return 0;
15979 for (i = 0; i < num; i++) {
15980 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015981 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015982 if (type != AC_WID_AUD_OUT)
15983 continue;
15984 for (j = 0; j < spec->multiout.num_dacs; j++)
15985 if (spec->multiout.dac_nids[j] == srcs[i])
15986 break;
15987 if (j >= spec->multiout.num_dacs)
15988 return srcs[i];
15989 }
15990 return 0;
15991}
15992
Kailang Yangdf694da2005-12-05 19:42:22 +010015993/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015994static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015995 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015996{
Takashi Iwai1c209302009-07-22 15:17:45 +020015997 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015998 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015999 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010016000
16001 spec->multiout.dac_nids = spec->private_dac_nids;
16002 for (i = 0; i < cfg->line_outs; i++) {
16003 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020016004 dac = alc861_look_for_dac(codec, nid);
16005 if (!dac)
16006 continue;
Takashi Iwaidda14412011-05-02 11:29:30 +020016007 spec->private_dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010016008 }
Kailang Yangdf694da2005-12-05 19:42:22 +010016009 return 0;
16010}
16011
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010016012static int __alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
16013 hda_nid_t nid, int idx, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010016014{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010016015 return __add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx, idx,
Takashi Iwai1c209302009-07-22 15:17:45 +020016016 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
16017}
16018
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010016019#define alc861_create_out_sw(codec, pfx, nid, chs) \
16020 __alc861_create_out_sw(codec, pfx, nid, 0, chs)
16021
Takashi Iwai1c209302009-07-22 15:17:45 +020016022/* add playback controls from the parsed DAC table */
16023static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
16024 const struct auto_pin_cfg *cfg)
16025{
16026 struct alc_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +010016027 static const char * const chname[4] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016028 "Front", "Surround", NULL /*CLFE*/, "Side"
16029 };
Takashi Iwaice764ab2011-04-27 16:35:23 +020016030 const char *pfx = alc_get_line_out_pfx(spec, true);
Kailang Yangdf694da2005-12-05 19:42:22 +010016031 hda_nid_t nid;
Takashi Iwaice764ab2011-04-27 16:35:23 +020016032 int i, err, noutputs;
Takashi Iwai1c209302009-07-22 15:17:45 +020016033
Takashi Iwaice764ab2011-04-27 16:35:23 +020016034 noutputs = cfg->line_outs;
16035 if (spec->multi_ios > 0)
16036 noutputs += spec->multi_ios;
16037
16038 for (i = 0; i < noutputs; i++) {
Kailang Yangdf694da2005-12-05 19:42:22 +010016039 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016040 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010016041 continue;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010016042 if (!pfx && i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010016043 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020016044 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016045 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016046 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016047 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016048 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016049 return err;
16050 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010016051 const char *name = pfx;
David Henningsson5a882642011-03-23 08:35:07 +010016052 int index = i;
16053 if (!name) {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010016054 name = chname[i];
David Henningsson5a882642011-03-23 08:35:07 +010016055 index = 0;
16056 }
16057 err = __alc861_create_out_sw(codec, name, nid, index, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016058 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016059 return err;
16060 }
16061 }
16062 return 0;
16063}
16064
Takashi Iwai1c209302009-07-22 15:17:45 +020016065static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010016066{
Takashi Iwai1c209302009-07-22 15:17:45 +020016067 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016068 int err;
16069 hda_nid_t nid;
16070
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016071 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010016072 return 0;
16073
16074 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020016075 nid = alc861_look_for_dac(codec, pin);
16076 if (nid) {
16077 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
16078 if (err < 0)
16079 return err;
16080 spec->multiout.hp_nid = nid;
16081 }
Kailang Yangdf694da2005-12-05 19:42:22 +010016082 }
16083 return 0;
16084}
16085
16086/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016087static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016088 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010016089{
Takashi Iwai05f5f472009-08-25 13:10:18 +020016090 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010016091}
16092
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016093static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
16094 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020016095 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010016096{
Takashi Iwai1c209302009-07-22 15:17:45 +020016097 hda_nid_t mix, srcs[5];
16098 int i, num;
16099
Jacek Luczak564c5be2008-05-03 18:41:23 +020016100 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
16101 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020016102 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020016103 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020016104 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
16105 return;
16106 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
16107 if (num < 0)
16108 return;
16109 for (i = 0; i < num; i++) {
16110 unsigned int mute;
16111 if (srcs[i] == dac || srcs[i] == 0x15)
16112 mute = AMP_IN_UNMUTE(i);
16113 else
16114 mute = AMP_IN_MUTE(i);
16115 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16116 mute);
16117 }
Kailang Yangdf694da2005-12-05 19:42:22 +010016118}
16119
16120static void alc861_auto_init_multi_out(struct hda_codec *codec)
16121{
16122 struct alc_spec *spec = codec->spec;
16123 int i;
16124
16125 for (i = 0; i < spec->autocfg.line_outs; i++) {
16126 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016127 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010016128 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016129 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016130 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016131 }
16132}
16133
16134static void alc861_auto_init_hp_out(struct hda_codec *codec)
16135{
16136 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016137
Takashi Iwai15870f02009-10-05 08:25:13 +020016138 if (spec->autocfg.hp_outs)
16139 alc861_auto_set_output_and_unmute(codec,
16140 spec->autocfg.hp_pins[0],
16141 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020016142 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020016143 if (spec->autocfg.speaker_outs)
16144 alc861_auto_set_output_and_unmute(codec,
16145 spec->autocfg.speaker_pins[0],
16146 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020016147 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016148}
16149
16150static void alc861_auto_init_analog_input(struct hda_codec *codec)
16151{
16152 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016153 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +010016154 int i;
16155
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016156 for (i = 0; i < cfg->num_inputs; i++) {
16157 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai23f0c042009-02-26 13:03:58 +010016158 if (nid >= 0x0c && nid <= 0x11)
Takashi Iwai30ea0982010-09-16 18:47:56 +020016159 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Kailang Yangdf694da2005-12-05 19:42:22 +010016160 }
16161}
16162
16163/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016164/* return 1 if successful, 0 if the proper config is not found,
16165 * or a negative error code
16166 */
Kailang Yangdf694da2005-12-05 19:42:22 +010016167static int alc861_parse_auto_config(struct hda_codec *codec)
16168{
16169 struct alc_spec *spec = codec->spec;
16170 int err;
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020016171 static const hda_nid_t alc861_ignore[] = { 0x1d, 0 };
Kailang Yangdf694da2005-12-05 19:42:22 +010016172
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016173 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16174 alc861_ignore);
16175 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016176 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016177 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010016178 return 0; /* can't find valid BIOS pin config */
16179
Takashi Iwai1c209302009-07-22 15:17:45 +020016180 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016181 if (err < 0)
16182 return err;
Takashi Iwaice764ab2011-04-27 16:35:23 +020016183 err = alc_auto_add_multi_channel_mode(codec);
16184 if (err < 0)
16185 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016186 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016187 if (err < 0)
16188 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016189 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016190 if (err < 0)
16191 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016192 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016193 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016194 return err;
16195
16196 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16197
Takashi Iwai757899a2010-07-30 10:48:14 +020016198 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016199
Takashi Iwai603c4012008-07-30 15:01:44 +020016200 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016201 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010016202
Takashi Iwaid88897e2008-10-31 15:01:37 +010016203 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010016204
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020016205 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016206 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010016207
16208 spec->adc_nids = alc861_adc_nids;
16209 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016210 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016211
Kailang Yang6227cdc2010-02-25 08:36:52 +010016212 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016213
Kailang Yangdf694da2005-12-05 19:42:22 +010016214 return 1;
16215}
16216
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016217/* additional initialization for auto-configuration model */
16218static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010016219{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016220 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016221 alc861_auto_init_multi_out(codec);
16222 alc861_auto_init_hp_out(codec);
16223 alc861_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020016224 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016225 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016226 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016227}
16228
Takashi Iwaicb53c622007-08-10 17:21:45 +020016229#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaia9111322011-05-02 11:30:18 +020016230static const struct hda_amp_list alc861_loopbacks[] = {
Takashi Iwaicb53c622007-08-10 17:21:45 +020016231 { 0x15, HDA_INPUT, 0 },
16232 { 0x15, HDA_INPUT, 1 },
16233 { 0x15, HDA_INPUT, 2 },
16234 { 0x15, HDA_INPUT, 3 },
16235 { } /* end */
16236};
16237#endif
16238
Kailang Yangdf694da2005-12-05 19:42:22 +010016239
16240/*
16241 * configuration and preset
16242 */
Takashi Iwaiea734962011-01-17 11:29:34 +010016243static const char * const alc861_models[ALC861_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016244 [ALC861_3ST] = "3stack",
16245 [ALC660_3ST] = "3stack-660",
16246 [ALC861_3ST_DIG] = "3stack-dig",
16247 [ALC861_6ST_DIG] = "6stack-dig",
16248 [ALC861_UNIWILL_M31] = "uniwill-m31",
16249 [ALC861_TOSHIBA] = "toshiba",
16250 [ALC861_ASUS] = "asus",
16251 [ALC861_ASUS_LAPTOP] = "asus-laptop",
16252 [ALC861_AUTO] = "auto",
16253};
16254
Takashi Iwaia9111322011-05-02 11:30:18 +020016255static const struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010016256 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016257 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16258 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16259 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016260 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020016261 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010016262 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020016263 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
16264 * Any other models that need this preset?
16265 */
16266 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020016267 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
16268 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016269 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
16270 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
16271 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
16272 /* FIXME: the below seems conflict */
16273 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
16274 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
16275 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010016276 {}
16277};
16278
Takashi Iwaia9111322011-05-02 11:30:18 +020016279static const struct alc_config_preset alc861_presets[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +010016280 [ALC861_3ST] = {
16281 .mixers = { alc861_3ST_mixer },
16282 .init_verbs = { alc861_threestack_init_verbs },
16283 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16284 .dac_nids = alc861_dac_nids,
16285 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16286 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016287 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016288 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16289 .adc_nids = alc861_adc_nids,
16290 .input_mux = &alc861_capture_source,
16291 },
16292 [ALC861_3ST_DIG] = {
16293 .mixers = { alc861_base_mixer },
16294 .init_verbs = { alc861_threestack_init_verbs },
16295 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16296 .dac_nids = alc861_dac_nids,
16297 .dig_out_nid = ALC861_DIGOUT_NID,
16298 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16299 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016300 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016301 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16302 .adc_nids = alc861_adc_nids,
16303 .input_mux = &alc861_capture_source,
16304 },
16305 [ALC861_6ST_DIG] = {
16306 .mixers = { alc861_base_mixer },
16307 .init_verbs = { alc861_base_init_verbs },
16308 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16309 .dac_nids = alc861_dac_nids,
16310 .dig_out_nid = ALC861_DIGOUT_NID,
16311 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
16312 .channel_mode = alc861_8ch_modes,
16313 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16314 .adc_nids = alc861_adc_nids,
16315 .input_mux = &alc861_capture_source,
16316 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016317 [ALC660_3ST] = {
16318 .mixers = { alc861_3ST_mixer },
16319 .init_verbs = { alc861_threestack_init_verbs },
16320 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
16321 .dac_nids = alc660_dac_nids,
16322 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16323 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016324 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016325 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16326 .adc_nids = alc861_adc_nids,
16327 .input_mux = &alc861_capture_source,
16328 },
Takashi Iwai22309c32006-08-09 16:57:28 +020016329 [ALC861_UNIWILL_M31] = {
16330 .mixers = { alc861_uniwill_m31_mixer },
16331 .init_verbs = { alc861_uniwill_m31_init_verbs },
16332 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16333 .dac_nids = alc861_dac_nids,
16334 .dig_out_nid = ALC861_DIGOUT_NID,
16335 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
16336 .channel_mode = alc861_uniwill_m31_modes,
16337 .need_dac_fix = 1,
16338 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16339 .adc_nids = alc861_adc_nids,
16340 .input_mux = &alc861_capture_source,
16341 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016342 [ALC861_TOSHIBA] = {
16343 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016344 .init_verbs = { alc861_base_init_verbs,
16345 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016346 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16347 .dac_nids = alc861_dac_nids,
16348 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16349 .channel_mode = alc883_3ST_2ch_modes,
16350 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16351 .adc_nids = alc861_adc_nids,
16352 .input_mux = &alc861_capture_source,
16353 .unsol_event = alc861_toshiba_unsol_event,
16354 .init_hook = alc861_toshiba_automute,
16355 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020016356 [ALC861_ASUS] = {
16357 .mixers = { alc861_asus_mixer },
16358 .init_verbs = { alc861_asus_init_verbs },
16359 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16360 .dac_nids = alc861_dac_nids,
16361 .dig_out_nid = ALC861_DIGOUT_NID,
16362 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
16363 .channel_mode = alc861_asus_modes,
16364 .need_dac_fix = 1,
16365 .hp_nid = 0x06,
16366 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16367 .adc_nids = alc861_adc_nids,
16368 .input_mux = &alc861_capture_source,
16369 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010016370 [ALC861_ASUS_LAPTOP] = {
16371 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
16372 .init_verbs = { alc861_asus_init_verbs,
16373 alc861_asus_laptop_init_verbs },
16374 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16375 .dac_nids = alc861_dac_nids,
16376 .dig_out_nid = ALC861_DIGOUT_NID,
16377 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16378 .channel_mode = alc883_3ST_2ch_modes,
16379 .need_dac_fix = 1,
16380 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16381 .adc_nids = alc861_adc_nids,
16382 .input_mux = &alc861_capture_source,
16383 },
16384};
Kailang Yangdf694da2005-12-05 19:42:22 +010016385
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016386/* Pin config fixes */
16387enum {
16388 PINFIX_FSC_AMILO_PI1505,
16389};
16390
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016391static const struct alc_fixup alc861_fixups[] = {
16392 [PINFIX_FSC_AMILO_PI1505] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016393 .type = ALC_FIXUP_PINS,
16394 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020016395 { 0x0b, 0x0221101f }, /* HP */
16396 { 0x0f, 0x90170310 }, /* speaker */
16397 { }
16398 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016399 },
16400};
16401
Takashi Iwaia9111322011-05-02 11:30:18 +020016402static const struct snd_pci_quirk alc861_fixup_tbl[] = {
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016403 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
16404 {}
16405};
Kailang Yangdf694da2005-12-05 19:42:22 +010016406
16407static int patch_alc861(struct hda_codec *codec)
16408{
16409 struct alc_spec *spec;
16410 int board_config;
16411 int err;
16412
Robert P. J. Daydc041e02006-12-19 14:44:15 +010016413 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010016414 if (spec == NULL)
16415 return -ENOMEM;
16416
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016417 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016418
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016419 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
16420 alc861_models,
16421 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016422
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016423 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016424 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16425 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010016426 board_config = ALC861_AUTO;
16427 }
16428
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016429 if (board_config == ALC861_AUTO) {
16430 alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
16431 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
16432 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016433
Kailang Yangdf694da2005-12-05 19:42:22 +010016434 if (board_config == ALC861_AUTO) {
16435 /* automatic parse from the BIOS config */
16436 err = alc861_parse_auto_config(codec);
16437 if (err < 0) {
16438 alc_free(codec);
16439 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016440 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016441 printk(KERN_INFO
16442 "hda_codec: Cannot set up configuration "
16443 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010016444 board_config = ALC861_3ST_DIG;
16445 }
16446 }
16447
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016448 err = snd_hda_attach_beep_device(codec, 0x23);
16449 if (err < 0) {
16450 alc_free(codec);
16451 return err;
16452 }
16453
Kailang Yangdf694da2005-12-05 19:42:22 +010016454 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016455 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016456
Kailang Yangdf694da2005-12-05 19:42:22 +010016457 spec->stream_analog_playback = &alc861_pcm_analog_playback;
16458 spec->stream_analog_capture = &alc861_pcm_analog_capture;
16459
Kailang Yangdf694da2005-12-05 19:42:22 +010016460 spec->stream_digital_playback = &alc861_pcm_digital_playback;
16461 spec->stream_digital_capture = &alc861_pcm_digital_capture;
16462
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010016463 if (!spec->cap_mixer)
16464 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016465 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
16466
Takashi Iwai2134ea42008-01-10 16:53:55 +010016467 spec->vmaster_nid = 0x03;
16468
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016469 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016470
Kailang Yangdf694da2005-12-05 19:42:22 +010016471 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050016472 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016473 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016474#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050016475 spec->power_hook = alc_power_eapd;
16476#endif
16477 }
16478#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020016479 if (!spec->loopback.amplist)
16480 spec->loopback.amplist = alc861_loopbacks;
16481#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020016482
Kailang Yangdf694da2005-12-05 19:42:22 +010016483 return 0;
16484}
16485
16486/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016487 * ALC861-VD support
16488 *
16489 * Based on ALC882
16490 *
16491 * In addition, an independent DAC
16492 */
16493#define ALC861VD_DIGOUT_NID 0x06
16494
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020016495static const hda_nid_t alc861vd_dac_nids[4] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016496 /* front, surr, clfe, side surr */
16497 0x02, 0x03, 0x04, 0x05
16498};
16499
16500/* dac_nids for ALC660vd are in a different order - according to
16501 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016502 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016503 * of ALC660vd codecs, but for now there is only 3stack mixer
16504 * - and it is the same as in 861vd.
16505 * adc_nids in ALC660vd are (is) the same as in 861vd
16506 */
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020016507static const hda_nid_t alc660vd_dac_nids[3] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016508 /* front, rear, clfe, rear_surr */
16509 0x02, 0x04, 0x03
16510};
16511
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020016512static const hda_nid_t alc861vd_adc_nids[1] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016513 /* ADC0 */
16514 0x09,
16515};
16516
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020016517static const hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010016518
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016519/* input MUX */
16520/* FIXME: should be a matrix-type input source selection */
Takashi Iwaia9111322011-05-02 11:30:18 +020016521static const struct hda_input_mux alc861vd_capture_source = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016522 .num_items = 4,
16523 .items = {
16524 { "Mic", 0x0 },
16525 { "Front Mic", 0x1 },
16526 { "Line", 0x2 },
16527 { "CD", 0x4 },
16528 },
16529};
16530
Takashi Iwaia9111322011-05-02 11:30:18 +020016531static const struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010016532 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020016533 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +010016534 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +010016535 { "Internal Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020016536 },
16537};
16538
Takashi Iwaia9111322011-05-02 11:30:18 +020016539static const struct hda_input_mux alc861vd_hp_capture_source = {
Kailang Yangd1a991a2007-08-15 16:21:59 +020016540 .num_items = 2,
16541 .items = {
16542 { "Front Mic", 0x0 },
16543 { "ATAPI Mic", 0x1 },
16544 },
16545};
16546
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016547/*
16548 * 2ch mode
16549 */
Takashi Iwaia9111322011-05-02 11:30:18 +020016550static const struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016551 { 2, NULL }
16552};
16553
16554/*
16555 * 6ch mode
16556 */
Takashi Iwaia9111322011-05-02 11:30:18 +020016557static const struct hda_verb alc861vd_6stack_ch6_init[] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016558 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16559 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16560 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16561 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16562 { } /* end */
16563};
16564
16565/*
16566 * 8ch mode
16567 */
Takashi Iwaia9111322011-05-02 11:30:18 +020016568static const struct hda_verb alc861vd_6stack_ch8_init[] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016569 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16570 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16571 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16572 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16573 { } /* end */
16574};
16575
Takashi Iwaia9111322011-05-02 11:30:18 +020016576static const struct hda_channel_mode alc861vd_6stack_modes[2] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016577 { 6, alc861vd_6stack_ch6_init },
16578 { 8, alc861vd_6stack_ch8_init },
16579};
16580
Takashi Iwaia9111322011-05-02 11:30:18 +020016581static const struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016582 {
16583 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16584 .name = "Channel Mode",
16585 .info = alc_ch_mode_info,
16586 .get = alc_ch_mode_get,
16587 .put = alc_ch_mode_put,
16588 },
16589 { } /* end */
16590};
16591
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016592/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16593 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16594 */
Takashi Iwaia9111322011-05-02 11:30:18 +020016595static const struct snd_kcontrol_new alc861vd_6st_mixer[] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016596 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16597 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16598
16599 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16600 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16601
16602 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16603 HDA_OUTPUT),
16604 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16605 HDA_OUTPUT),
16606 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16607 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16608
16609 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16610 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16611
16612 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16613
David Henningsson5f99f862011-01-04 15:24:24 +010016614 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016615 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16616 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16617
David Henningsson5f99f862011-01-04 15:24:24 +010016618 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016619 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16620 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16621
16622 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16623 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16624
16625 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16626 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16627
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016628 { } /* end */
16629};
16630
Takashi Iwaia9111322011-05-02 11:30:18 +020016631static const struct snd_kcontrol_new alc861vd_3st_mixer[] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016632 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16633 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16634
16635 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16636
David Henningsson5f99f862011-01-04 15:24:24 +010016637 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016638 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16639 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16640
David Henningsson5f99f862011-01-04 15:24:24 +010016641 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016642 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16643 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16644
16645 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16646 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16647
16648 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16649 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16650
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016651 { } /* end */
16652};
16653
Takashi Iwaia9111322011-05-02 11:30:18 +020016654static const struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016655 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16656 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16657 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16658
16659 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16660
David Henningsson5f99f862011-01-04 15:24:24 +010016661 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +020016662 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16663 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16664
David Henningsson5f99f862011-01-04 15:24:24 +010016665 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +020016666 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16667 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16668
16669 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16670 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16671
16672 { } /* end */
16673};
16674
Tobin Davisb419f342008-03-07 11:57:51 +010016675/* Pin assignment: Speaker=0x14, HP = 0x15,
David Henningsson8607f7c2010-12-20 14:43:54 +010016676 * Mic=0x18, Internal Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016677 */
Takashi Iwaia9111322011-05-02 11:30:18 +020016678static const struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016679 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16680 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016681 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16682 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010016683 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson8607f7c2010-12-20 14:43:54 +010016684 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16685 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010016686 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010016687 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16688 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016689 { } /* end */
16690};
16691
Kailang Yangd1a991a2007-08-15 16:21:59 +020016692/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16693 * Front Mic=0x18, ATAPI Mic = 0x19,
16694 */
Takashi Iwaia9111322011-05-02 11:30:18 +020016695static const struct snd_kcontrol_new alc861vd_hp_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +020016696 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16697 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16698 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16699 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16700 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16701 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16702 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16703 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016704
Kailang Yangd1a991a2007-08-15 16:21:59 +020016705 { } /* end */
16706};
16707
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016708/*
16709 * generic initialization of ADC, input mixers and output mixers
16710 */
Takashi Iwaia9111322011-05-02 11:30:18 +020016711static const struct hda_verb alc861vd_volume_init_verbs[] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016712 /*
16713 * Unmute ADC0 and set the default input to mic-in
16714 */
16715 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16716 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16717
16718 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16719 * the analog-loopback mixer widget
16720 */
16721 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016722 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16723 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16724 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16725 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16726 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016727
16728 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016729 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16730 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16731 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016732 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016733
16734 /*
16735 * Set up output mixers (0x02 - 0x05)
16736 */
16737 /* set vol=0 to output mixers */
16738 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16739 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16740 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16741 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16742
16743 /* set up input amps for analog loopback */
16744 /* Amp Indices: DAC = 0, mixer = 1 */
16745 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16746 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16747 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16748 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16749 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16750 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16751 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16752 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16753
16754 { }
16755};
16756
16757/*
16758 * 3-stack pin configuration:
16759 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16760 */
Takashi Iwaia9111322011-05-02 11:30:18 +020016761static const struct hda_verb alc861vd_3stack_init_verbs[] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016762 /*
16763 * Set pin mode and muting
16764 */
16765 /* set front pin widgets 0x14 for output */
16766 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16767 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16768 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16769
16770 /* Mic (rear) pin: input vref at 80% */
16771 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16772 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16773 /* Front Mic pin: input vref at 80% */
16774 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16775 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16776 /* Line In pin: input */
16777 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16778 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16779 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16780 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16781 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16782 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16783 /* CD pin widget for input */
16784 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16785
16786 { }
16787};
16788
16789/*
16790 * 6-stack pin configuration:
16791 */
Takashi Iwaia9111322011-05-02 11:30:18 +020016792static const struct hda_verb alc861vd_6stack_init_verbs[] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016793 /*
16794 * Set pin mode and muting
16795 */
16796 /* set front pin widgets 0x14 for output */
16797 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16798 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16799 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16800
16801 /* Rear Pin: output 1 (0x0d) */
16802 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16803 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16804 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16805 /* CLFE Pin: output 2 (0x0e) */
16806 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16807 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16808 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16809 /* Side Pin: output 3 (0x0f) */
16810 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16811 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16812 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16813
16814 /* Mic (rear) pin: input vref at 80% */
16815 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16816 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16817 /* Front Mic pin: input vref at 80% */
16818 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16819 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16820 /* Line In pin: input */
16821 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16822 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16823 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16824 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16825 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16826 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16827 /* CD pin widget for input */
16828 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16829
16830 { }
16831};
16832
Takashi Iwaia9111322011-05-02 11:30:18 +020016833static const struct hda_verb alc861vd_eapd_verbs[] = {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016834 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16835 { }
16836};
16837
Takashi Iwaia9111322011-05-02 11:30:18 +020016838static const struct hda_verb alc660vd_eapd_verbs[] = {
Kailang Yangf9423e72008-05-27 12:32:25 +020016839 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16840 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16841 { }
16842};
16843
Takashi Iwaia9111322011-05-02 11:30:18 +020016844static const struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016845 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16846 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16847 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16848 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016849 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016850 {}
16851};
16852
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016853static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016854{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016855 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016856 spec->autocfg.hp_pins[0] = 0x1b;
16857 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +020016858 spec->automute = 1;
16859 spec->automute_mode = ALC_AUTOMUTE_AMP;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016860}
16861
16862static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16863{
Takashi Iwaid922b512011-04-28 12:18:53 +020016864 alc_hp_automute(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +010016865 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016866}
16867
16868static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16869 unsigned int res)
16870{
16871 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016872 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +010016873 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016874 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016875 default:
Takashi Iwaid922b512011-04-28 12:18:53 +020016876 alc_sku_unsol_event(codec, res);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016877 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016878 }
16879}
16880
Takashi Iwaia9111322011-05-02 11:30:18 +020016881static const struct hda_verb alc861vd_dallas_verbs[] = {
Kailang Yang272a5272007-05-14 11:00:38 +020016882 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16883 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16884 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16885 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16886
16887 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16888 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16889 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16890 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16891 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16892 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16893 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16894 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016895
Kailang Yang272a5272007-05-14 11:00:38 +020016896 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16897 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16898 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16899 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16900 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16901 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16902 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16903 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16904
16905 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16906 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16907 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16908 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16909 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16910 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16911 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16912 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16913
16914 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16915 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16916 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16917 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16918
16919 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016920 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016921 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16922
16923 { } /* end */
16924};
16925
16926/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016927static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016928{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016929 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016930
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016931 spec->autocfg.hp_pins[0] = 0x15;
16932 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid922b512011-04-28 12:18:53 +020016933 spec->automute = 1;
16934 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yang272a5272007-05-14 11:00:38 +020016935}
16936
Takashi Iwaicb53c622007-08-10 17:21:45 +020016937#ifdef CONFIG_SND_HDA_POWER_SAVE
16938#define alc861vd_loopbacks alc880_loopbacks
16939#endif
16940
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016941/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016942#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16943#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16944#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16945#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16946
16947/*
16948 * configuration and preset
16949 */
Takashi Iwaiea734962011-01-17 11:29:34 +010016950static const char * const alc861vd_models[ALC861VD_MODEL_LAST] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016951 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016952 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016953 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016954 [ALC861VD_3ST] = "3stack",
16955 [ALC861VD_3ST_DIG] = "3stack-digout",
16956 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016957 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016958 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016959 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016960 [ALC861VD_AUTO] = "auto",
16961};
16962
Takashi Iwaia9111322011-05-02 11:30:18 +020016963static const struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016964 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16965 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016966 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016967 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016968 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016969 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016970 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016971 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016972 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016973 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016974 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016975 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016976 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016977 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016978 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016979 {}
16980};
16981
Takashi Iwaia9111322011-05-02 11:30:18 +020016982static const struct alc_config_preset alc861vd_presets[] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016983 [ALC660VD_3ST] = {
16984 .mixers = { alc861vd_3st_mixer },
16985 .init_verbs = { alc861vd_volume_init_verbs,
16986 alc861vd_3stack_init_verbs },
16987 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16988 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016989 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16990 .channel_mode = alc861vd_3stack_2ch_modes,
16991 .input_mux = &alc861vd_capture_source,
16992 },
Mike Crash6963f842007-06-25 12:12:51 +020016993 [ALC660VD_3ST_DIG] = {
16994 .mixers = { alc861vd_3st_mixer },
16995 .init_verbs = { alc861vd_volume_init_verbs,
16996 alc861vd_3stack_init_verbs },
16997 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16998 .dac_nids = alc660vd_dac_nids,
16999 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020017000 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17001 .channel_mode = alc861vd_3stack_2ch_modes,
17002 .input_mux = &alc861vd_capture_source,
17003 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017004 [ALC861VD_3ST] = {
17005 .mixers = { alc861vd_3st_mixer },
17006 .init_verbs = { alc861vd_volume_init_verbs,
17007 alc861vd_3stack_init_verbs },
17008 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
17009 .dac_nids = alc861vd_dac_nids,
17010 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17011 .channel_mode = alc861vd_3stack_2ch_modes,
17012 .input_mux = &alc861vd_capture_source,
17013 },
17014 [ALC861VD_3ST_DIG] = {
17015 .mixers = { alc861vd_3st_mixer },
17016 .init_verbs = { alc861vd_volume_init_verbs,
17017 alc861vd_3stack_init_verbs },
17018 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
17019 .dac_nids = alc861vd_dac_nids,
17020 .dig_out_nid = ALC861VD_DIGOUT_NID,
17021 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17022 .channel_mode = alc861vd_3stack_2ch_modes,
17023 .input_mux = &alc861vd_capture_source,
17024 },
17025 [ALC861VD_6ST_DIG] = {
17026 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
17027 .init_verbs = { alc861vd_volume_init_verbs,
17028 alc861vd_6stack_init_verbs },
17029 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
17030 .dac_nids = alc861vd_dac_nids,
17031 .dig_out_nid = ALC861VD_DIGOUT_NID,
17032 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
17033 .channel_mode = alc861vd_6stack_modes,
17034 .input_mux = &alc861vd_capture_source,
17035 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020017036 [ALC861VD_LENOVO] = {
17037 .mixers = { alc861vd_lenovo_mixer },
17038 .init_verbs = { alc861vd_volume_init_verbs,
17039 alc861vd_3stack_init_verbs,
17040 alc861vd_eapd_verbs,
17041 alc861vd_lenovo_unsol_verbs },
17042 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
17043 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020017044 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17045 .channel_mode = alc861vd_3stack_2ch_modes,
17046 .input_mux = &alc861vd_capture_source,
17047 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017048 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020017049 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020017050 },
Kailang Yang272a5272007-05-14 11:00:38 +020017051 [ALC861VD_DALLAS] = {
17052 .mixers = { alc861vd_dallas_mixer },
17053 .init_verbs = { alc861vd_dallas_verbs },
17054 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
17055 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020017056 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17057 .channel_mode = alc861vd_3stack_2ch_modes,
17058 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020017059 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017060 .setup = alc861vd_dallas_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020017061 .init_hook = alc_hp_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020017062 },
17063 [ALC861VD_HP] = {
17064 .mixers = { alc861vd_hp_mixer },
17065 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
17066 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
17067 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020017068 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020017069 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17070 .channel_mode = alc861vd_3stack_2ch_modes,
17071 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaid922b512011-04-28 12:18:53 +020017072 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017073 .setup = alc861vd_dallas_setup,
Takashi Iwaid922b512011-04-28 12:18:53 +020017074 .init_hook = alc_hp_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020017075 },
Takashi Iwai13c94742008-11-05 08:06:08 +010017076 [ALC660VD_ASUS_V1S] = {
17077 .mixers = { alc861vd_lenovo_mixer },
17078 .init_verbs = { alc861vd_volume_init_verbs,
17079 alc861vd_3stack_init_verbs,
17080 alc861vd_eapd_verbs,
17081 alc861vd_lenovo_unsol_verbs },
17082 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
17083 .dac_nids = alc660vd_dac_nids,
17084 .dig_out_nid = ALC861VD_DIGOUT_NID,
17085 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17086 .channel_mode = alc861vd_3stack_2ch_modes,
17087 .input_mux = &alc861vd_capture_source,
17088 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017089 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020017090 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010017091 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017092};
17093
17094/*
17095 * BIOS auto configuration
17096 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020017097static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
17098 const struct auto_pin_cfg *cfg)
17099{
Herton Ronaldo Krzesinski71675942010-11-25 00:08:01 -020017100 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x22, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020017101}
17102
17103
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017104static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
17105 hda_nid_t nid, int pin_type, int dac_idx)
17106{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017107 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017108}
17109
17110static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
17111{
17112 struct alc_spec *spec = codec->spec;
17113 int i;
17114
17115 for (i = 0; i <= HDA_SIDE; i++) {
17116 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017117 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017118 if (nid)
17119 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017120 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017121 }
17122}
17123
17124
17125static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
17126{
17127 struct alc_spec *spec = codec->spec;
17128 hda_nid_t pin;
17129
17130 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017131 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017132 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017133 pin = spec->autocfg.speaker_pins[0];
17134 if (pin)
17135 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017136}
17137
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017138#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
17139
17140static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
17141{
17142 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020017143 struct auto_pin_cfg *cfg = &spec->autocfg;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017144 int i;
17145
Takashi Iwai66ceeb62010-08-30 13:05:52 +020017146 for (i = 0; i < cfg->num_inputs; i++) {
17147 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017148 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020017149 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +010017150 if (nid != ALC861VD_PIN_CD_NID &&
17151 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017152 snd_hda_codec_write(codec, nid, 0,
17153 AC_VERB_SET_AMP_GAIN_MUTE,
17154 AMP_OUT_MUTE);
17155 }
17156 }
17157}
17158
Takashi Iwaif511b012008-08-15 16:46:42 +020017159#define alc861vd_auto_init_input_src alc882_auto_init_input_src
17160
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017161#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
17162#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
17163
17164/* add playback controls from the parsed DAC table */
Takashi Iwai569ed342011-01-19 10:14:46 +010017165/* Based on ALC880 version. But ALC861VD has separate,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017166 * different NIDs for mute/unmute switch and volume control */
17167static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
17168 const struct auto_pin_cfg *cfg)
17169{
Takashi Iwaiea734962011-01-17 11:29:34 +010017170 static const char * const chname[4] = {
17171 "Front", "Surround", "CLFE", "Side"
17172 };
Takashi Iwaice764ab2011-04-27 16:35:23 +020017173 const char *pfx = alc_get_line_out_pfx(spec, true);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017174 hda_nid_t nid_v, nid_s;
Takashi Iwaice764ab2011-04-27 16:35:23 +020017175 int i, err, noutputs;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017176
Takashi Iwaice764ab2011-04-27 16:35:23 +020017177 noutputs = cfg->line_outs;
17178 if (spec->multi_ios > 0)
17179 noutputs += spec->multi_ios;
17180
17181 for (i = 0; i < noutputs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017182 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017183 continue;
17184 nid_v = alc861vd_idx_to_mixer_vol(
17185 alc880_dac_to_idx(
17186 spec->multiout.dac_nids[i]));
17187 nid_s = alc861vd_idx_to_mixer_switch(
17188 alc880_dac_to_idx(
17189 spec->multiout.dac_nids[i]));
17190
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017191 if (!pfx && i == 2) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017192 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017193 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17194 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017195 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
17196 HDA_OUTPUT));
17197 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017198 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017199 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17200 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017201 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
17202 HDA_OUTPUT));
17203 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017204 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017205 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17206 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017207 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
17208 HDA_INPUT));
17209 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017210 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017211 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17212 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017213 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
17214 HDA_INPUT));
17215 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017216 return err;
17217 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017218 const char *name = pfx;
David Henningsson5a882642011-03-23 08:35:07 +010017219 int index = i;
17220 if (!name) {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017221 name = chname[i];
David Henningsson5a882642011-03-23 08:35:07 +010017222 index = 0;
17223 }
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017224 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
David Henningsson5a882642011-03-23 08:35:07 +010017225 name, index,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017226 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
17227 HDA_OUTPUT));
17228 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017229 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017230 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
David Henningsson5a882642011-03-23 08:35:07 +010017231 name, index,
Kailang Yangbdd148a2007-05-08 15:19:08 +020017232 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017233 HDA_INPUT));
17234 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017235 return err;
17236 }
17237 }
17238 return 0;
17239}
17240
17241/* add playback controls for speaker and HP outputs */
17242/* Based on ALC880 version. But ALC861VD has separate,
17243 * different NIDs for mute/unmute switch and volume control */
17244static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
17245 hda_nid_t pin, const char *pfx)
17246{
17247 hda_nid_t nid_v, nid_s;
17248 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017249
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017250 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017251 return 0;
17252
17253 if (alc880_is_fixed_pin(pin)) {
17254 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17255 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017256 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017257 spec->multiout.hp_nid = nid_v;
17258 else
17259 spec->multiout.extra_out_nid[0] = nid_v;
17260 /* control HP volume/switch on the output mixer amp */
17261 nid_v = alc861vd_idx_to_mixer_vol(
17262 alc880_fixed_pin_idx(pin));
17263 nid_s = alc861vd_idx_to_mixer_switch(
17264 alc880_fixed_pin_idx(pin));
17265
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017266 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017267 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
17268 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017269 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017270 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017271 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
17272 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017273 return err;
17274 } else if (alc880_is_multi_pin(pin)) {
17275 /* set manual connection */
17276 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017277 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017278 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17279 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017280 return err;
17281 }
17282 return 0;
17283}
17284
17285/* parse the BIOS configuration and set up the alc_spec
17286 * return 1 if successful, 0 if the proper config is not found,
17287 * or a negative error code
17288 * Based on ALC880 version - had to change it to override
17289 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
17290static int alc861vd_parse_auto_config(struct hda_codec *codec)
17291{
17292 struct alc_spec *spec = codec->spec;
17293 int err;
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020017294 static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017295
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017296 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17297 alc861vd_ignore);
17298 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017299 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017300 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017301 return 0; /* can't find valid BIOS pin config */
17302
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017303 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17304 if (err < 0)
17305 return err;
Takashi Iwaice764ab2011-04-27 16:35:23 +020017306 err = alc_auto_add_multi_channel_mode(codec);
17307 if (err < 0)
17308 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017309 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
17310 if (err < 0)
17311 return err;
17312 err = alc861vd_auto_create_extra_out(spec,
17313 spec->autocfg.speaker_pins[0],
17314 "Speaker");
17315 if (err < 0)
17316 return err;
17317 err = alc861vd_auto_create_extra_out(spec,
17318 spec->autocfg.hp_pins[0],
17319 "Headphone");
17320 if (err < 0)
17321 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017322 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017323 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017324 return err;
17325
17326 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17327
Takashi Iwai757899a2010-07-30 10:48:14 +020017328 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017329
Takashi Iwai603c4012008-07-30 15:01:44 +020017330 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017331 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017332
Takashi Iwaid88897e2008-10-31 15:01:37 +010017333 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017334
17335 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017336 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017337
Takashi Iwai776e1842007-08-29 15:07:11 +020017338 err = alc_auto_add_mic_boost(codec);
17339 if (err < 0)
17340 return err;
17341
Kailang Yang6227cdc2010-02-25 08:36:52 +010017342 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017343
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017344 return 1;
17345}
17346
17347/* additional initialization for auto-configuration model */
17348static void alc861vd_auto_init(struct hda_codec *codec)
17349{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017350 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017351 alc861vd_auto_init_multi_out(codec);
17352 alc861vd_auto_init_hp_out(codec);
17353 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017354 alc861vd_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020017355 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017356 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017357 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017358}
17359
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017360enum {
17361 ALC660VD_FIX_ASUS_GPIO1
17362};
17363
17364/* reset GPIO1 */
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017365static const struct alc_fixup alc861vd_fixups[] = {
17366 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017367 .type = ALC_FIXUP_VERBS,
17368 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020017369 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
17370 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
17371 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
17372 { }
17373 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017374 },
17375};
17376
Takashi Iwaia9111322011-05-02 11:30:18 +020017377static const struct snd_pci_quirk alc861vd_fixup_tbl[] = {
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017378 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
17379 {}
17380};
17381
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017382static int patch_alc861vd(struct hda_codec *codec)
17383{
17384 struct alc_spec *spec;
17385 int err, board_config;
17386
17387 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17388 if (spec == NULL)
17389 return -ENOMEM;
17390
17391 codec->spec = spec;
17392
17393 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
17394 alc861vd_models,
17395 alc861vd_cfg_tbl);
17396
17397 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017398 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17399 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017400 board_config = ALC861VD_AUTO;
17401 }
17402
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017403 if (board_config == ALC861VD_AUTO) {
17404 alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
17405 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
17406 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017407
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017408 if (board_config == ALC861VD_AUTO) {
17409 /* automatic parse from the BIOS config */
17410 err = alc861vd_parse_auto_config(codec);
17411 if (err < 0) {
17412 alc_free(codec);
17413 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017414 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017415 printk(KERN_INFO
17416 "hda_codec: Cannot set up configuration "
17417 "from BIOS. Using base mode...\n");
17418 board_config = ALC861VD_3ST;
17419 }
17420 }
17421
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017422 err = snd_hda_attach_beep_device(codec, 0x23);
17423 if (err < 0) {
17424 alc_free(codec);
17425 return err;
17426 }
17427
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017428 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017429 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017430
Kailang Yang2f893282008-05-27 12:14:47 +020017431 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020017432 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010017433 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020017434 }
17435
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017436 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
17437 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
17438
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017439 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
17440 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
17441
Takashi Iwaidd704692009-08-11 08:45:11 +020017442 if (!spec->adc_nids) {
17443 spec->adc_nids = alc861vd_adc_nids;
17444 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
17445 }
17446 if (!spec->capsrc_nids)
17447 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017448
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017449 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010017450 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017451
Takashi Iwai2134ea42008-01-10 16:53:55 +010017452 spec->vmaster_nid = 0x02;
17453
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017454 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017455
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017456 codec->patch_ops = alc_patch_ops;
17457
17458 if (board_config == ALC861VD_AUTO)
17459 spec->init_hook = alc861vd_auto_init;
Takashi Iwai1c7161532011-04-07 10:37:16 +020017460 spec->shutup = alc_eapd_shutup;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017461#ifdef CONFIG_SND_HDA_POWER_SAVE
17462 if (!spec->loopback.amplist)
17463 spec->loopback.amplist = alc861vd_loopbacks;
17464#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017465
17466 return 0;
17467}
17468
17469/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017470 * ALC662 support
17471 *
17472 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
17473 * configuration. Each pin widget can choose any input DACs and a mixer.
17474 * Each ADC is connected from a mixer of all inputs. This makes possible
17475 * 6-channel independent captures.
17476 *
17477 * In addition, an independent DAC for the multi-playback (not used in this
17478 * driver yet).
17479 */
17480#define ALC662_DIGOUT_NID 0x06
17481#define ALC662_DIGIN_NID 0x0a
17482
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020017483static const hda_nid_t alc662_dac_nids[3] = {
Raymond Yau4bf4a6c2011-04-05 22:47:15 +080017484 /* front, rear, clfe */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017485 0x02, 0x03, 0x04
17486};
17487
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020017488static const hda_nid_t alc272_dac_nids[2] = {
Kailang Yang622e84c2009-04-21 07:39:04 +020017489 0x02, 0x03
17490};
17491
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020017492static const hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017493 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017494 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017495};
Takashi Iwaie1406342008-02-11 18:32:32 +010017496
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020017497static const hda_nid_t alc272_adc_nids[1] = {
Kailang Yang622e84c2009-04-21 07:39:04 +020017498 /* ADC1-2 */
17499 0x08,
17500};
17501
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020017502static const hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
17503static const hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020017504
Takashi Iwaie1406342008-02-11 18:32:32 +010017505
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017506/* input MUX */
17507/* FIXME: should be a matrix-type input source selection */
Takashi Iwaia9111322011-05-02 11:30:18 +020017508static const struct hda_input_mux alc662_capture_source = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017509 .num_items = 4,
17510 .items = {
17511 { "Mic", 0x0 },
17512 { "Front Mic", 0x1 },
17513 { "Line", 0x2 },
17514 { "CD", 0x4 },
17515 },
17516};
17517
Takashi Iwaia9111322011-05-02 11:30:18 +020017518static const struct hda_input_mux alc662_lenovo_101e_capture_source = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017519 .num_items = 2,
17520 .items = {
17521 { "Mic", 0x1 },
17522 { "Line", 0x2 },
17523 },
17524};
Kailang Yang291702f2007-10-16 14:28:03 +020017525
Takashi Iwaia9111322011-05-02 11:30:18 +020017526static const struct hda_input_mux alc663_capture_source = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017527 .num_items = 3,
17528 .items = {
17529 { "Mic", 0x0 },
17530 { "Front Mic", 0x1 },
17531 { "Line", 0x2 },
17532 },
17533};
17534
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017535#if 0 /* set to 1 for testing other input sources below */
Takashi Iwaia9111322011-05-02 11:30:18 +020017536static const struct hda_input_mux alc272_nc10_capture_source = {
Chris Pockelé9541ba12009-05-12 08:08:53 +020017537 .num_items = 16,
17538 .items = {
17539 { "Autoselect Mic", 0x0 },
17540 { "Internal Mic", 0x1 },
17541 { "In-0x02", 0x2 },
17542 { "In-0x03", 0x3 },
17543 { "In-0x04", 0x4 },
17544 { "In-0x05", 0x5 },
17545 { "In-0x06", 0x6 },
17546 { "In-0x07", 0x7 },
17547 { "In-0x08", 0x8 },
17548 { "In-0x09", 0x9 },
17549 { "In-0x0a", 0x0a },
17550 { "In-0x0b", 0x0b },
17551 { "In-0x0c", 0x0c },
17552 { "In-0x0d", 0x0d },
17553 { "In-0x0e", 0x0e },
17554 { "In-0x0f", 0x0f },
17555 },
17556};
17557#endif
17558
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017559/*
17560 * 2ch mode
17561 */
Takashi Iwaia9111322011-05-02 11:30:18 +020017562static const struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017563 { 2, NULL }
17564};
17565
17566/*
17567 * 2ch mode
17568 */
Takashi Iwaia9111322011-05-02 11:30:18 +020017569static const struct hda_verb alc662_3ST_ch2_init[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017570 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
17571 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17572 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
17573 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17574 { } /* end */
17575};
17576
17577/*
17578 * 6ch mode
17579 */
Takashi Iwaia9111322011-05-02 11:30:18 +020017580static const struct hda_verb alc662_3ST_ch6_init[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017581 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17582 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17583 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17584 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17585 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17586 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17587 { } /* end */
17588};
17589
Takashi Iwaia9111322011-05-02 11:30:18 +020017590static const struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017591 { 2, alc662_3ST_ch2_init },
17592 { 6, alc662_3ST_ch6_init },
17593};
17594
17595/*
17596 * 2ch mode
17597 */
Takashi Iwaia9111322011-05-02 11:30:18 +020017598static const struct hda_verb alc662_sixstack_ch6_init[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017599 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17600 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17601 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17602 { } /* end */
17603};
17604
17605/*
17606 * 6ch mode
17607 */
Takashi Iwaia9111322011-05-02 11:30:18 +020017608static const struct hda_verb alc662_sixstack_ch8_init[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017609 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17610 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17611 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17612 { } /* end */
17613};
17614
Takashi Iwaia9111322011-05-02 11:30:18 +020017615static const struct hda_channel_mode alc662_5stack_modes[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017616 { 2, alc662_sixstack_ch6_init },
17617 { 6, alc662_sixstack_ch8_init },
17618};
17619
17620/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17621 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17622 */
17623
Takashi Iwaia9111322011-05-02 11:30:18 +020017624static const struct snd_kcontrol_new alc662_base_mixer[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017625 /* output mixer control */
17626 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017627 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017628 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017629 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017630 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17631 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017632 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17633 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017634 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17635
17636 /*Input mixer control */
17637 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17638 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17639 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17640 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17641 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17642 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17643 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17644 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017645 { } /* end */
17646};
17647
Takashi Iwaia9111322011-05-02 11:30:18 +020017648static const struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017649 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017650 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017651 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17652 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17653 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17654 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17655 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17656 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17657 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17658 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17659 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017660 { } /* end */
17661};
17662
Takashi Iwaia9111322011-05-02 11:30:18 +020017663static const struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017664 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017665 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017666 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017667 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017668 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17669 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017670 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17671 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017672 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17673 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17674 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17675 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17676 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17677 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17678 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17679 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17680 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017681 { } /* end */
17682};
17683
Takashi Iwaia9111322011-05-02 11:30:18 +020017684static const struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017685 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17686 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017687 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17688 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017689 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17690 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17691 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17692 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17693 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017694 { } /* end */
17695};
17696
Takashi Iwaia9111322011-05-02 11:30:18 +020017697static const struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017698 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17699 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017700
David Henningsson5f99f862011-01-04 15:24:24 +010017701 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017702 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17703 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020017704
David Henningsson5f99f862011-01-04 15:24:24 +010017705 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017706 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17707 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020017708 { } /* end */
17709};
17710
Takashi Iwaia9111322011-05-02 11:30:18 +020017711static const struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017712 ALC262_HIPPO_MASTER_SWITCH,
17713 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017714 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017715 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17716 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017717 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17718 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17719 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17720 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17721 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17722 { } /* end */
17723};
17724
Takashi Iwaia9111322011-05-02 11:30:18 +020017725static const struct hda_bind_ctls alc663_asus_bind_master_vol = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017726 .ops = &snd_hda_bind_vol,
17727 .values = {
17728 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17729 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17730 0
17731 },
17732};
17733
Takashi Iwaia9111322011-05-02 11:30:18 +020017734static const struct hda_bind_ctls alc663_asus_one_bind_switch = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017735 .ops = &snd_hda_bind_sw,
17736 .values = {
17737 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17738 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17739 0
17740 },
17741};
17742
Takashi Iwaia9111322011-05-02 11:30:18 +020017743static const struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017744 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17745 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17746 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17747 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17748 { } /* end */
17749};
17750
Takashi Iwaia9111322011-05-02 11:30:18 +020017751static const struct hda_bind_ctls alc663_asus_tree_bind_switch = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017752 .ops = &snd_hda_bind_sw,
17753 .values = {
17754 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17755 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17756 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17757 0
17758 },
17759};
17760
Takashi Iwaia9111322011-05-02 11:30:18 +020017761static const struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017762 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17763 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17764 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17765 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17766 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17767 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17768
17769 { } /* end */
17770};
17771
Takashi Iwaia9111322011-05-02 11:30:18 +020017772static const struct hda_bind_ctls alc663_asus_four_bind_switch = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017773 .ops = &snd_hda_bind_sw,
17774 .values = {
17775 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17776 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17777 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17778 0
17779 },
17780};
17781
Takashi Iwaia9111322011-05-02 11:30:18 +020017782static const struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017783 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17784 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17785 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17786 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17787 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17788 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17789 { } /* end */
17790};
17791
Takashi Iwaia9111322011-05-02 11:30:18 +020017792static const struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017793 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17794 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017795 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17796 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17797 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17798 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17799 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17800 { } /* end */
17801};
17802
Takashi Iwaia9111322011-05-02 11:30:18 +020017803static const struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017804 .ops = &snd_hda_bind_vol,
17805 .values = {
17806 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17807 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17808 0
17809 },
17810};
17811
Takashi Iwaia9111322011-05-02 11:30:18 +020017812static const struct hda_bind_ctls alc663_asus_two_bind_switch = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017813 .ops = &snd_hda_bind_sw,
17814 .values = {
17815 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17816 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17817 0
17818 },
17819};
17820
Takashi Iwaia9111322011-05-02 11:30:18 +020017821static const struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017822 HDA_BIND_VOL("Master Playback Volume",
17823 &alc663_asus_two_bind_master_vol),
17824 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17825 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017826 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17827 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17828 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017829 { } /* end */
17830};
17831
Takashi Iwaia9111322011-05-02 11:30:18 +020017832static const struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017833 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17834 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17835 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17836 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17837 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17838 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017839 { } /* end */
17840};
17841
Takashi Iwaia9111322011-05-02 11:30:18 +020017842static const struct snd_kcontrol_new alc663_g71v_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017843 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17844 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17845 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17846 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17847 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17848
17849 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17850 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017851 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17852 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017853 { } /* end */
17854};
17855
Takashi Iwaia9111322011-05-02 11:30:18 +020017856static const struct snd_kcontrol_new alc663_g50v_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017857 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17858 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17859 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17860
17861 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17862 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017863 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17864 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017865 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17866 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17867 { } /* end */
17868};
17869
Takashi Iwaia9111322011-05-02 11:30:18 +020017870static const struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
Kailang Yangebb83ee2009-12-17 12:23:00 +010017871 .ops = &snd_hda_bind_sw,
17872 .values = {
17873 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17874 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17875 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17876 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17877 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17878 0
17879 },
17880};
17881
Takashi Iwaia9111322011-05-02 11:30:18 +020017882static const struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
Kailang Yangebb83ee2009-12-17 12:23:00 +010017883 .ops = &snd_hda_bind_sw,
17884 .values = {
17885 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17886 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17887 0
17888 },
17889};
17890
Takashi Iwaia9111322011-05-02 11:30:18 +020017891static const struct snd_kcontrol_new alc663_mode7_mixer[] = {
Kailang Yangebb83ee2009-12-17 12:23:00 +010017892 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17893 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17894 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17895 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17896 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17897 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17898 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17899 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17900 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17901 { } /* end */
17902};
17903
Takashi Iwaia9111322011-05-02 11:30:18 +020017904static const struct snd_kcontrol_new alc663_mode8_mixer[] = {
Kailang Yangebb83ee2009-12-17 12:23:00 +010017905 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17906 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17907 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17908 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17909 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17910 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17911 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17912 { } /* end */
17913};
17914
17915
Takashi Iwaia9111322011-05-02 11:30:18 +020017916static const struct snd_kcontrol_new alc662_chmode_mixer[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017917 {
17918 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17919 .name = "Channel Mode",
17920 .info = alc_ch_mode_info,
17921 .get = alc_ch_mode_get,
17922 .put = alc_ch_mode_put,
17923 },
17924 { } /* end */
17925};
17926
Takashi Iwaia9111322011-05-02 11:30:18 +020017927static const struct hda_verb alc662_init_verbs[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017928 /* ADC: mute amp left and right */
17929 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17930 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017931
Kailang Yangb60dd392007-09-20 12:50:29 +020017932 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17933 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17934 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17935 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17936 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17937 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017938
17939 /* Front Pin: output 0 (0x0c) */
17940 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17941 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17942
17943 /* Rear Pin: output 1 (0x0d) */
17944 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17945 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17946
17947 /* CLFE Pin: output 2 (0x0e) */
17948 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17949 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17950
17951 /* Mic (rear) pin: input vref at 80% */
17952 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17953 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17954 /* Front Mic pin: input vref at 80% */
17955 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17956 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17957 /* Line In pin: input */
17958 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17959 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17960 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17961 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17962 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17963 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17964 /* CD pin widget for input */
17965 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17966
17967 /* FIXME: use matrix-type input source selection */
17968 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17969 /* Input mixer */
17970 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017971 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017972
Takashi Iwaia7f23712011-04-07 10:24:23 +020017973 { }
17974};
17975
Takashi Iwaia9111322011-05-02 11:30:18 +020017976static const struct hda_verb alc662_eapd_init_verbs[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017977 /* always trun on EAPD */
17978 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17979 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017980 { }
17981};
17982
Takashi Iwaia9111322011-05-02 11:30:18 +020017983static const struct hda_verb alc662_sue_init_verbs[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017984 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17985 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017986 {}
17987};
17988
Takashi Iwaia9111322011-05-02 11:30:18 +020017989static const struct hda_verb alc662_eeepc_sue_init_verbs[] = {
Kailang Yang291702f2007-10-16 14:28:03 +020017990 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17991 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17992 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017993};
17994
Kailang Yang8c427222008-01-10 13:03:59 +010017995/* Set Unsolicited Event*/
Takashi Iwaia9111322011-05-02 11:30:18 +020017996static const struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
Kailang Yang8c427222008-01-10 13:03:59 +010017997 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17998 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17999 {}
18000};
18001
Takashi Iwaia9111322011-05-02 11:30:18 +020018002static const struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020018003 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18004 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020018005 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18006 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020018007 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18008 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18009 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020018010 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18011 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18012 {}
18013};
18014
Takashi Iwaia9111322011-05-02 11:30:18 +020018015static const struct hda_verb alc663_21jd_amic_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020018016 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18017 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18018 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18019 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18020 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18021 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18022 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18023 {}
18024};
18025
Takashi Iwaia9111322011-05-02 11:30:18 +020018026static const struct hda_verb alc662_1bjd_amic_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020018027 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18028 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18029 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18030 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
18031 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18032 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18033 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18034 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18035 {}
18036};
18037
Takashi Iwaia9111322011-05-02 11:30:18 +020018038static const struct hda_verb alc663_15jd_amic_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020018039 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18040 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18041 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18042 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18043 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18044 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18045 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18046 {}
18047};
18048
Takashi Iwaia9111322011-05-02 11:30:18 +020018049static const struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020018050 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18051 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18052 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18053 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
18054 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18055 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18056 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
18057 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18058 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18059 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18060 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18061 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18062 {}
18063};
18064
Takashi Iwaia9111322011-05-02 11:30:18 +020018065static const struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020018066 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18067 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18068 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18069 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18070 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18071 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18072 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18073 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18074 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18075 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18076 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18077 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18078 {}
18079};
18080
Takashi Iwaia9111322011-05-02 11:30:18 +020018081static const struct hda_verb alc663_g71v_init_verbs[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020018082 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18083 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
18084 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
18085
18086 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18087 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18088 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
18089
18090 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
18091 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
18092 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
18093 {}
18094};
18095
Takashi Iwaia9111322011-05-02 11:30:18 +020018096static const struct hda_verb alc663_g50v_init_verbs[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020018097 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18098 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18099 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
18100
18101 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18102 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18103 {}
18104};
18105
Takashi Iwaia9111322011-05-02 11:30:18 +020018106static const struct hda_verb alc662_ecs_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020018107 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
18108 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18109 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18110 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18111 {}
18112};
18113
Takashi Iwaia9111322011-05-02 11:30:18 +020018114static const struct hda_verb alc272_dell_zm1_init_verbs[] = {
Kailang Yang622e84c2009-04-21 07:39:04 +020018115 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18116 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18117 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18118 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18119 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18120 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18121 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18122 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18123 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18124 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18125 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18126 {}
18127};
18128
Takashi Iwaia9111322011-05-02 11:30:18 +020018129static const struct hda_verb alc272_dell_init_verbs[] = {
Kailang Yang622e84c2009-04-21 07:39:04 +020018130 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18131 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18132 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18133 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18134 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18135 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18136 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18137 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18138 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18139 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18140 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18141 {}
18142};
18143
Takashi Iwaia9111322011-05-02 11:30:18 +020018144static const struct hda_verb alc663_mode7_init_verbs[] = {
Kailang Yangebb83ee2009-12-17 12:23:00 +010018145 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18146 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18147 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18148 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18149 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18150 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18151 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
18152 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18153 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18154 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18155 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18156 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18157 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18158 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18159 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18160 {}
18161};
18162
Takashi Iwaia9111322011-05-02 11:30:18 +020018163static const struct hda_verb alc663_mode8_init_verbs[] = {
Kailang Yangebb83ee2009-12-17 12:23:00 +010018164 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18165 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18166 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18167 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
18168 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18169 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18170 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18171 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18172 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18173 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18174 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18175 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18176 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18177 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18178 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18179 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18180 {}
18181};
18182
Takashi Iwaia9111322011-05-02 11:30:18 +020018183static const struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020018184 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
18185 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
18186 { } /* end */
18187};
18188
Takashi Iwaia9111322011-05-02 11:30:18 +020018189static const struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
Kailang Yang622e84c2009-04-21 07:39:04 +020018190 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
18191 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
18192 { } /* end */
18193};
18194
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020018195static void alc662_lenovo_101e_setup(struct hda_codec *codec)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018196{
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020018197 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018198
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020018199 spec->autocfg.hp_pins[0] = 0x1b;
18200 spec->autocfg.line_out_pins[0] = 0x14;
18201 spec->autocfg.speaker_pins[0] = 0x15;
18202 spec->automute = 1;
18203 spec->detect_line = 1;
18204 spec->automute_lines = 1;
18205 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018206}
18207
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018208static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020018209{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018210 struct alc_spec *spec = codec->spec;
18211
18212 alc262_hippo1_setup(codec);
18213 spec->ext_mic.pin = 0x18;
18214 spec->ext_mic.mux_idx = 0;
18215 spec->int_mic.pin = 0x19;
18216 spec->int_mic.mux_idx = 1;
18217 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020018218}
18219
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018220static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010018221{
Takashi Iwai42171c12009-05-08 14:11:43 +020018222 struct alc_spec *spec = codec->spec;
18223
18224 spec->autocfg.hp_pins[0] = 0x14;
18225 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaie9427962011-04-28 15:46:07 +020018226 spec->automute = 1;
18227 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yang8c427222008-01-10 13:03:59 +010018228}
18229
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018230static void alc663_m51va_setup(struct hda_codec *codec)
18231{
18232 struct alc_spec *spec = codec->spec;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018233 spec->autocfg.hp_pins[0] = 0x21;
18234 spec->autocfg.speaker_pins[0] = 0x14;
18235 spec->automute_mixer_nid[0] = 0x0c;
18236 spec->automute = 1;
18237 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018238 spec->ext_mic.pin = 0x18;
18239 spec->ext_mic.mux_idx = 0;
18240 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018241 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018242 spec->auto_mic = 1;
18243}
18244
Kailang Yangf1d4e282008-08-26 14:03:29 +020018245/* ***************** Mode1 ******************************/
Kailang Yangebb83ee2009-12-17 12:23:00 +010018246static void alc663_mode1_setup(struct hda_codec *codec)
18247{
18248 struct alc_spec *spec = codec->spec;
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018249 spec->autocfg.hp_pins[0] = 0x21;
18250 spec->autocfg.speaker_pins[0] = 0x14;
18251 spec->automute_mixer_nid[0] = 0x0c;
18252 spec->automute = 1;
18253 spec->automute_mode = ALC_AUTOMUTE_MIXER;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018254 spec->ext_mic.pin = 0x18;
18255 spec->ext_mic.mux_idx = 0;
18256 spec->int_mic.pin = 0x19;
18257 spec->int_mic.mux_idx = 1;
18258 spec->auto_mic = 1;
18259}
18260
Kailang Yangf1d4e282008-08-26 14:03:29 +020018261/* ***************** Mode2 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018262static void alc662_mode2_setup(struct hda_codec *codec)
Kailang Yangf1d4e282008-08-26 14:03:29 +020018263{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018264 struct alc_spec *spec = codec->spec;
18265 spec->autocfg.hp_pins[0] = 0x1b;
18266 spec->autocfg.speaker_pins[0] = 0x14;
18267 spec->automute = 1;
18268 spec->automute_mode = ALC_AUTOMUTE_PIN;
18269 spec->ext_mic.pin = 0x18;
18270 spec->ext_mic.mux_idx = 0;
18271 spec->int_mic.pin = 0x19;
18272 spec->int_mic.mux_idx = 1;
18273 spec->auto_mic = 1;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018274}
18275
Kailang Yangf1d4e282008-08-26 14:03:29 +020018276/* ***************** Mode3 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018277static void alc663_mode3_setup(struct hda_codec *codec)
Kailang Yangf1d4e282008-08-26 14:03:29 +020018278{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018279 struct alc_spec *spec = codec->spec;
18280 spec->autocfg.hp_pins[0] = 0x21;
18281 spec->autocfg.hp_pins[0] = 0x15;
18282 spec->autocfg.speaker_pins[0] = 0x14;
18283 spec->automute = 1;
18284 spec->automute_mode = ALC_AUTOMUTE_PIN;
18285 spec->ext_mic.pin = 0x18;
18286 spec->ext_mic.mux_idx = 0;
18287 spec->int_mic.pin = 0x19;
18288 spec->int_mic.mux_idx = 1;
18289 spec->auto_mic = 1;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018290}
18291
Kailang Yangf1d4e282008-08-26 14:03:29 +020018292/* ***************** Mode4 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018293static void alc663_mode4_setup(struct hda_codec *codec)
Kailang Yangf1d4e282008-08-26 14:03:29 +020018294{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018295 struct alc_spec *spec = codec->spec;
18296 spec->autocfg.hp_pins[0] = 0x21;
18297 spec->autocfg.speaker_pins[0] = 0x14;
18298 spec->autocfg.speaker_pins[1] = 0x16;
18299 spec->automute_mixer_nid[0] = 0x0c;
18300 spec->automute_mixer_nid[1] = 0x0e;
18301 spec->automute = 1;
18302 spec->automute_mode = ALC_AUTOMUTE_MIXER;
18303 spec->ext_mic.pin = 0x18;
18304 spec->ext_mic.mux_idx = 0;
18305 spec->int_mic.pin = 0x19;
18306 spec->int_mic.mux_idx = 1;
18307 spec->auto_mic = 1;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018308}
18309
Kailang Yangf1d4e282008-08-26 14:03:29 +020018310/* ***************** Mode5 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018311static void alc663_mode5_setup(struct hda_codec *codec)
Kailang Yangf1d4e282008-08-26 14:03:29 +020018312{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018313 struct alc_spec *spec = codec->spec;
18314 spec->autocfg.hp_pins[0] = 0x15;
18315 spec->autocfg.speaker_pins[0] = 0x14;
18316 spec->autocfg.speaker_pins[1] = 0x16;
18317 spec->automute_mixer_nid[0] = 0x0c;
18318 spec->automute_mixer_nid[1] = 0x0e;
18319 spec->automute = 1;
18320 spec->automute_mode = ALC_AUTOMUTE_MIXER;
18321 spec->ext_mic.pin = 0x18;
18322 spec->ext_mic.mux_idx = 0;
18323 spec->int_mic.pin = 0x19;
18324 spec->int_mic.mux_idx = 1;
18325 spec->auto_mic = 1;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018326}
18327
Kailang Yangf1d4e282008-08-26 14:03:29 +020018328/* ***************** Mode6 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018329static void alc663_mode6_setup(struct hda_codec *codec)
Kailang Yangf1d4e282008-08-26 14:03:29 +020018330{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018331 struct alc_spec *spec = codec->spec;
18332 spec->autocfg.hp_pins[0] = 0x1b;
18333 spec->autocfg.hp_pins[0] = 0x15;
18334 spec->autocfg.speaker_pins[0] = 0x14;
18335 spec->automute_mixer_nid[0] = 0x0c;
18336 spec->automute = 1;
18337 spec->automute_mode = ALC_AUTOMUTE_MIXER;
18338 spec->ext_mic.pin = 0x18;
18339 spec->ext_mic.mux_idx = 0;
18340 spec->int_mic.pin = 0x19;
18341 spec->int_mic.mux_idx = 1;
18342 spec->auto_mic = 1;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018343}
18344
Kailang Yangebb83ee2009-12-17 12:23:00 +010018345/* ***************** Mode7 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018346static void alc663_mode7_setup(struct hda_codec *codec)
Kailang Yangebb83ee2009-12-17 12:23:00 +010018347{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018348 struct alc_spec *spec = codec->spec;
18349 spec->autocfg.hp_pins[0] = 0x1b;
18350 spec->autocfg.hp_pins[0] = 0x21;
18351 spec->autocfg.speaker_pins[0] = 0x14;
18352 spec->autocfg.speaker_pins[0] = 0x17;
18353 spec->automute = 1;
18354 spec->automute_mode = ALC_AUTOMUTE_PIN;
18355 spec->ext_mic.pin = 0x18;
18356 spec->ext_mic.mux_idx = 0;
18357 spec->int_mic.pin = 0x19;
18358 spec->int_mic.mux_idx = 1;
18359 spec->auto_mic = 1;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018360}
18361
18362/* ***************** Mode8 ******************************/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018363static void alc663_mode8_setup(struct hda_codec *codec)
Kailang Yangebb83ee2009-12-17 12:23:00 +010018364{
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018365 struct alc_spec *spec = codec->spec;
18366 spec->autocfg.hp_pins[0] = 0x21;
18367 spec->autocfg.hp_pins[1] = 0x15;
18368 spec->autocfg.speaker_pins[0] = 0x14;
18369 spec->autocfg.speaker_pins[0] = 0x17;
18370 spec->automute = 1;
18371 spec->automute_mode = ALC_AUTOMUTE_PIN;
18372 spec->ext_mic.pin = 0x18;
18373 spec->ext_mic.mux_idx = 0;
18374 spec->int_mic.pin = 0x12;
18375 spec->int_mic.mux_idx = 9;
18376 spec->auto_mic = 1;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018377}
18378
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020018379static void alc663_g71v_setup(struct hda_codec *codec)
Kailang Yang6dda9f42008-05-27 12:05:31 +020018380{
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020018381 struct alc_spec *spec = codec->spec;
18382 spec->autocfg.hp_pins[0] = 0x21;
18383 spec->autocfg.line_out_pins[0] = 0x15;
18384 spec->autocfg.speaker_pins[0] = 0x14;
18385 spec->automute = 1;
18386 spec->automute_mode = ALC_AUTOMUTE_AMP;
18387 spec->detect_line = 1;
18388 spec->automute_lines = 1;
18389 spec->ext_mic.pin = 0x18;
18390 spec->ext_mic.mux_idx = 0;
18391 spec->int_mic.pin = 0x12;
18392 spec->int_mic.mux_idx = 9;
18393 spec->auto_mic = 1;
Kailang Yang6dda9f42008-05-27 12:05:31 +020018394}
18395
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018396#define alc663_g50v_setup alc663_m51va_setup
18397
Takashi Iwaia9111322011-05-02 11:30:18 +020018398static const struct snd_kcontrol_new alc662_ecs_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020018399 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020018400 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018401
David Henningsson5f99f862011-01-04 15:24:24 +010018402 HDA_CODEC_VOLUME("Mic/LineIn Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010018403 HDA_CODEC_VOLUME("Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
18404 HDA_CODEC_MUTE("Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020018405
David Henningsson5f99f862011-01-04 15:24:24 +010018406 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010018407 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18408 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020018409 { } /* end */
18410};
18411
Takashi Iwaia9111322011-05-02 11:30:18 +020018412static const struct snd_kcontrol_new alc272_nc10_mixer[] = {
Chris Pockelé9541ba12009-05-12 08:08:53 +020018413 /* Master Playback automatically created from Speaker and Headphone */
18414 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18415 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18416 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
18417 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
18418
David Henningsson8607f7c2010-12-20 14:43:54 +010018419 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
18420 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010018421 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018422
David Henningsson28c4edb2010-12-20 14:24:29 +010018423 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18424 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010018425 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018426 { } /* end */
18427};
18428
Takashi Iwaicb53c622007-08-10 17:21:45 +020018429#ifdef CONFIG_SND_HDA_POWER_SAVE
18430#define alc662_loopbacks alc880_loopbacks
18431#endif
18432
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018433
Sasha Alexandrdef319f2009-06-16 16:00:15 -040018434/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018435#define alc662_pcm_analog_playback alc880_pcm_analog_playback
18436#define alc662_pcm_analog_capture alc880_pcm_analog_capture
18437#define alc662_pcm_digital_playback alc880_pcm_digital_playback
18438#define alc662_pcm_digital_capture alc880_pcm_digital_capture
18439
18440/*
18441 * configuration and preset
18442 */
Takashi Iwaiea734962011-01-17 11:29:34 +010018443static const char * const alc662_models[ALC662_MODEL_LAST] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018444 [ALC662_3ST_2ch_DIG] = "3stack-dig",
18445 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
18446 [ALC662_3ST_6ch] = "3stack-6ch",
Raymond Yau4bf4a6c2011-04-05 22:47:15 +080018447 [ALC662_5ST_DIG] = "5stack-dig",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018448 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020018449 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010018450 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018451 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020018452 [ALC663_ASUS_M51VA] = "m51va",
18453 [ALC663_ASUS_G71V] = "g71v",
18454 [ALC663_ASUS_H13] = "h13",
18455 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018456 [ALC663_ASUS_MODE1] = "asus-mode1",
18457 [ALC662_ASUS_MODE2] = "asus-mode2",
18458 [ALC663_ASUS_MODE3] = "asus-mode3",
18459 [ALC663_ASUS_MODE4] = "asus-mode4",
18460 [ALC663_ASUS_MODE5] = "asus-mode5",
18461 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010018462 [ALC663_ASUS_MODE7] = "asus-mode7",
18463 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020018464 [ALC272_DELL] = "dell",
18465 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020018466 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018467 [ALC662_AUTO] = "auto",
18468};
18469
Takashi Iwaia9111322011-05-02 11:30:18 +020018470static const struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010018471 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020018472 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18473 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018474 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
18475 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010018476 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018477 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
18478 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
18479 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
18480 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018481 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
18482 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018483 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018484 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
18485 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
18486 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
18487 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
18488 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018489 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018490 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
18491 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018492 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
18493 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
18494 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
18495 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018496 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018497 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
18498 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
18499 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018500 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
18501 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
18502 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
18503 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018504 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018505 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
18506 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020018507 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018508 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
18509 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
18510 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018511 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010018512 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018513 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
18514 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018515 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
18516 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
18517 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018518 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018519 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
18520 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018521 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018522 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018523 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018524 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18525 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18526 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018527 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018528 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18529 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018530 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018531 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018532 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018533 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018534 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18535 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018536 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018537 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Takashi Iwaiebb47242011-05-02 10:37:29 +020018538 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
18539 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018540 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018541 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018542 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018543 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018544 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018545 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018546 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18547 ALC663_ASUS_H13),
Anisse Astier965b76d2011-02-10 13:14:44 +010018548 SND_PCI_QUIRK(0x1991, 0x5628, "Ordissimo EVE", ALC662_LENOVO_101E),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018549 {}
18550};
18551
Takashi Iwaia9111322011-05-02 11:30:18 +020018552static const struct alc_config_preset alc662_presets[] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018553 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018554 .mixers = { alc662_3ST_2ch_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018555 .init_verbs = { alc662_init_verbs, alc662_eapd_init_verbs },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018556 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18557 .dac_nids = alc662_dac_nids,
18558 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018559 .dig_in_nid = ALC662_DIGIN_NID,
18560 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18561 .channel_mode = alc662_3ST_2ch_modes,
18562 .input_mux = &alc662_capture_source,
18563 },
18564 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018565 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018566 .init_verbs = { alc662_init_verbs, alc662_eapd_init_verbs },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018567 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18568 .dac_nids = alc662_dac_nids,
18569 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018570 .dig_in_nid = ALC662_DIGIN_NID,
18571 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18572 .channel_mode = alc662_3ST_6ch_modes,
18573 .need_dac_fix = 1,
18574 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018575 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018576 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018577 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018578 .init_verbs = { alc662_init_verbs, alc662_eapd_init_verbs },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018579 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18580 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018581 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18582 .channel_mode = alc662_3ST_6ch_modes,
18583 .need_dac_fix = 1,
18584 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018585 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018586 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018587 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018588 .init_verbs = { alc662_init_verbs, alc662_eapd_init_verbs },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018589 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18590 .dac_nids = alc662_dac_nids,
18591 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018592 .dig_in_nid = ALC662_DIGIN_NID,
18593 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18594 .channel_mode = alc662_5stack_modes,
18595 .input_mux = &alc662_capture_source,
18596 },
18597 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018598 .mixers = { alc662_lenovo_101e_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018599 .init_verbs = { alc662_init_verbs,
18600 alc662_eapd_init_verbs,
18601 alc662_sue_init_verbs },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018602 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18603 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018604 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18605 .channel_mode = alc662_3ST_2ch_modes,
18606 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020018607 .unsol_event = alc_sku_unsol_event,
18608 .setup = alc662_lenovo_101e_setup,
18609 .init_hook = alc_inithook,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018610 },
Kailang Yang291702f2007-10-16 14:28:03 +020018611 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018612 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018613 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018614 alc662_eapd_init_verbs,
Kailang Yang291702f2007-10-16 14:28:03 +020018615 alc662_eeepc_sue_init_verbs },
18616 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18617 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018618 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18619 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwaie9427962011-04-28 15:46:07 +020018620 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018621 .setup = alc662_eeepc_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020018622 .init_hook = alc_inithook,
Kailang Yang291702f2007-10-16 14:28:03 +020018623 },
Kailang Yang8c427222008-01-10 13:03:59 +010018624 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018625 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018626 alc662_chmode_mixer },
18627 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018628 alc662_eapd_init_verbs,
Kailang Yang8c427222008-01-10 13:03:59 +010018629 alc662_eeepc_ep20_sue_init_verbs },
18630 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18631 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018632 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18633 .channel_mode = alc662_3ST_6ch_modes,
18634 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwaie9427962011-04-28 15:46:07 +020018635 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018636 .setup = alc662_eeepc_ep20_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020018637 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010018638 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018639 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018640 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018641 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018642 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018643 alc662_ecs_init_verbs },
18644 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18645 .dac_nids = alc662_dac_nids,
18646 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18647 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwaie9427962011-04-28 15:46:07 +020018648 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018649 .setup = alc662_eeepc_setup,
Takashi Iwaie9427962011-04-28 15:46:07 +020018650 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018651 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018652 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018653 .mixers = { alc663_m51va_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018654 .init_verbs = { alc662_init_verbs,
18655 alc662_eapd_init_verbs,
18656 alc663_m51va_init_verbs },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018657 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18658 .dac_nids = alc662_dac_nids,
18659 .dig_out_nid = ALC662_DIGOUT_NID,
18660 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18661 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018662 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018663 .setup = alc663_m51va_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018664 .init_hook = alc_inithook,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018665 },
18666 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018667 .mixers = { alc663_g71v_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018668 .init_verbs = { alc662_init_verbs,
18669 alc662_eapd_init_verbs,
18670 alc663_g71v_init_verbs },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018671 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18672 .dac_nids = alc662_dac_nids,
18673 .dig_out_nid = ALC662_DIGOUT_NID,
18674 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18675 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020018676 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018677 .setup = alc663_g71v_setup,
Takashi Iwaie6a5e1b2011-04-28 14:41:52 +020018678 .init_hook = alc_inithook,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018679 },
18680 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018681 .mixers = { alc663_m51va_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018682 .init_verbs = { alc662_init_verbs,
18683 alc662_eapd_init_verbs,
18684 alc663_m51va_init_verbs },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018685 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18686 .dac_nids = alc662_dac_nids,
18687 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18688 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018689 .setup = alc663_m51va_setup,
18690 .unsol_event = alc_sku_unsol_event,
18691 .init_hook = alc_inithook,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018692 },
18693 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018694 .mixers = { alc663_g50v_mixer },
Takashi Iwaia7f23712011-04-07 10:24:23 +020018695 .init_verbs = { alc662_init_verbs,
18696 alc662_eapd_init_verbs,
18697 alc663_g50v_init_verbs },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018698 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18699 .dac_nids = alc662_dac_nids,
18700 .dig_out_nid = ALC662_DIGOUT_NID,
18701 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18702 .channel_mode = alc662_3ST_6ch_modes,
18703 .input_mux = &alc663_capture_source,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018704 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018705 .setup = alc663_g50v_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018706 .init_hook = alc_inithook,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018707 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018708 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018709 .mixers = { alc663_m51va_mixer },
18710 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018711 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018712 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018713 alc663_21jd_amic_init_verbs },
18714 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18715 .hp_nid = 0x03,
18716 .dac_nids = alc662_dac_nids,
18717 .dig_out_nid = ALC662_DIGOUT_NID,
18718 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18719 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018720 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018721 .setup = alc663_mode1_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018722 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018723 },
18724 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018725 .mixers = { alc662_1bjd_mixer },
18726 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018727 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018728 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018729 alc662_1bjd_amic_init_verbs },
18730 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18731 .dac_nids = alc662_dac_nids,
18732 .dig_out_nid = ALC662_DIGOUT_NID,
18733 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18734 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018735 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018736 .setup = alc662_mode2_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018737 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018738 },
18739 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018740 .mixers = { alc663_two_hp_m1_mixer },
18741 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018742 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018743 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018744 alc663_two_hp_amic_m1_init_verbs },
18745 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18746 .hp_nid = 0x03,
18747 .dac_nids = alc662_dac_nids,
18748 .dig_out_nid = ALC662_DIGOUT_NID,
18749 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18750 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018751 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018752 .setup = alc663_mode3_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018753 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018754 },
18755 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018756 .mixers = { alc663_asus_21jd_clfe_mixer },
18757 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018758 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018759 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018760 alc663_21jd_amic_init_verbs},
18761 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18762 .hp_nid = 0x03,
18763 .dac_nids = alc662_dac_nids,
18764 .dig_out_nid = ALC662_DIGOUT_NID,
18765 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18766 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018767 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018768 .setup = alc663_mode4_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018769 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018770 },
18771 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018772 .mixers = { alc663_asus_15jd_clfe_mixer },
18773 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018774 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018775 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018776 alc663_15jd_amic_init_verbs },
18777 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18778 .hp_nid = 0x03,
18779 .dac_nids = alc662_dac_nids,
18780 .dig_out_nid = ALC662_DIGOUT_NID,
18781 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18782 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018783 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018784 .setup = alc663_mode5_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018785 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018786 },
18787 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018788 .mixers = { alc663_two_hp_m2_mixer },
18789 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018790 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018791 alc662_eapd_init_verbs,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018792 alc663_two_hp_amic_m2_init_verbs },
18793 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18794 .hp_nid = 0x03,
18795 .dac_nids = alc662_dac_nids,
18796 .dig_out_nid = ALC662_DIGOUT_NID,
18797 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18798 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018799 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018800 .setup = alc663_mode6_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018801 .init_hook = alc_inithook,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018802 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018803 [ALC663_ASUS_MODE7] = {
18804 .mixers = { alc663_mode7_mixer },
18805 .cap_mixer = alc662_auto_capture_mixer,
18806 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018807 alc662_eapd_init_verbs,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018808 alc663_mode7_init_verbs },
18809 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18810 .hp_nid = 0x03,
18811 .dac_nids = alc662_dac_nids,
18812 .dig_out_nid = ALC662_DIGOUT_NID,
18813 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18814 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018815 .unsol_event = alc_sku_unsol_event,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018816 .setup = alc663_mode7_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018817 .init_hook = alc_inithook,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018818 },
18819 [ALC663_ASUS_MODE8] = {
18820 .mixers = { alc663_mode8_mixer },
18821 .cap_mixer = alc662_auto_capture_mixer,
18822 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018823 alc662_eapd_init_verbs,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018824 alc663_mode8_init_verbs },
18825 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18826 .hp_nid = 0x03,
18827 .dac_nids = alc662_dac_nids,
18828 .dig_out_nid = ALC662_DIGOUT_NID,
18829 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18830 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018831 .unsol_event = alc_sku_unsol_event,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018832 .setup = alc663_mode8_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018833 .init_hook = alc_inithook,
Kailang Yangebb83ee2009-12-17 12:23:00 +010018834 },
Kailang Yang622e84c2009-04-21 07:39:04 +020018835 [ALC272_DELL] = {
18836 .mixers = { alc663_m51va_mixer },
18837 .cap_mixer = alc272_auto_capture_mixer,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018838 .init_verbs = { alc662_init_verbs,
18839 alc662_eapd_init_verbs,
18840 alc272_dell_init_verbs },
Kailang Yang622e84c2009-04-21 07:39:04 +020018841 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
Takashi Iwai1bc7cf92011-04-06 09:42:29 +020018842 .dac_nids = alc272_dac_nids,
Kailang Yang622e84c2009-04-21 07:39:04 +020018843 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18844 .adc_nids = alc272_adc_nids,
18845 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
18846 .capsrc_nids = alc272_capsrc_nids,
18847 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018848 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018849 .setup = alc663_m51va_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018850 .init_hook = alc_inithook,
Kailang Yang622e84c2009-04-21 07:39:04 +020018851 },
18852 [ALC272_DELL_ZM1] = {
18853 .mixers = { alc663_m51va_mixer },
18854 .cap_mixer = alc662_auto_capture_mixer,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018855 .init_verbs = { alc662_init_verbs,
18856 alc662_eapd_init_verbs,
18857 alc272_dell_zm1_init_verbs },
Kailang Yang622e84c2009-04-21 07:39:04 +020018858 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
Takashi Iwai1bc7cf92011-04-06 09:42:29 +020018859 .dac_nids = alc272_dac_nids,
Kailang Yang622e84c2009-04-21 07:39:04 +020018860 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18861 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018862 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020018863 .capsrc_nids = alc662_capsrc_nids,
18864 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018865 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018866 .setup = alc663_m51va_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018867 .init_hook = alc_inithook,
Kailang Yang622e84c2009-04-21 07:39:04 +020018868 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020018869 [ALC272_SAMSUNG_NC10] = {
18870 .mixers = { alc272_nc10_mixer },
18871 .init_verbs = { alc662_init_verbs,
Takashi Iwaia7f23712011-04-07 10:24:23 +020018872 alc662_eapd_init_verbs,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018873 alc663_21jd_amic_init_verbs },
18874 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18875 .dac_nids = alc272_dac_nids,
18876 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18877 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018878 /*.input_mux = &alc272_nc10_capture_source,*/
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018879 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018880 .setup = alc663_mode4_setup,
Takashi Iwai3b8510c2011-04-28 14:03:24 +020018881 .init_hook = alc_inithook,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018883};
18884
18885
18886/*
18887 * BIOS auto configuration
18888 */
18889
Takashi Iwai7085ec12009-10-02 09:03:58 +020018890/* convert from MIX nid to DAC */
Takashi Iwai604401a2011-04-27 15:14:23 +020018891static hda_nid_t alc_auto_mix_to_dac(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018892{
Takashi Iwai604401a2011-04-27 15:14:23 +020018893 hda_nid_t list[5];
Takashi Iwai1304ac82011-04-06 15:16:21 +020018894 int i, num;
18895
18896 num = snd_hda_get_connections(codec, nid, list, ARRAY_SIZE(list));
18897 for (i = 0; i < num; i++) {
18898 if (get_wcaps_type(get_wcaps(codec, list[i])) == AC_WID_AUD_OUT)
18899 return list[i];
18900 }
18901 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018902}
18903
Takashi Iwai604401a2011-04-27 15:14:23 +020018904/* go down to the selector widget before the mixer */
18905static hda_nid_t alc_go_down_to_selector(struct hda_codec *codec, hda_nid_t pin)
18906{
18907 hda_nid_t srcs[5];
18908 int num = snd_hda_get_connections(codec, pin, srcs,
18909 ARRAY_SIZE(srcs));
18910 if (num != 1 ||
18911 get_wcaps_type(get_wcaps(codec, srcs[0])) != AC_WID_AUD_SEL)
18912 return pin;
18913 return srcs[0];
18914}
18915
Takashi Iwai7085ec12009-10-02 09:03:58 +020018916/* get MIX nid connected to the given pin targeted to DAC */
Takashi Iwai604401a2011-04-27 15:14:23 +020018917static hda_nid_t alc_auto_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018918 hda_nid_t dac)
18919{
David Henningssoncc1c4522010-11-24 14:17:47 +010018920 hda_nid_t mix[5];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018921 int i, num;
18922
Takashi Iwai604401a2011-04-27 15:14:23 +020018923 pin = alc_go_down_to_selector(codec, pin);
Takashi Iwai7085ec12009-10-02 09:03:58 +020018924 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
18925 for (i = 0; i < num; i++) {
Takashi Iwai604401a2011-04-27 15:14:23 +020018926 if (alc_auto_mix_to_dac(codec, mix[i]) == dac)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018927 return mix[i];
18928 }
18929 return 0;
18930}
18931
Takashi Iwaice764ab2011-04-27 16:35:23 +020018932/* select the connection from pin to DAC if needed */
18933static int alc_auto_select_dac(struct hda_codec *codec, hda_nid_t pin,
18934 hda_nid_t dac)
18935{
18936 hda_nid_t mix[5];
18937 int i, num;
18938
18939 pin = alc_go_down_to_selector(codec, pin);
18940 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
18941 if (num < 2)
18942 return 0;
18943 for (i = 0; i < num; i++) {
18944 if (alc_auto_mix_to_dac(codec, mix[i]) == dac) {
18945 snd_hda_codec_update_cache(codec, pin, 0,
18946 AC_VERB_SET_CONNECT_SEL, i);
18947 return 0;
18948 }
18949 }
18950 return 0;
18951}
18952
Takashi Iwai7085ec12009-10-02 09:03:58 +020018953/* look for an empty DAC slot */
Takashi Iwai604401a2011-04-27 15:14:23 +020018954static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018955{
18956 struct alc_spec *spec = codec->spec;
18957 hda_nid_t srcs[5];
18958 int i, j, num;
18959
Takashi Iwai604401a2011-04-27 15:14:23 +020018960 pin = alc_go_down_to_selector(codec, pin);
Takashi Iwai7085ec12009-10-02 09:03:58 +020018961 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
Takashi Iwai7085ec12009-10-02 09:03:58 +020018962 for (i = 0; i < num; i++) {
Takashi Iwai604401a2011-04-27 15:14:23 +020018963 hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]);
Takashi Iwai7085ec12009-10-02 09:03:58 +020018964 if (!nid)
18965 continue;
18966 for (j = 0; j < spec->multiout.num_dacs; j++)
18967 if (spec->multiout.dac_nids[j] == nid)
18968 break;
18969 if (j >= spec->multiout.num_dacs)
18970 return nid;
18971 }
18972 return 0;
18973}
18974
18975/* fill in the dac_nids table from the parsed pin configuration */
18976static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
18977 const struct auto_pin_cfg *cfg)
18978{
18979 struct alc_spec *spec = codec->spec;
18980 int i;
18981 hda_nid_t dac;
18982
18983 spec->multiout.dac_nids = spec->private_dac_nids;
18984 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai604401a2011-04-27 15:14:23 +020018985 dac = alc_auto_look_for_dac(codec, cfg->line_out_pins[i]);
Takashi Iwai7085ec12009-10-02 09:03:58 +020018986 if (!dac)
18987 continue;
Takashi Iwaidda14412011-05-02 11:29:30 +020018988 spec->private_dac_nids[spec->multiout.num_dacs++] = dac;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018989 }
18990 return 0;
18991}
18992
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010018993static inline int __alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
18994 hda_nid_t nid, int idx, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018995{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010018996 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018997 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
18998}
18999
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019000static inline int __alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
19001 hda_nid_t nid, int idx, unsigned int chs)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019002{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019003 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019004 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
19005}
19006
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019007#define alc662_add_vol_ctl(spec, pfx, nid, chs) \
19008 __alc662_add_vol_ctl(spec, pfx, nid, 0, chs)
19009#define alc662_add_sw_ctl(spec, pfx, nid, chs) \
19010 __alc662_add_sw_ctl(spec, pfx, nid, 0, chs)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019011#define alc662_add_stereo_vol(spec, pfx, nid) \
19012 alc662_add_vol_ctl(spec, pfx, nid, 3)
19013#define alc662_add_stereo_sw(spec, pfx, nid) \
19014 alc662_add_sw_ctl(spec, pfx, nid, 3)
19015
19016/* add playback controls from the parsed DAC table */
19017static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
19018 const struct auto_pin_cfg *cfg)
19019{
19020 struct alc_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +010019021 static const char * const chname[4] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019022 "Front", "Surround", NULL /*CLFE*/, "Side"
19023 };
Takashi Iwaice764ab2011-04-27 16:35:23 +020019024 const char *pfx = alc_get_line_out_pfx(spec, true);
19025 hda_nid_t nid, mix, pin;
19026 int i, err, noutputs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019027
Takashi Iwaice764ab2011-04-27 16:35:23 +020019028 noutputs = cfg->line_outs;
19029 if (spec->multi_ios > 0)
19030 noutputs += spec->multi_ios;
19031
19032 for (i = 0; i < noutputs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019033 nid = spec->multiout.dac_nids[i];
19034 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019035 continue;
Takashi Iwaice764ab2011-04-27 16:35:23 +020019036 if (i >= cfg->line_outs)
19037 pin = spec->multi_io[i - 1].pin;
19038 else
19039 pin = cfg->line_out_pins[i];
19040 mix = alc_auto_dac_to_mix(codec, pin, nid);
Takashi Iwai7085ec12009-10-02 09:03:58 +020019041 if (!mix)
19042 continue;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019043 if (!pfx && i == 2) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019044 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019045 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019046 if (err < 0)
19047 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019048 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019049 if (err < 0)
19050 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019051 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019052 if (err < 0)
19053 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019054 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019055 if (err < 0)
19056 return err;
19057 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019058 const char *name = pfx;
David Henningsson5a882642011-03-23 08:35:07 +010019059 int index = i;
19060 if (!name) {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019061 name = chname[i];
David Henningsson5a882642011-03-23 08:35:07 +010019062 index = 0;
19063 }
19064 err = __alc662_add_vol_ctl(spec, name, nid, index, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019065 if (err < 0)
19066 return err;
David Henningsson5a882642011-03-23 08:35:07 +010019067 err = __alc662_add_sw_ctl(spec, name, mix, index, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019068 if (err < 0)
19069 return err;
19070 }
19071 }
19072 return 0;
19073}
19074
19075/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019076/* return DAC nid if any new DAC is assigned */
19077static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019078 const char *pfx)
19079{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019080 struct alc_spec *spec = codec->spec;
19081 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019082 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019083
19084 if (!pin)
19085 return 0;
Takashi Iwai604401a2011-04-27 15:14:23 +020019086 nid = alc_auto_look_for_dac(codec, pin);
Takashi Iwai7085ec12009-10-02 09:03:58 +020019087 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019088 /* the corresponding DAC is already occupied */
19089 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
19090 return 0; /* no way */
19091 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019092 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019093 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
19094 }
19095
Takashi Iwai604401a2011-04-27 15:14:23 +020019096 mix = alc_auto_dac_to_mix(codec, pin, nid);
Takashi Iwai7085ec12009-10-02 09:03:58 +020019097 if (!mix)
19098 return 0;
19099 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
19100 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020019101 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019102 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
19103 if (err < 0)
19104 return err;
19105 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019106}
19107
19108/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020019109#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020019110 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019111
19112static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
19113 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019114 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019115{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019116 int i, num;
Takashi Iwaice503f32010-07-30 10:37:29 +020019117 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019118
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019119 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai7085ec12009-10-02 09:03:58 +020019120 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
Takashi Iwai7085ec12009-10-02 09:03:58 +020019121 for (i = 0; i < num; i++) {
Takashi Iwai604401a2011-04-27 15:14:23 +020019122 if (alc_auto_mix_to_dac(codec, srcs[i]) != dac)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019123 continue;
Takashi Iwai0e53f342011-04-07 12:27:32 +020019124 /* need the manual connection? */
19125 if (num > 1)
19126 snd_hda_codec_write(codec, nid, 0,
19127 AC_VERB_SET_CONNECT_SEL, i);
19128 /* unmute mixer widget inputs */
19129 snd_hda_codec_write(codec, srcs[i], 0,
19130 AC_VERB_SET_AMP_GAIN_MUTE,
19131 AMP_IN_UNMUTE(0));
19132 snd_hda_codec_write(codec, srcs[i], 0,
19133 AC_VERB_SET_AMP_GAIN_MUTE,
19134 AMP_IN_UNMUTE(1));
Takashi Iwai7085ec12009-10-02 09:03:58 +020019135 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019136 }
19137}
19138
19139static void alc662_auto_init_multi_out(struct hda_codec *codec)
19140{
19141 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019142 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019143 int i;
19144
19145 for (i = 0; i <= HDA_SIDE; i++) {
19146 hda_nid_t nid = spec->autocfg.line_out_pins[i];
19147 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020019148 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019149 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019150 }
19151}
19152
19153static void alc662_auto_init_hp_out(struct hda_codec *codec)
19154{
19155 struct alc_spec *spec = codec->spec;
19156 hda_nid_t pin;
19157
19158 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019159 if (pin)
19160 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
19161 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019162 pin = spec->autocfg.speaker_pins[0];
19163 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019164 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
19165 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019166}
19167
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019168#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
19169
19170static void alc662_auto_init_analog_input(struct hda_codec *codec)
19171{
19172 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019173 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019174 int i;
19175
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019176 for (i = 0; i < cfg->num_inputs; i++) {
19177 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019178 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020019179 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010019180 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010019181 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019182 snd_hda_codec_write(codec, nid, 0,
19183 AC_VERB_SET_AMP_GAIN_MUTE,
19184 AMP_OUT_MUTE);
19185 }
19186 }
19187}
19188
Takashi Iwaif511b012008-08-15 16:46:42 +020019189#define alc662_auto_init_input_src alc882_auto_init_input_src
19190
Takashi Iwaice764ab2011-04-27 16:35:23 +020019191/*
19192 * multi-io helper
19193 */
19194static int alc_auto_fill_multi_ios(struct hda_codec *codec,
19195 unsigned int location)
19196{
19197 struct alc_spec *spec = codec->spec;
19198 struct auto_pin_cfg *cfg = &spec->autocfg;
19199 int type, i, num_pins = 0;
19200
19201 for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) {
19202 for (i = 0; i < cfg->num_inputs; i++) {
19203 hda_nid_t nid = cfg->inputs[i].pin;
19204 hda_nid_t dac;
19205 unsigned int defcfg, caps;
19206 if (cfg->inputs[i].type != type)
19207 continue;
19208 defcfg = snd_hda_codec_get_pincfg(codec, nid);
19209 if (get_defcfg_connect(defcfg) != AC_JACK_PORT_COMPLEX)
19210 continue;
19211 if (location && get_defcfg_location(defcfg) != location)
19212 continue;
19213 caps = snd_hda_query_pin_caps(codec, nid);
19214 if (!(caps & AC_PINCAP_OUT))
19215 continue;
19216 dac = alc_auto_look_for_dac(codec, nid);
19217 if (!dac)
19218 continue;
19219 spec->multi_io[num_pins].pin = nid;
19220 spec->multi_io[num_pins].dac = dac;
19221 num_pins++;
Takashi Iwaidda14412011-05-02 11:29:30 +020019222 spec->private_dac_nids[spec->multiout.num_dacs++] = dac;
Takashi Iwaice764ab2011-04-27 16:35:23 +020019223 }
19224 }
19225 spec->multiout.num_dacs = 1;
19226 if (num_pins < 2)
19227 return 0;
19228 return num_pins;
19229}
19230
19231static int alc_auto_ch_mode_info(struct snd_kcontrol *kcontrol,
19232 struct snd_ctl_elem_info *uinfo)
19233{
19234 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
19235 struct alc_spec *spec = codec->spec;
19236
19237 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
19238 uinfo->count = 1;
19239 uinfo->value.enumerated.items = spec->multi_ios + 1;
19240 if (uinfo->value.enumerated.item > spec->multi_ios)
19241 uinfo->value.enumerated.item = spec->multi_ios;
19242 sprintf(uinfo->value.enumerated.name, "%dch",
19243 (uinfo->value.enumerated.item + 1) * 2);
19244 return 0;
19245}
19246
19247static int alc_auto_ch_mode_get(struct snd_kcontrol *kcontrol,
19248 struct snd_ctl_elem_value *ucontrol)
19249{
19250 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
19251 struct alc_spec *spec = codec->spec;
19252 ucontrol->value.enumerated.item[0] = (spec->ext_channel_count - 1) / 2;
19253 return 0;
19254}
19255
19256static int alc_set_multi_io(struct hda_codec *codec, int idx, bool output)
19257{
19258 struct alc_spec *spec = codec->spec;
19259 hda_nid_t nid = spec->multi_io[idx].pin;
19260
19261 if (!spec->multi_io[idx].ctl_in)
19262 spec->multi_io[idx].ctl_in =
19263 snd_hda_codec_read(codec, nid, 0,
19264 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
19265 if (output) {
19266 snd_hda_codec_update_cache(codec, nid, 0,
19267 AC_VERB_SET_PIN_WIDGET_CONTROL,
19268 PIN_OUT);
19269 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
19270 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
19271 HDA_AMP_MUTE, 0);
19272 alc_auto_select_dac(codec, nid, spec->multi_io[idx].dac);
19273 } else {
19274 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
19275 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
19276 HDA_AMP_MUTE, HDA_AMP_MUTE);
19277 snd_hda_codec_update_cache(codec, nid, 0,
19278 AC_VERB_SET_PIN_WIDGET_CONTROL,
19279 spec->multi_io[idx].ctl_in);
19280 }
19281 return 0;
19282}
19283
19284static int alc_auto_ch_mode_put(struct snd_kcontrol *kcontrol,
19285 struct snd_ctl_elem_value *ucontrol)
19286{
19287 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
19288 struct alc_spec *spec = codec->spec;
19289 int i, ch;
19290
19291 ch = ucontrol->value.enumerated.item[0];
19292 if (ch < 0 || ch > spec->multi_ios)
19293 return -EINVAL;
19294 if (ch == (spec->ext_channel_count - 1) / 2)
19295 return 0;
19296 spec->ext_channel_count = (ch + 1) * 2;
19297 for (i = 0; i < spec->multi_ios; i++)
19298 alc_set_multi_io(codec, i, i < ch);
19299 spec->multiout.max_channels = spec->ext_channel_count;
19300 return 1;
19301}
19302
Takashi Iwaia9111322011-05-02 11:30:18 +020019303static const struct snd_kcontrol_new alc_auto_channel_mode_enum = {
Takashi Iwaice764ab2011-04-27 16:35:23 +020019304 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
19305 .name = "Channel Mode",
19306 .info = alc_auto_ch_mode_info,
19307 .get = alc_auto_ch_mode_get,
19308 .put = alc_auto_ch_mode_put,
19309};
19310
19311static int alc_auto_add_multi_channel_mode(struct hda_codec *codec)
19312{
19313 struct alc_spec *spec = codec->spec;
19314 struct auto_pin_cfg *cfg = &spec->autocfg;
19315 unsigned int location, defcfg;
19316 int num_pins;
19317
19318 if (cfg->line_outs != 1 ||
19319 cfg->line_out_type != AUTO_PIN_LINE_OUT)
19320 return 0;
19321
19322 defcfg = snd_hda_codec_get_pincfg(codec, cfg->line_out_pins[0]);
19323 location = get_defcfg_location(defcfg);
19324
19325 num_pins = alc_auto_fill_multi_ios(codec, location);
19326 if (num_pins > 0) {
19327 struct snd_kcontrol_new *knew;
19328
19329 knew = alc_kcontrol_new(spec);
19330 if (!knew)
19331 return -ENOMEM;
19332 *knew = alc_auto_channel_mode_enum;
19333 knew->name = kstrdup("Channel Mode", GFP_KERNEL);
19334 if (!knew->name)
19335 return -ENOMEM;
19336
19337 spec->multi_ios = num_pins;
19338 spec->ext_channel_count = 2;
19339 spec->multiout.num_dacs = num_pins + 1;
19340 }
19341 return 0;
19342}
19343
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019344static int alc662_parse_auto_config(struct hda_codec *codec)
19345{
19346 struct alc_spec *spec = codec->spec;
19347 int err;
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020019348 static const hda_nid_t alc662_ignore[] = { 0x1d, 0 };
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019349
19350 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19351 alc662_ignore);
19352 if (err < 0)
19353 return err;
19354 if (!spec->autocfg.line_outs)
19355 return 0; /* can't find valid BIOS pin config */
19356
Takashi Iwai7085ec12009-10-02 09:03:58 +020019357 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019358 if (err < 0)
19359 return err;
Takashi Iwaice764ab2011-04-27 16:35:23 +020019360 err = alc_auto_add_multi_channel_mode(codec);
19361 if (err < 0)
19362 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019363 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019364 if (err < 0)
19365 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019366 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019367 spec->autocfg.speaker_pins[0],
19368 "Speaker");
19369 if (err < 0)
19370 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019371 if (err)
19372 spec->multiout.extra_out_nid[0] = err;
19373 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019374 "Headphone");
19375 if (err < 0)
19376 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019377 if (err)
19378 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019379 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019380 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019381 return err;
19382
19383 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
19384
Takashi Iwai757899a2010-07-30 10:48:14 +020019385 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019386
Takashi Iwai603c4012008-07-30 15:01:44 +020019387 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010019388 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019389
19390 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020019391 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020019392
Takashi Iwaiee979a142008-09-02 15:42:20 +020019393 err = alc_auto_add_mic_boost(codec);
19394 if (err < 0)
19395 return err;
19396
Kailang Yang6227cdc2010-02-25 08:36:52 +010019397 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
19398 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
19399 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
19400 else
19401 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020019402
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019403 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019404}
19405
19406/* additional initialization for auto-configuration model */
19407static void alc662_auto_init(struct hda_codec *codec)
19408{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019409 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019410 alc662_auto_init_multi_out(codec);
19411 alc662_auto_init_hp_out(codec);
19412 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020019413 alc662_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019414 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019415 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020019416 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019417}
19418
Todd Broch6be79482010-12-07 16:51:05 -080019419static void alc272_fixup_mario(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019420 const struct alc_fixup *fix, int action)
Takashi Iwai6fc398c2011-01-13 14:36:37 +010019421{
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019422 if (action != ALC_FIXUP_ACT_PROBE)
Takashi Iwai6fc398c2011-01-13 14:36:37 +010019423 return;
Todd Broch6be79482010-12-07 16:51:05 -080019424 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
19425 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
19426 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
19427 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
19428 (0 << AC_AMPCAP_MUTE_SHIFT)))
19429 printk(KERN_WARNING
19430 "hda_codec: failed to override amp caps for NID 0x2\n");
19431}
19432
David Henningsson6cb3b702010-09-09 08:51:44 +020019433enum {
Daniel T Chen2df03512010-10-10 22:39:28 -040019434 ALC662_FIXUP_ASPIRE,
David Henningsson6cb3b702010-09-09 08:51:44 +020019435 ALC662_FIXUP_IDEAPAD,
Todd Broch6be79482010-12-07 16:51:05 -080019436 ALC272_FIXUP_MARIO,
Anisse Astierd2ebd472011-01-20 12:36:21 +010019437 ALC662_FIXUP_CZC_P10T,
David Henningsson94024cd2011-04-29 14:10:55 +020019438 ALC662_FIXUP_SKU_IGNORE,
David Henningsson6cb3b702010-09-09 08:51:44 +020019439};
19440
19441static const struct alc_fixup alc662_fixups[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -040019442 [ALC662_FIXUP_ASPIRE] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019443 .type = ALC_FIXUP_PINS,
19444 .v.pins = (const struct alc_pincfg[]) {
Daniel T Chen2df03512010-10-10 22:39:28 -040019445 { 0x15, 0x99130112 }, /* subwoofer */
19446 { }
19447 }
19448 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019449 [ALC662_FIXUP_IDEAPAD] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019450 .type = ALC_FIXUP_PINS,
19451 .v.pins = (const struct alc_pincfg[]) {
David Henningsson6cb3b702010-09-09 08:51:44 +020019452 { 0x17, 0x99130112 }, /* subwoofer */
19453 { }
19454 }
19455 },
Todd Broch6be79482010-12-07 16:51:05 -080019456 [ALC272_FIXUP_MARIO] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019457 .type = ALC_FIXUP_FUNC,
19458 .v.func = alc272_fixup_mario,
Anisse Astierd2ebd472011-01-20 12:36:21 +010019459 },
19460 [ALC662_FIXUP_CZC_P10T] = {
19461 .type = ALC_FIXUP_VERBS,
19462 .v.verbs = (const struct hda_verb[]) {
19463 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
19464 {}
19465 }
19466 },
David Henningsson94024cd2011-04-29 14:10:55 +020019467 [ALC662_FIXUP_SKU_IGNORE] = {
19468 .type = ALC_FIXUP_SKU,
19469 .v.sku = ALC_FIXUP_SKU_IGNORE,
Takashi Iwaic6b35872011-03-28 12:05:31 +020019470 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019471};
19472
Takashi Iwaia9111322011-05-02 11:30:18 +020019473static const struct snd_pci_quirk alc662_fixup_tbl[] = {
David Henningssona6c47a82011-02-10 15:39:19 +010019474 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
David Henningsson94024cd2011-04-29 14:10:55 +020019475 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
Daniel T Chen2df03512010-10-10 22:39:28 -040019476 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
Daniel T Chena0e90ac2010-11-20 10:20:35 -050019477 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
Valentine Sinitsynd4118582010-10-01 22:24:08 +060019478 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
David Henningsson6cb3b702010-09-09 08:51:44 +020019479 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
Anisse Astierd2ebd472011-01-20 12:36:21 +010019480 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
David Henningsson6cb3b702010-09-09 08:51:44 +020019481 {}
19482};
19483
Todd Broch6be79482010-12-07 16:51:05 -080019484static const struct alc_model_fixup alc662_fixup_models[] = {
19485 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
19486 {}
19487};
David Henningsson6cb3b702010-09-09 08:51:44 +020019488
19489
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019490static int patch_alc662(struct hda_codec *codec)
19491{
19492 struct alc_spec *spec;
19493 int err, board_config;
Kailang Yang693194f2010-10-21 08:51:48 +020019494 int coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019495
19496 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19497 if (!spec)
19498 return -ENOMEM;
19499
19500 codec->spec = spec;
19501
Kailang Yangda00c242010-03-19 11:23:45 +010019502 alc_auto_parse_customize_define(codec);
19503
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020019504 alc_fix_pll_init(codec, 0x20, 0x04, 15);
19505
Kailang Yang693194f2010-10-21 08:51:48 +020019506 coef = alc_read_coef_idx(codec, 0);
19507 if (coef == 0x8020 || coef == 0x8011)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019508 alc_codec_rename(codec, "ALC661");
Kailang Yang693194f2010-10-21 08:51:48 +020019509 else if (coef & (1 << 14) &&
19510 codec->bus->pci->subsystem_vendor == 0x1025 &&
19511 spec->cdefine.platform_type == 1)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019512 alc_codec_rename(codec, "ALC272X");
Kailang Yang693194f2010-10-21 08:51:48 +020019513 else if (coef == 0x4011)
19514 alc_codec_rename(codec, "ALC656");
Kailang Yang274693f2009-12-03 10:07:50 +010019515
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019516 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
19517 alc662_models,
19518 alc662_cfg_tbl);
19519 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020019520 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19521 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019522 board_config = ALC662_AUTO;
19523 }
19524
19525 if (board_config == ALC662_AUTO) {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019526 alc_pick_fixup(codec, alc662_fixup_models,
19527 alc662_fixup_tbl, alc662_fixups);
19528 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019529 /* automatic parse from the BIOS config */
19530 err = alc662_parse_auto_config(codec);
19531 if (err < 0) {
19532 alc_free(codec);
19533 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019534 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019535 printk(KERN_INFO
19536 "hda_codec: Cannot set up configuration "
19537 "from BIOS. Using base mode...\n");
19538 board_config = ALC662_3ST_2ch_DIG;
19539 }
19540 }
19541
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019542 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020019543 err = snd_hda_attach_beep_device(codec, 0x1);
19544 if (err < 0) {
19545 alc_free(codec);
19546 return err;
19547 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090019548 }
19549
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019550 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020019551 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019552
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019553 spec->stream_analog_playback = &alc662_pcm_analog_playback;
19554 spec->stream_analog_capture = &alc662_pcm_analog_capture;
19555
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019556 spec->stream_digital_playback = &alc662_pcm_digital_playback;
19557 spec->stream_digital_capture = &alc662_pcm_digital_capture;
19558
Takashi Iwaidd704692009-08-11 08:45:11 +020019559 if (!spec->adc_nids) {
19560 spec->adc_nids = alc662_adc_nids;
19561 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
19562 }
19563 if (!spec->capsrc_nids)
19564 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019565
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019566 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019567 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019568
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019569 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010019570 switch (codec->vendor_id) {
19571 case 0x10ec0662:
19572 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
19573 break;
19574 case 0x10ec0272:
19575 case 0x10ec0663:
19576 case 0x10ec0665:
19577 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
19578 break;
19579 case 0x10ec0273:
19580 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
19581 break;
19582 }
Kailang Yangcec27c82010-02-04 14:18:18 +010019583 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010019584 spec->vmaster_nid = 0x02;
19585
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019586 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
19587
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019588 codec->patch_ops = alc_patch_ops;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019589 if (board_config == ALC662_AUTO)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019590 spec->init_hook = alc662_auto_init;
Takashi Iwai1c7161532011-04-07 10:37:16 +020019591 spec->shutup = alc_eapd_shutup;
David Henningsson6cb3b702010-09-09 08:51:44 +020019592
Kailang Yangbf1b0222010-10-21 08:49:56 +020019593 alc_init_jacks(codec);
19594
Takashi Iwaicb53c622007-08-10 17:21:45 +020019595#ifdef CONFIG_SND_HDA_POWER_SAVE
19596 if (!spec->loopback.amplist)
19597 spec->loopback.amplist = alc662_loopbacks;
19598#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019599
19600 return 0;
19601}
19602
Kailang Yang274693f2009-12-03 10:07:50 +010019603static int patch_alc888(struct hda_codec *codec)
19604{
19605 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19606 kfree(codec->chip_name);
Kailang Yang01e0f132010-11-22 10:59:36 +010019607 if (codec->vendor_id == 0x10ec0887)
19608 codec->chip_name = kstrdup("ALC887-VD", GFP_KERNEL);
19609 else
19610 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019611 if (!codec->chip_name) {
19612 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019613 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019614 }
19615 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019616 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019617 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019618}
19619
Kailang Yangb478b992011-05-18 11:51:15 +020019620static int patch_alc899(struct hda_codec *codec)
19621{
19622 if ((alc_read_coef_idx(codec, 0) & 0x2000) != 0x2000) {
19623 kfree(codec->chip_name);
19624 codec->chip_name = kstrdup("ALC898", GFP_KERNEL);
19625 }
19626 return patch_alc882(codec);
19627}
19628
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019629/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019630 * ALC680 support
19631 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019632#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019633#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19634#define alc680_modes alc260_modes
19635
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020019636static const hda_nid_t alc680_dac_nids[3] = {
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019637 /* Lout1, Lout2, hp */
19638 0x02, 0x03, 0x04
19639};
19640
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020019641static const hda_nid_t alc680_adc_nids[3] = {
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019642 /* ADC0-2 */
19643 /* DMIC, MIC, Line-in*/
19644 0x07, 0x08, 0x09
19645};
19646
Kailang Yangc69aefa2010-08-17 10:39:22 +020019647/*
19648 * Analog capture ADC cgange
19649 */
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019650static void alc680_rec_autoswitch(struct hda_codec *codec)
19651{
19652 struct alc_spec *spec = codec->spec;
19653 struct auto_pin_cfg *cfg = &spec->autocfg;
19654 int pin_found = 0;
19655 int type_found = AUTO_PIN_LAST;
19656 hda_nid_t nid;
19657 int i;
19658
19659 for (i = 0; i < cfg->num_inputs; i++) {
19660 nid = cfg->inputs[i].pin;
Takashi Iwai06dec222011-05-17 10:00:16 +020019661 if (!is_jack_detectable(codec, nid))
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019662 continue;
19663 if (snd_hda_jack_detect(codec, nid)) {
19664 if (cfg->inputs[i].type < type_found) {
19665 type_found = cfg->inputs[i].type;
19666 pin_found = nid;
19667 }
19668 }
19669 }
19670
19671 nid = 0x07;
19672 if (pin_found)
19673 snd_hda_get_connections(codec, pin_found, &nid, 1);
19674
19675 if (nid != spec->cur_adc)
19676 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
19677 spec->cur_adc = nid;
19678 snd_hda_codec_setup_stream(codec, nid, spec->cur_adc_stream_tag, 0,
19679 spec->cur_adc_format);
19680}
19681
Kailang Yangc69aefa2010-08-17 10:39:22 +020019682static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19683 struct hda_codec *codec,
19684 unsigned int stream_tag,
19685 unsigned int format,
19686 struct snd_pcm_substream *substream)
19687{
19688 struct alc_spec *spec = codec->spec;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019689
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019690 spec->cur_adc = 0x07;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019691 spec->cur_adc_stream_tag = stream_tag;
19692 spec->cur_adc_format = format;
19693
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019694 alc680_rec_autoswitch(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019695 return 0;
19696}
19697
19698static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19699 struct hda_codec *codec,
19700 struct snd_pcm_substream *substream)
19701{
19702 snd_hda_codec_cleanup_stream(codec, 0x07);
19703 snd_hda_codec_cleanup_stream(codec, 0x08);
19704 snd_hda_codec_cleanup_stream(codec, 0x09);
19705 return 0;
19706}
19707
Takashi Iwaia9111322011-05-02 11:30:18 +020019708static const struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019709 .substreams = 1, /* can be overridden */
19710 .channels_min = 2,
19711 .channels_max = 2,
19712 /* NID is set in alc_build_pcms */
19713 .ops = {
19714 .prepare = alc680_capture_pcm_prepare,
19715 .cleanup = alc680_capture_pcm_cleanup
19716 },
19717};
19718
Takashi Iwaia9111322011-05-02 11:30:18 +020019719static const struct snd_kcontrol_new alc680_base_mixer[] = {
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019720 /* output mixer control */
19721 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19722 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19723 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19724 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010019725 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x12, 0, HDA_INPUT),
19726 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
19727 HDA_CODEC_VOLUME("Line In Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019728 { }
19729};
19730
Takashi Iwaia9111322011-05-02 11:30:18 +020019731static const struct hda_bind_ctls alc680_bind_cap_vol = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019732 .ops = &snd_hda_bind_vol,
19733 .values = {
19734 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19735 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19736 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19737 0
19738 },
19739};
19740
Takashi Iwaia9111322011-05-02 11:30:18 +020019741static const struct hda_bind_ctls alc680_bind_cap_switch = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019742 .ops = &snd_hda_bind_sw,
19743 .values = {
19744 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19745 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19746 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19747 0
19748 },
19749};
19750
Takashi Iwaia9111322011-05-02 11:30:18 +020019751static const struct snd_kcontrol_new alc680_master_capture_mixer[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019752 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19753 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019754 { } /* end */
19755};
19756
19757/*
19758 * generic initialization of ADC, input mixers and output mixers
19759 */
Takashi Iwaia9111322011-05-02 11:30:18 +020019760static const struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019761 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19762 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19763 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019764
Kailang Yangc69aefa2010-08-17 10:39:22 +020019765 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19766 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19767 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19768 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19769 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19770 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019771
19772 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19773 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19774 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19775 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19776 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019777
19778 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19779 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019780 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019781
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019782 { }
19783};
19784
Kailang Yangc69aefa2010-08-17 10:39:22 +020019785/* toggle speaker-output according to the hp-jack state */
19786static void alc680_base_setup(struct hda_codec *codec)
19787{
19788 struct alc_spec *spec = codec->spec;
19789
19790 spec->autocfg.hp_pins[0] = 0x16;
19791 spec->autocfg.speaker_pins[0] = 0x14;
19792 spec->autocfg.speaker_pins[1] = 0x15;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019793 spec->autocfg.num_inputs = 2;
19794 spec->autocfg.inputs[0].pin = 0x18;
19795 spec->autocfg.inputs[0].type = AUTO_PIN_MIC;
19796 spec->autocfg.inputs[1].pin = 0x19;
Takashi Iwai86e29592010-09-09 14:50:17 +020019797 spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN;
Takashi Iwaid922b512011-04-28 12:18:53 +020019798 spec->automute = 1;
19799 spec->automute_mode = ALC_AUTOMUTE_AMP;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019800}
19801
19802static void alc680_unsol_event(struct hda_codec *codec,
19803 unsigned int res)
19804{
19805 if ((res >> 26) == ALC880_HP_EVENT)
Takashi Iwaid922b512011-04-28 12:18:53 +020019806 alc_hp_automute(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019807 if ((res >> 26) == ALC880_MIC_EVENT)
19808 alc680_rec_autoswitch(codec);
19809}
19810
19811static void alc680_inithook(struct hda_codec *codec)
19812{
Takashi Iwaid922b512011-04-28 12:18:53 +020019813 alc_hp_automute(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019814 alc680_rec_autoswitch(codec);
19815}
19816
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019817/* create input playback/capture controls for the given pin */
19818static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19819 const char *ctlname, int idx)
19820{
19821 hda_nid_t dac;
19822 int err;
19823
19824 switch (nid) {
19825 case 0x14:
19826 dac = 0x02;
19827 break;
19828 case 0x15:
19829 dac = 0x03;
19830 break;
19831 case 0x16:
19832 dac = 0x04;
19833 break;
19834 default:
19835 return 0;
19836 }
19837 if (spec->multiout.dac_nids[0] != dac &&
19838 spec->multiout.dac_nids[1] != dac) {
19839 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19840 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19841 HDA_OUTPUT));
19842 if (err < 0)
19843 return err;
19844
19845 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19846 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19847
19848 if (err < 0)
19849 return err;
Takashi Iwaidda14412011-05-02 11:29:30 +020019850 spec->private_dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019851 }
19852
19853 return 0;
19854}
19855
19856/* add playback controls from the parsed DAC table */
19857static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19858 const struct auto_pin_cfg *cfg)
19859{
19860 hda_nid_t nid;
19861 int err;
19862
19863 spec->multiout.dac_nids = spec->private_dac_nids;
19864
19865 nid = cfg->line_out_pins[0];
19866 if (nid) {
19867 const char *name;
19868 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19869 name = "Speaker";
19870 else
19871 name = "Front";
19872 err = alc680_new_analog_output(spec, nid, name, 0);
19873 if (err < 0)
19874 return err;
19875 }
19876
19877 nid = cfg->speaker_pins[0];
19878 if (nid) {
19879 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19880 if (err < 0)
19881 return err;
19882 }
19883 nid = cfg->hp_pins[0];
19884 if (nid) {
19885 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19886 if (err < 0)
19887 return err;
19888 }
19889
19890 return 0;
19891}
19892
19893static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19894 hda_nid_t nid, int pin_type)
19895{
19896 alc_set_pin_output(codec, nid, pin_type);
19897}
19898
19899static void alc680_auto_init_multi_out(struct hda_codec *codec)
19900{
19901 struct alc_spec *spec = codec->spec;
19902 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19903 if (nid) {
19904 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19905 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19906 }
19907}
19908
19909static void alc680_auto_init_hp_out(struct hda_codec *codec)
19910{
19911 struct alc_spec *spec = codec->spec;
19912 hda_nid_t pin;
19913
19914 pin = spec->autocfg.hp_pins[0];
19915 if (pin)
19916 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
19917 pin = spec->autocfg.speaker_pins[0];
19918 if (pin)
19919 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
19920}
19921
19922/* pcm configuration: identical with ALC880 */
19923#define alc680_pcm_analog_playback alc880_pcm_analog_playback
19924#define alc680_pcm_analog_capture alc880_pcm_analog_capture
19925#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
19926#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020019927#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019928
19929/*
19930 * BIOS auto configuration
19931 */
19932static int alc680_parse_auto_config(struct hda_codec *codec)
19933{
19934 struct alc_spec *spec = codec->spec;
19935 int err;
Takashi Iwai4c6d72d2011-05-02 11:30:18 +020019936 static const hda_nid_t alc680_ignore[] = { 0 };
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019937
19938 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19939 alc680_ignore);
19940 if (err < 0)
19941 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019942
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019943 if (!spec->autocfg.line_outs) {
19944 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
19945 spec->multiout.max_channels = 2;
19946 spec->no_analog = 1;
19947 goto dig_only;
19948 }
19949 return 0; /* can't find valid BIOS pin config */
19950 }
19951 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
19952 if (err < 0)
19953 return err;
19954
19955 spec->multiout.max_channels = 2;
19956
19957 dig_only:
19958 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020019959 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019960 if (spec->kctls.list)
19961 add_mixer(spec, spec->kctls.list);
19962
19963 add_verb(spec, alc680_init_verbs);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019964
19965 err = alc_auto_add_mic_boost(codec);
19966 if (err < 0)
19967 return err;
19968
19969 return 1;
19970}
19971
19972#define alc680_auto_init_analog_input alc882_auto_init_analog_input
19973
19974/* init callback for auto-configuration model -- overriding the default init */
19975static void alc680_auto_init(struct hda_codec *codec)
19976{
19977 struct alc_spec *spec = codec->spec;
19978 alc680_auto_init_multi_out(codec);
19979 alc680_auto_init_hp_out(codec);
19980 alc680_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019981 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019982 if (spec->unsol_event)
19983 alc_inithook(codec);
19984}
19985
19986/*
19987 * configuration and preset
19988 */
Takashi Iwaiea734962011-01-17 11:29:34 +010019989static const char * const alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020019990 [ALC680_BASE] = "base",
19991 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019992};
19993
Takashi Iwaia9111322011-05-02 11:30:18 +020019994static const struct snd_pci_quirk alc680_cfg_tbl[] = {
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019995 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
19996 {}
19997};
19998
Takashi Iwaia9111322011-05-02 11:30:18 +020019999static const struct alc_config_preset alc680_presets[] = {
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020000 [ALC680_BASE] = {
20001 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020020002 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020003 .init_verbs = { alc680_init_verbs },
20004 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
20005 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020006 .dig_out_nid = ALC680_DIGOUT_NID,
20007 .num_channel_mode = ARRAY_SIZE(alc680_modes),
20008 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020020009 .unsol_event = alc680_unsol_event,
20010 .setup = alc680_base_setup,
20011 .init_hook = alc680_inithook,
20012
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020013 },
20014};
20015
20016static int patch_alc680(struct hda_codec *codec)
20017{
20018 struct alc_spec *spec;
20019 int board_config;
20020 int err;
20021
20022 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
20023 if (spec == NULL)
20024 return -ENOMEM;
20025
20026 codec->spec = spec;
20027
20028 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
20029 alc680_models,
20030 alc680_cfg_tbl);
20031
20032 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
20033 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
20034 codec->chip_name);
20035 board_config = ALC680_AUTO;
20036 }
20037
20038 if (board_config == ALC680_AUTO) {
20039 /* automatic parse from the BIOS config */
20040 err = alc680_parse_auto_config(codec);
20041 if (err < 0) {
20042 alc_free(codec);
20043 return err;
20044 } else if (!err) {
20045 printk(KERN_INFO
20046 "hda_codec: Cannot set up configuration "
20047 "from BIOS. Using base mode...\n");
20048 board_config = ALC680_BASE;
20049 }
20050 }
20051
20052 if (board_config != ALC680_AUTO)
20053 setup_preset(codec, &alc680_presets[board_config]);
20054
20055 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020020056 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020057 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020020058 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020059
20060 if (!spec->adc_nids) {
20061 spec->adc_nids = alc680_adc_nids;
20062 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids);
20063 }
20064
20065 if (!spec->cap_mixer)
20066 set_capture_mixer(codec);
20067
20068 spec->vmaster_nid = 0x02;
20069
20070 codec->patch_ops = alc_patch_ops;
20071 if (board_config == ALC680_AUTO)
20072 spec->init_hook = alc680_auto_init;
20073
20074 return 0;
20075}
20076
20077/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070020078 * patch entries
20079 */
Takashi Iwaia9111322011-05-02 11:30:18 +020020080static const struct hda_codec_preset snd_hda_preset_realtek[] = {
Kailang Yang296f0332011-05-18 11:52:36 +020020081 { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070020082 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010020083 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010020084 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020020085 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010020086 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010020087 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020020088 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010020089 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Kailang Yang296f0332011-05-18 11:52:36 +020020090 { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020091 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020092 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020093 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
20094 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
20095 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020096 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020097 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020098 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
20099 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020020100 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010020101 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010020102 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020103 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020104 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070020105 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020020106 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020020107 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020108 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020020109 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020110 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010020111 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yang01e0f132010-11-22 10:59:36 +010020112 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc888 },
Kailang Yang44426082008-10-15 11:18:05 +020020113 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020114 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010020115 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020020116 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010020117 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Kailang Yangb478b992011-05-18 11:51:15 +020020118 { .id = 0x10ec0899, .name = "ALC899", .patch = patch_alc899 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070020119 {} /* terminator */
20120};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010020121
20122MODULE_ALIAS("snd-hda-codec-id:10ec*");
20123
20124MODULE_LICENSE("GPL");
20125MODULE_DESCRIPTION("Realtek HD-audio codec");
20126
20127static struct hda_codec_preset_list realtek_list = {
20128 .preset = snd_hda_preset_realtek,
20129 .owner = THIS_MODULE,
20130};
20131
20132static int __init patch_realtek_init(void)
20133{
20134 return snd_hda_add_codec_preset(&realtek_list);
20135}
20136
20137static void __exit patch_realtek_exit(void)
20138{
20139 snd_hda_delete_codec_preset(&realtek_list);
20140}
20141
20142module_init(patch_realtek_init)
20143module_exit(patch_realtek_exit)